aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJim Porter2023-05-01 09:49:00 -0700
committerJim Porter2023-05-02 21:28:34 -0700
commit40d66095635ead025b33dc693a19b463f70eb9ce (patch)
tree75459d0d63878ddda41018cba4bc9dad0b6136bc /test
parentfa33a14ebe56aa1726df9c8ad93106966c5b6eae (diff)
downloademacs-40d66095635ead025b33dc693a19b463f70eb9ce.tar.gz
emacs-40d66095635ead025b33dc693a19b463f70eb9ce.zip
Use connection-aware functions when getting the UID/GID in Eshell
This means, for example, that when using Tramp to sudo in Eshell, "rm" queries the user before deleting anything (bug#63221). * lisp/eshell/esh-util.el (eshell-user-login-name): New function... * lisp/eshell/em-unix.el (eshell/whoami): ... use it. * lisp/eshell/em-ls.el (eshell-ls-applicable): Use 'file-user-uid' and 'eshell-user-login-name'. (eshell-ls-decorated-name): Use 'file-user-uid'. * lisp/eshell/em-pred.el (eshell-predicate-alist): Use 'file-user-uid' and 'file-group-gid'. * lisp/eshell/em-unix.el (eshell-interactive-query): New widget... (eshell-rm-interactive-query, eshell-mv-interactive-query) (eshell-cp-interactive-query, eshell-ln-interactive-query): ... use it. (eshell-interactive-query-p): New function... (eshell/rm, eshell/mv, eshell/cp, eshell/ln): ... use it. * lisp/simple.el (file-group-gid): New function. * lisp/net/ange-ftp.el (ange-ftp-file-group-gid): New function... (file-group-gid): ... use it. * lisp/net/tramp.el (tramp-handle-file-group-gid): * lisp/net/tramp-archive.el (tramp-archive-handle-file-group-gid): New functions. * lisp/net/tramp.el (tramp-file-name-for-operation): Add 'file-group-gid'. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'file-group-gid' mapping. * test/lisp/net/tramp-tests.el (tramp-test44-file-user-group-ids): * test/lisp/net/tramp-archive-tests.el (tramp-archive-test44-file-user-group-ids): Add tests for 'file-group-gid'. * doc/lispref/files.texi (Magic File Names): Mention 'file-group-gid'. * doc/lispref/os.texi (User Identification): Document 'file-group-gid', and move 'group-real-gid' to match the order of 'user-real-uid'. * etc/NEWS: Announce 'file-group-gid'.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/net/tramp-archive-tests.el14
-rw-r--r--test/lisp/net/tramp-tests.el14
2 files changed, 17 insertions, 11 deletions
diff --git a/test/lisp/net/tramp-archive-tests.el b/test/lisp/net/tramp-archive-tests.el
index 94ef40a1116..5fa727a13e5 100644
--- a/test/lisp/net/tramp-archive-tests.el
+++ b/test/lisp/net/tramp-archive-tests.el
@@ -881,16 +881,18 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
881 (zerop (nth 1 fsi)) 881 (zerop (nth 1 fsi))
882 (zerop (nth 2 fsi)))))) 882 (zerop (nth 2 fsi))))))
883 883
884;; `file-user-uid' was introduced in Emacs 30.1. 884;; `file-user-uid' and `file-group-gid' were introduced in Emacs 30.1.
885(ert-deftest tramp-archive-test44-file-user-uid () 885(ert-deftest tramp-archive-test44-user-group-ids ()
886 "Check that `file-user-uid' returns proper values." 886 "Check that `file-user-uid' returns proper values."
887 (skip-unless tramp-archive-enabled) 887 (skip-unless tramp-archive-enabled)
888 (skip-unless (fboundp 'file-user-uid)) 888 (skip-unless (and (fboundp 'file-user-uid)
889 (fboundp 'file-group-gid)))
889 890
890 (let ((default-directory tramp-archive-test-archive)) 891 (let ((default-directory tramp-archive-test-archive))
891 ;; `file-user-uid' exists since Emacs 30.1. We don't want to see 892 ;; `file-user-uid' and `file-group-gid' exist since Emacs 30.1.
892 ;; compiler warnings for older Emacsen. 893 ;; We don't want to see compiler warnings for older Emacsen.
893 (should (integerp (with-no-warnings (file-user-uid)))))) 894 (should (integerp (with-no-warnings (file-user-uid))))
895 (should (integerp (with-no-warnings (file-group-gid))))))
894 896
895(ert-deftest tramp-archive-test48-auto-load () 897(ert-deftest tramp-archive-test48-auto-load ()
896 "Check that `tramp-archive' autoloads properly." 898 "Check that `tramp-archive' autoloads properly."
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 5fde783087e..8e4e7122a27 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -7367,16 +7367,20 @@ This requires restrictions of file name syntax."
7367 (dotimes (i (length fsi)) 7367 (dotimes (i (length fsi))
7368 (should (natnump (or (nth i fsi) 0)))))) 7368 (should (natnump (or (nth i fsi) 0))))))
7369 7369
7370;; `file-user-uid' was introduced in Emacs 30.1. 7370;; `file-user-uid' and `file-group-gid' were introduced in Emacs 30.1.
7371(ert-deftest tramp-test44-file-user-uid () 7371(ert-deftest tramp-test44-file-user-group-ids ()
7372 "Check that `file-user-uid' and `tramp-get-remote-*' return proper values." 7372 "Check results of user/group functions.
7373`file-user-uid', `file-group-gid', and `tramp-get-remote-*'
7374should all return proper values."
7373 (skip-unless (tramp--test-enabled)) 7375 (skip-unless (tramp--test-enabled))
7374 7376
7375 (let ((default-directory ert-remote-temporary-file-directory)) 7377 (let ((default-directory ert-remote-temporary-file-directory))
7376 ;; `file-user-uid' exists since Emacs 30.1. We don't want to see 7378 ;; `file-user-uid' and `file-group-gid' exist since Emacs 30.1.
7377 ;; compiler warnings for older Emacsen. 7379 ;; We don't want to see compiler warnings for older Emacsen.
7378 (when (fboundp 'file-user-uid) 7380 (when (fboundp 'file-user-uid)
7379 (should (integerp (with-no-warnings (file-user-uid))))) 7381 (should (integerp (with-no-warnings (file-user-uid)))))
7382 (when (fboundp 'file-group-gid)
7383 (should (integerp (with-no-warnings (file-group-gid)))))
7380 7384
7381 (with-parsed-tramp-file-name default-directory nil 7385 (with-parsed-tramp-file-name default-directory nil
7382 (should (or (integerp (tramp-get-remote-uid v 'integer)) 7386 (should (or (integerp (tramp-get-remote-uid v 'integer))