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 /doc | |
| 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'.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/files.texi | 6 | ||||
| -rw-r--r-- | doc/lispref/os.texi | 10 | ||||
| -rw-r--r-- | doc/misc/eshell.texi | 8 |
3 files changed, 22 insertions, 2 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 |