diff options
| author | Jim Porter | 2023-01-10 15:35:18 -0800 |
|---|---|---|
| committer | Jim Porter | 2023-01-16 17:11:02 -0800 |
| commit | 0bb8a011d57cb55c16ff502125b60e8e3bb3d5aa (patch) | |
| tree | 4756c74e355419d4f14f569f0aa50ea2f13b6a49 | |
| parent | bcaa63ac506dc070b29db13326801ff978e8b00d (diff) | |
| download | emacs-0bb8a011d57cb55c16ff502125b60e8e3bb3d5aa.tar.gz emacs-0bb8a011d57cb55c16ff502125b60e8e3bb3d5aa.zip | |
Add 'file-user-uid' to get the connection-local effective UID
In particular, this lets Eshell show a "#" root prompt sigil when the
user has sudo'ed via "cd /sudo::" (bug#60722).
* lisp/simple.el (file-user-uid): New function.
* lisp/net/tramp.el (tramp-file-name-for-operation): Add
'file-user-uid'.
(tramp-handle-file-user-uid): New function.
* lisp/net/tramp-adb.el (tramp-adb-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-user-uid'.
* lisp/net/tramp-archive.el (tramp-archive-handle-file-user-uid): New
function...
(tramp-archive-file-name-handler-alist): ... use it.
* lisp/eshell/em-prompt.el (eshell-prompt-function): Use
'file-user-uid'.
* lisp/eshell/esh-var.el (eshell-variable-aliases-list): Add '$UID'.
* test/lisp/eshell/esh-var-tests.el (esh-var-test/uid-var): New test.
* doc/lispref/os.texi (User Identification): Document 'file-user-uid'.
* doc/lispref/files.texi (Magic File Names): Mention 'file-user-uid'.
* doc/misc/eshell.texi (Variables): Document '$UID'. Add a missing
index entry for '$INSIDE_EMACS'.
* etc/NEWS: Announce 'file-user-uid'.
| -rw-r--r-- | doc/lispref/files.texi | 6 | ||||
| -rw-r--r-- | doc/lispref/os.texi | 10 | ||||
| -rw-r--r-- | doc/misc/eshell.texi | 8 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/eshell/em-prompt.el | 2 | ||||
| -rw-r--r-- | lisp/eshell/esh-var.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-adb.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-archive.el | 7 | ||||
| -rw-r--r-- | lisp/net/tramp-crypt.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-gvfs.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-rclone.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-smb.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-sshfs.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-sudoedit.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 13 | ||||
| -rw-r--r-- | lisp/simple.el | 12 | ||||
| -rw-r--r-- | test/lisp/eshell/esh-var-tests.el | 4 |
18 files changed, 73 insertions, 4 deletions
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 5cc4c1e7ddf..ad01e0f2886 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi | |||
| @@ -3390,7 +3390,8 @@ first, before handlers for jobs such as remote file access. | |||
| 3390 | @code{file-readable-p}, @code{file-regular-p}, | 3390 | @code{file-readable-p}, @code{file-regular-p}, |
| 3391 | @code{file-remote-p}, @code{file-selinux-context}, | 3391 | @code{file-remote-p}, @code{file-selinux-context}, |
| 3392 | @code{file-symlink-p}, @code{file-system-info}, | 3392 | @code{file-symlink-p}, @code{file-system-info}, |
| 3393 | @code{file-truename}, @code{file-writable-p}, | 3393 | @code{file-truename}, @code{file-user-uid}, |
| 3394 | @code{file-writable-p}, | ||
| 3394 | @code{find-backup-file-name},@* | 3395 | @code{find-backup-file-name},@* |
| 3395 | @code{get-file-buffer}, | 3396 | @code{get-file-buffer}, |
| 3396 | @code{insert-directory}, | 3397 | @code{insert-directory}, |
| @@ -3451,7 +3452,8 @@ first, before handlers for jobs such as remote file access. | |||
| 3451 | @code{file-readable-p}, @code{file-regular-p}, | 3452 | @code{file-readable-p}, @code{file-regular-p}, |
| 3452 | @code{file-remote-p}, @code{file-selinux-context}, | 3453 | @code{file-remote-p}, @code{file-selinux-context}, |
| 3453 | @code{file-symlink-p}, @code{file-system-info}, | 3454 | @code{file-symlink-p}, @code{file-system-info}, |
| 3454 | @code{file-truename}, @code{file-writable-p}, | 3455 | @code{file-truename}, @code{file-user-uid}, |
| 3456 | @code{file-writable-p}, | ||
| 3455 | @code{find-backup-file-name}, | 3457 | @code{find-backup-file-name}, |
| 3456 | @code{get-file-buffer}, | 3458 | @code{get-file-buffer}, |
| 3457 | @code{insert-directory}, | 3459 | @code{insert-directory}, |
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 3be7036f637..bca62a7a8de 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi | |||
| @@ -1277,6 +1277,16 @@ This function returns the real @acronym{UID} of the user. | |||
| 1277 | This function returns the effective @acronym{UID} of the user. | 1277 | This function returns the effective @acronym{UID} of the user. |
| 1278 | @end defun | 1278 | @end defun |
| 1279 | 1279 | ||
| 1280 | @defun file-user-uid | ||
| 1281 | This function returns the connection-local value for the user's | ||
| 1282 | effective @acronym{UID}. If @code{default-directory} is local, this | ||
| 1283 | is equivalent to @code{user-uid}, but for remote files (@pxref{Remote | ||
| 1284 | Files, , , emacs, The GNU Emacs Manual}), it will return the | ||
| 1285 | @acronym{UID} for the user associated with that remote connection; if | ||
| 1286 | the remote connection has no associated user, it will instead return | ||
| 1287 | -1. | ||
| 1288 | @end defun | ||
| 1289 | |||
| 1280 | @cindex GID | 1290 | @cindex GID |
| 1281 | @defun group-gid | 1291 | @defun group-gid |
| 1282 | This function returns the effective @acronym{GID} of the Emacs process. | 1292 | This function returns the effective @acronym{GID} of the Emacs process. |
diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi index fc7d52eb711..c40ff58f42c 100644 --- a/doc/misc/eshell.texi +++ b/doc/misc/eshell.texi | |||
| @@ -983,6 +983,13 @@ whenever you change the current directory to a different host | |||
| 983 | the value will automatically update to reflect the search path on that | 983 | the value will automatically update to reflect the search path on that |
| 984 | host. | 984 | host. |
| 985 | 985 | ||
| 986 | @vindex $UID | ||
| 987 | @item $UID | ||
| 988 | This returns the effective @acronym{UID} for the current user. This | ||
| 989 | variable is connection-aware, so when the current directory is remote, | ||
| 990 | its value will be @acronym{UID} for the user associated with that | ||
| 991 | remote connection. | ||
| 992 | |||
| 986 | @vindex $_ | 993 | @vindex $_ |
| 987 | @item $_ | 994 | @item $_ |
| 988 | This refers to the last argument of the last command. With a | 995 | This refers to the last argument of the last command. With a |
| @@ -1014,6 +1021,7 @@ that are currently visible in the Eshell window. They are both | |||
| 1014 | copied to the environment, so external commands invoked from | 1021 | copied to the environment, so external commands invoked from |
| 1015 | Eshell can consult them to do the right thing. | 1022 | Eshell can consult them to do the right thing. |
| 1016 | 1023 | ||
| 1024 | @vindex $INSIDE_EMACS | ||
| 1017 | @item $INSIDE_EMACS | 1025 | @item $INSIDE_EMACS |
| 1018 | This variable indicates to external commands that they are being | 1026 | This variable indicates to external commands that they are being |
| 1019 | invoked from within Emacs so they can adjust their behavior if | 1027 | invoked from within Emacs so they can adjust their behavior if |
| @@ -235,6 +235,12 @@ compared reliably at all. | |||
| 235 | This warning can be suppressed using 'with-suppressed-warnings' with | 235 | This warning can be suppressed using 'with-suppressed-warnings' with |
| 236 | the warning name 'suspicious'. | 236 | the warning name 'suspicious'. |
| 237 | 237 | ||
| 238 | +++ | ||
| 239 | ** New function 'file-user-uid'. | ||
| 240 | This function is like 'user-uid', but is aware of file name handlers, | ||
| 241 | so it will return the remote UID for remote files (or -1 if the | ||
| 242 | connection has no associated user). | ||
| 243 | |||
| 238 | 244 | ||
| 239 | * Changes in Emacs 30.1 on Non-Free Operating Systems | 245 | * Changes in Emacs 30.1 on Non-Free Operating Systems |
| 240 | 246 | ||
diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index 52d46282c52..b3a0fadf618 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el | |||
| @@ -52,7 +52,7 @@ as is common with most shells." | |||
| 52 | (defcustom eshell-prompt-function | 52 | (defcustom eshell-prompt-function |
| 53 | (lambda () | 53 | (lambda () |
| 54 | (concat (abbreviate-file-name (eshell/pwd)) | 54 | (concat (abbreviate-file-name (eshell/pwd)) |
| 55 | (if (= (user-uid) 0) " # " " $ "))) | 55 | (if (= (file-user-uid) 0) " # " " $ "))) |
| 56 | "A function that returns the Eshell prompt string. | 56 | "A function that returns the Eshell prompt string. |
| 57 | Make sure to update `eshell-prompt-regexp' so that it will match your | 57 | Make sure to update `eshell-prompt-regexp' so that it will match your |
| 58 | prompt." | 58 | prompt." |
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index 811bb9957cf..fd76a2c6f09 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el | |||
| @@ -162,6 +162,7 @@ if they are quoted with a backslash." | |||
| 162 | ("COLUMNS" ,(lambda () (window-body-width nil 'remap)) t t) | 162 | ("COLUMNS" ,(lambda () (window-body-width nil 'remap)) t t) |
| 163 | ("LINES" ,(lambda () (window-body-height nil 'remap)) t t) | 163 | ("LINES" ,(lambda () (window-body-height nil 'remap)) t t) |
| 164 | ("INSIDE_EMACS" eshell-inside-emacs t) | 164 | ("INSIDE_EMACS" eshell-inside-emacs t) |
| 165 | ("UID" ,(lambda () (file-user-uid)) nil t) | ||
| 165 | 166 | ||
| 166 | ;; for esh-ext.el | 167 | ;; for esh-ext.el |
| 167 | ("PATH" (,(lambda () (string-join (eshell-get-path t) (path-separator))) | 168 | ("PATH" (,(lambda () (string-join (eshell-get-path t) (path-separator))) |
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 29b9f894ec3..10f33e5f929 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -153,6 +153,7 @@ It is used for TCP/IP devices." | |||
| 153 | (file-symlink-p . tramp-handle-file-symlink-p) | 153 | (file-symlink-p . tramp-handle-file-symlink-p) |
| 154 | (file-system-info . tramp-adb-handle-file-system-info) | 154 | (file-system-info . tramp-adb-handle-file-system-info) |
| 155 | (file-truename . tramp-handle-file-truename) | 155 | (file-truename . tramp-handle-file-truename) |
| 156 | (file-user-uid . tramp-handle-file-user-uid) | ||
| 156 | (file-writable-p . tramp-adb-handle-file-writable-p) | 157 | (file-writable-p . tramp-adb-handle-file-writable-p) |
| 157 | (find-backup-file-name . tramp-handle-find-backup-file-name) | 158 | (find-backup-file-name . tramp-handle-find-backup-file-name) |
| 158 | ;; `get-file-buffer' performed by default handler. | 159 | ;; `get-file-buffer' performed by default handler. |
diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el index 3b1d568c127..b9cf85bd843 100644 --- a/lisp/net/tramp-archive.el +++ b/lisp/net/tramp-archive.el | |||
| @@ -265,6 +265,7 @@ It must be supported by libarchive(3).") | |||
| 265 | (file-symlink-p . tramp-handle-file-symlink-p) | 265 | (file-symlink-p . tramp-handle-file-symlink-p) |
| 266 | (file-system-info . tramp-archive-handle-file-system-info) | 266 | (file-system-info . tramp-archive-handle-file-system-info) |
| 267 | (file-truename . tramp-archive-handle-file-truename) | 267 | (file-truename . tramp-archive-handle-file-truename) |
| 268 | (file-user-uid . tramp-archive-handle-file-user-uid) | ||
| 268 | (file-writable-p . ignore) | 269 | (file-writable-p . ignore) |
| 269 | (find-backup-file-name . ignore) | 270 | (find-backup-file-name . ignore) |
| 270 | ;; `get-file-buffer' performed by default handler. | 271 | ;; `get-file-buffer' performed by default handler. |
| @@ -701,6 +702,12 @@ offered." | |||
| 701 | (let ((default-directory (file-name-directory archive))) | 702 | (let ((default-directory (file-name-directory archive))) |
| 702 | (temporary-file-directory)))) | 703 | (temporary-file-directory)))) |
| 703 | 704 | ||
| 705 | (defun tramp-archive-handle-file-user-uid () | ||
| 706 | "Like `user-uid' for file archives." | ||
| 707 | (with-parsed-tramp-archive-file-name default-directory nil | ||
| 708 | (let ((default-directory (file-name-directory archive))) | ||
| 709 | (file-user-uid)))) | ||
| 710 | |||
| 704 | (defun tramp-archive-handle-not-implemented (operation &rest args) | 711 | (defun tramp-archive-handle-not-implemented (operation &rest args) |
| 705 | "Generic handler for operations not implemented for file archives." | 712 | "Generic handler for operations not implemented for file archives." |
| 706 | (let ((v (ignore-errors | 713 | (let ((v (ignore-errors |
diff --git a/lisp/net/tramp-crypt.el b/lisp/net/tramp-crypt.el index 507fd432419..b9d0d96eccc 100644 --- a/lisp/net/tramp-crypt.el +++ b/lisp/net/tramp-crypt.el | |||
| @@ -204,6 +204,7 @@ If NAME doesn't belong to an encrypted remote directory, return nil." | |||
| 204 | (file-symlink-p . tramp-handle-file-symlink-p) | 204 | (file-symlink-p . tramp-handle-file-symlink-p) |
| 205 | (file-system-info . tramp-crypt-handle-file-system-info) | 205 | (file-system-info . tramp-crypt-handle-file-system-info) |
| 206 | ;; `file-truename' performed by default handler. | 206 | ;; `file-truename' performed by default handler. |
| 207 | (file-user-uid . tramp-handle-file-user-uid) | ||
| 207 | (file-writable-p . tramp-crypt-handle-file-writable-p) | 208 | (file-writable-p . tramp-crypt-handle-file-writable-p) |
| 208 | (find-backup-file-name . tramp-handle-find-backup-file-name) | 209 | (find-backup-file-name . tramp-handle-find-backup-file-name) |
| 209 | ;; `get-file-buffer' performed by default handler. | 210 | ;; `get-file-buffer' performed by default handler. |
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index ea774d0b9b7..02ceb2979f7 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el | |||
| @@ -798,6 +798,7 @@ It has been changed in GVFS 1.14.") | |||
| 798 | (file-symlink-p . tramp-handle-file-symlink-p) | 798 | (file-symlink-p . tramp-handle-file-symlink-p) |
| 799 | (file-system-info . tramp-gvfs-handle-file-system-info) | 799 | (file-system-info . tramp-gvfs-handle-file-system-info) |
| 800 | (file-truename . tramp-handle-file-truename) | 800 | (file-truename . tramp-handle-file-truename) |
| 801 | (file-user-uid . tramp-handle-file-user-uid) | ||
| 801 | (file-writable-p . tramp-handle-file-writable-p) | 802 | (file-writable-p . tramp-handle-file-writable-p) |
| 802 | (find-backup-file-name . tramp-handle-find-backup-file-name) | 803 | (find-backup-file-name . tramp-handle-find-backup-file-name) |
| 803 | ;; `get-file-buffer' performed by default handler. | 804 | ;; `get-file-buffer' performed by default handler. |
diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el index b28f9f64952..9eb2a54cdcf 100644 --- a/lisp/net/tramp-rclone.el +++ b/lisp/net/tramp-rclone.el | |||
| @@ -118,6 +118,7 @@ | |||
| 118 | (file-symlink-p . tramp-handle-file-symlink-p) | 118 | (file-symlink-p . tramp-handle-file-symlink-p) |
| 119 | (file-system-info . tramp-rclone-handle-file-system-info) | 119 | (file-system-info . tramp-rclone-handle-file-system-info) |
| 120 | (file-truename . tramp-handle-file-truename) | 120 | (file-truename . tramp-handle-file-truename) |
| 121 | (file-user-uid . tramp-handle-file-user-uid) | ||
| 121 | (file-writable-p . tramp-handle-file-writable-p) | 122 | (file-writable-p . tramp-handle-file-writable-p) |
| 122 | (find-backup-file-name . tramp-handle-find-backup-file-name) | 123 | (find-backup-file-name . tramp-handle-find-backup-file-name) |
| 123 | ;; `get-file-buffer' performed by default handler. | 124 | ;; `get-file-buffer' performed by default handler. |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index acbb6aea135..46b1f612101 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -1086,6 +1086,7 @@ Format specifiers \"%s\" are replaced before the script is used.") | |||
| 1086 | (file-symlink-p . tramp-handle-file-symlink-p) | 1086 | (file-symlink-p . tramp-handle-file-symlink-p) |
| 1087 | (file-system-info . tramp-sh-handle-file-system-info) | 1087 | (file-system-info . tramp-sh-handle-file-system-info) |
| 1088 | (file-truename . tramp-sh-handle-file-truename) | 1088 | (file-truename . tramp-sh-handle-file-truename) |
| 1089 | (file-user-uid . tramp-handle-file-user-uid) | ||
| 1089 | (file-writable-p . tramp-sh-handle-file-writable-p) | 1090 | (file-writable-p . tramp-sh-handle-file-writable-p) |
| 1090 | (find-backup-file-name . tramp-handle-find-backup-file-name) | 1091 | (find-backup-file-name . tramp-handle-find-backup-file-name) |
| 1091 | ;; `get-file-buffer' performed by default handler. | 1092 | ;; `get-file-buffer' performed by default handler. |
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index b3f0344f818..9d03490f1d5 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el | |||
| @@ -269,6 +269,7 @@ See `tramp-actions-before-shell' for more info.") | |||
| 269 | (file-symlink-p . tramp-handle-file-symlink-p) | 269 | (file-symlink-p . tramp-handle-file-symlink-p) |
| 270 | (file-system-info . tramp-smb-handle-file-system-info) | 270 | (file-system-info . tramp-smb-handle-file-system-info) |
| 271 | (file-truename . tramp-handle-file-truename) | 271 | (file-truename . tramp-handle-file-truename) |
| 272 | (file-user-uid . tramp-handle-file-user-uid) | ||
| 272 | (file-writable-p . tramp-smb-handle-file-writable-p) | 273 | (file-writable-p . tramp-smb-handle-file-writable-p) |
| 273 | (find-backup-file-name . tramp-handle-find-backup-file-name) | 274 | (find-backup-file-name . tramp-handle-find-backup-file-name) |
| 274 | ;; `get-file-buffer' performed by default handler. | 275 | ;; `get-file-buffer' performed by default handler. |
diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el index 27b2854e451..65c4bf23c38 100644 --- a/lisp/net/tramp-sshfs.el +++ b/lisp/net/tramp-sshfs.el | |||
| @@ -124,6 +124,7 @@ | |||
| 124 | (file-symlink-p . tramp-handle-file-symlink-p) | 124 | (file-symlink-p . tramp-handle-file-symlink-p) |
| 125 | (file-system-info . tramp-sshfs-handle-file-system-info) | 125 | (file-system-info . tramp-sshfs-handle-file-system-info) |
| 126 | (file-truename . tramp-handle-file-truename) | 126 | (file-truename . tramp-handle-file-truename) |
| 127 | (file-user-uid . tramp-handle-file-user-uid) | ||
| 127 | (file-writable-p . tramp-sshfs-handle-file-writable-p) | 128 | (file-writable-p . tramp-sshfs-handle-file-writable-p) |
| 128 | (find-backup-file-name . tramp-handle-find-backup-file-name) | 129 | (find-backup-file-name . tramp-handle-find-backup-file-name) |
| 129 | ;; `get-file-buffer' performed by default handler. | 130 | ;; `get-file-buffer' performed by default handler. |
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index ce080918e0f..db7ac842871 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el | |||
| @@ -114,6 +114,7 @@ See `tramp-actions-before-shell' for more info.") | |||
| 114 | (file-symlink-p . tramp-handle-file-symlink-p) | 114 | (file-symlink-p . tramp-handle-file-symlink-p) |
| 115 | (file-system-info . tramp-sudoedit-handle-file-system-info) | 115 | (file-system-info . tramp-sudoedit-handle-file-system-info) |
| 116 | (file-truename . tramp-sudoedit-handle-file-truename) | 116 | (file-truename . tramp-sudoedit-handle-file-truename) |
| 117 | (file-user-uid . tramp-handle-file-user-uid) | ||
| 117 | (file-writable-p . tramp-sudoedit-handle-file-writable-p) | 118 | (file-writable-p . tramp-sudoedit-handle-file-writable-p) |
| 118 | (find-backup-file-name . tramp-handle-find-backup-file-name) | 119 | (find-backup-file-name . tramp-handle-find-backup-file-name) |
| 119 | ;; `get-file-buffer' performed by default handler. | 120 | ;; `get-file-buffer' performed by default handler. |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 169cf1982b4..fab1962d2b7 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -2632,7 +2632,9 @@ Must be handled by the callers." | |||
| 2632 | '(exec-path make-nearby-temp-file make-process process-file | 2632 | '(exec-path make-nearby-temp-file make-process process-file |
| 2633 | shell-command start-file-process temporary-file-directory | 2633 | shell-command start-file-process temporary-file-directory |
| 2634 | ;; Emacs 29+ only. | 2634 | ;; Emacs 29+ only. |
| 2635 | list-system-processes memory-info process-attributes)) | 2635 | list-system-processes memory-info process-attributes |
| 2636 | ;; Emacs 30+ only. | ||
| 2637 | file-user-uid)) | ||
| 2636 | default-directory) | 2638 | default-directory) |
| 2637 | ;; PROC. | 2639 | ;; PROC. |
| 2638 | ((member operation '(file-notify-rm-watch file-notify-valid-p)) | 2640 | ((member operation '(file-notify-rm-watch file-notify-valid-p)) |
| @@ -3714,6 +3716,15 @@ Let-bind it when necessary.") | |||
| 3714 | vec (concat "~" (substring filename (match-beginning 1)))) | 3716 | vec (concat "~" (substring filename (match-beginning 1)))) |
| 3715 | (tramp-make-tramp-file-name (tramp-dissect-file-name filename))))) | 3717 | (tramp-make-tramp-file-name (tramp-dissect-file-name filename))))) |
| 3716 | 3718 | ||
| 3719 | (defun tramp-handle-file-user-uid () | ||
| 3720 | "Like `user-uid' for Tramp files." | ||
| 3721 | (let ((v (tramp-dissect-file-name default-directory))) | ||
| 3722 | (or (tramp-get-remote-uid v 'integer) | ||
| 3723 | ;; Some handlers for `tramp-get-remote-uid' return nil if they | ||
| 3724 | ;; can't get the UID; always return -1 in this case for | ||
| 3725 | ;; consistency. | ||
| 3726 | -1))) | ||
| 3727 | |||
| 3717 | (defun tramp-handle-access-file (filename string) | 3728 | (defun tramp-handle-access-file (filename string) |
| 3718 | "Like `access-file' for Tramp files." | 3729 | "Like `access-file' for Tramp files." |
| 3719 | (setq filename (file-truename filename)) | 3730 | (setq filename (file-truename filename)) |
diff --git a/lisp/simple.el b/lisp/simple.el index 4b09f41de55..844cfa68b08 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -4730,6 +4730,18 @@ Also see the `async-shell-command-buffer' variable." | |||
| 4730 | action)) | 4730 | action)) |
| 4731 | (user-error "Shell command in progress")))) | 4731 | (user-error "Shell command in progress")))) |
| 4732 | 4732 | ||
| 4733 | (defun file-user-uid () | ||
| 4734 | "Return the connection-local effective uid. | ||
| 4735 | This is similar to `user-uid', but may invoke a file name handler | ||
| 4736 | based on `default-directory'. See Info node `(elisp)Magic File | ||
| 4737 | Names'. | ||
| 4738 | |||
| 4739 | If a file name handler is unable to retrieve the effective uid, | ||
| 4740 | this function will instead return -1." | ||
| 4741 | (if-let ((handler (find-file-name-handler default-directory 'file-user-uid))) | ||
| 4742 | (funcall handler 'file-user-uid) | ||
| 4743 | (user-uid))) | ||
| 4744 | |||
| 4733 | (defun max-mini-window-lines (&optional frame) | 4745 | (defun max-mini-window-lines (&optional frame) |
| 4734 | "Compute maximum number of lines for echo area in FRAME. | 4746 | "Compute maximum number of lines for echo area in FRAME. |
| 4735 | As defined by `max-mini-window-height'. FRAME defaults to the | 4747 | As defined by `max-mini-window-height'. FRAME defaults to the |
diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el index 3f602798dbe..0cc1b92266f 100644 --- a/test/lisp/eshell/esh-var-tests.el +++ b/test/lisp/eshell/esh-var-tests.el | |||
| @@ -746,6 +746,10 @@ it, since the setter is nil." | |||
| 746 | (format "cd %s" ert-remote-temporary-file-directory)) | 746 | (format "cd %s" ert-remote-temporary-file-directory)) |
| 747 | (eshell-match-command-output "echo $PATH" (regexp-quote remote-path))))) | 747 | (eshell-match-command-output "echo $PATH" (regexp-quote remote-path))))) |
| 748 | 748 | ||
| 749 | (ert-deftest esh-var-test/uid-var () | ||
| 750 | "Test that $UID is equivalent to (user-uid) for local directories." | ||
| 751 | (eshell-command-result-equal "echo $UID" (user-uid))) | ||
| 752 | |||
| 749 | (ert-deftest esh-var-test/last-status-var-lisp-command () | 753 | (ert-deftest esh-var-test/last-status-var-lisp-command () |
| 750 | "Test using the \"last exit status\" ($?) variable with a Lisp command" | 754 | "Test using the \"last exit status\" ($?) variable with a Lisp command" |
| 751 | (with-temp-eshell | 755 | (with-temp-eshell |