aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2025-10-15 10:30:29 +0200
committerMichael Albinus2025-10-15 10:30:29 +0200
commit53fa2b72183e110cc6da3ce172c48e40d3fea3c7 (patch)
tree7168f7b85363aca07ef77b917a160d9f2637a2e4
parent7845936cbbf8c56a4d57700fbd10246b7288aa01 (diff)
downloademacs-53fa2b72183e110cc6da3ce172c48e40d3fea3c7.tar.gz
emacs-53fa2b72183e110cc6da3ce172c48e40d3fea3c7.zip
Add support for su-rs and sudo-rs programs
* doc/misc/tramp.texi (Inline methods): Add "surs" and "sudors" methods. * etc/NEWS: Add optional "surs" and "sudors" Tramp methods. Presentational fixes and improvements. * lisp/net/tramp-cmds.el (tramp-file-name-with-method): Add "surs" and "sudors" to :type. Adapt :version. * lisp/net/tramp-sh.el (tramp-enable-surs-method) (tramp-enable-sudors-method): New defuns (tramp-sh-handle-expand-file-name): Add "surs" and "sudors" in check. * lisp/net/tramp.el (tramp-methods): Adapt docstring. * lisp/comint.el (comint-password-prompt-regexp): * test/lisp/comint-tests.el (comint-testsuite-password-strings): Add su-rs and sudo-rs password prompts.
-rw-r--r--doc/misc/tramp.texi16
-rw-r--r--etc/NEWS17
-rw-r--r--lisp/comint.el3
-rw-r--r--lisp/net/tramp-cmds.el6
-rw-r--r--lisp/net/tramp-sh.el41
-rw-r--r--lisp/net/tramp.el21
-rw-r--r--test/lisp/comint-tests.el2
7 files changed, 85 insertions, 21 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 5ce41091048..7b3a4808a45 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -852,12 +852,20 @@ as the @option{rsh} method.
852@cindex method @option{su} 852@cindex method @option{su}
853@cindex @option{su} method 853@cindex @option{su} method
854@item @option{su} 854@item @option{su}
855@cindex method @option{surs}
856@cindex @option{surs} method
857@item @option{surs}
855 858
856Instead of connecting to a remote host, @command{su} program allows 859Instead of connecting to a remote host, @command{su} program allows
857editing as another user. The host can be either @samp{localhost} or 860editing as another user. The host can be either @samp{localhost} or
858the host returned by the function @command{(system-name)}. 861the host returned by the function @command{(system-name)}.
859@xref{Multi-hops}, for an exception to this behavior. 862@xref{Multi-hops}, for an exception to this behavior.
860 863
864Method @option{surs} is the same like method @option{su}, but it uses
865the modern @command{su-rs} program. It can be used instead wherever
866method @option{su} is mentioned in this manual. @option{surs} is an
867optional method, @pxref{Optional methods}.
868
861@cindex method @option{androidsu} 869@cindex method @option{androidsu}
862@cindex @option{androidsu} method 870@cindex @option{androidsu} method
863@item @option{androidsu} 871@item @option{androidsu}
@@ -876,6 +884,9 @@ default on @code{android} systems only.
876@cindex method @option{sudo} 884@cindex method @option{sudo}
877@cindex @option{sudo} method 885@cindex @option{sudo} method
878@item @option{sudo} 886@item @option{sudo}
887@cindex method @option{sudors}
888@cindex @option{sudors} method
889@item @option{sudors}
879 890
880Similar to @option{su} method, @option{sudo} uses @command{sudo}. 891Similar to @option{su} method, @option{sudo} uses @command{sudo}.
881@command{sudo} must have sufficient rights to start a shell. 892@command{sudo} must have sufficient rights to start a shell.
@@ -884,6 +895,11 @@ For security reasons, a @option{sudo} connection is disabled after a
884predefined timeout (5 minutes by default). This can be changed, 895predefined timeout (5 minutes by default). This can be changed,
885@pxref{Predefined connection information}. 896@pxref{Predefined connection information}.
886 897
898Method @option{sudors} is the same like method @option{sudo}, but it
899uses the modern @command{sudo-rs} program. It can be used instead
900wherever method @option{sudo} is mentioned in this manual.
901@option{sudors} is an optional method, @pxref{Optional methods}.
902
887@cindex method @option{doas} 903@cindex method @option{doas}
888@cindex @option{doas} method 904@cindex @option{doas} method
889@item @option{doas} 905@item @option{doas}
diff --git a/etc/NEWS b/etc/NEWS
index 4e27d6fc44e..0b8d624d923 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -327,13 +327,13 @@ deleted implicitly by functions like 'kill-buffer', 'bury-buffer' and
327+++ 327+++
328*** Buffer-local window change functions run in their buffers now. 328*** Buffer-local window change functions run in their buffers now.
329Running the buffer-local version of each of the abnormal hooks 329Running the buffer-local version of each of the abnormal hooks
330'window-buffer-change-functions', 'window-size-change-functions' 330'window-buffer-change-functions', 'window-size-change-functions',
331'window-selection-change-functions' and 'window-state-change-functions' 331'window-selection-change-functions' and 'window-state-change-functions'
332will make the respective buffer temporarily current for running the 332will make the respective buffer temporarily current for running the
333hook.' 333hook.
334 334
335+++ 335+++
336*** 'window-buffer-change-functions' is run for removed buffer too. 336*** 'window-buffer-change-functions' is run for removed buffers too.
337The buffer-local version of 'window-buffer-change-functions' may be run 337The buffer-local version of 'window-buffer-change-functions' may be run
338twice now: Once for the buffer removed from the respective window and 338twice now: Once for the buffer removed from the respective window and
339once for the buffer now shown in that window. 339once for the buffer now shown in that window.
@@ -1883,6 +1883,11 @@ default, "sudo".
1883*** 'tramp-file-name-with-method' can now be set as connection-local variable. 1883*** 'tramp-file-name-with-method' can now be set as connection-local variable.
1884 1884
1885+++ 1885+++
1886*** New optional connection methods "surs" and "sudors".
1887These connection methods are similar to "su" and "sudo", but they use
1888the modern 'su-rs' and 'sudo-rs' commands.
1889
1890+++
1886*** Connection method "kubernetes" supports now optional namespace. 1891*** Connection method "kubernetes" supports now optional namespace.
1887The host name for Kubernetes connections can be of kind 1892The host name for Kubernetes connections can be of kind
1888[CONTAINER.]POD[%NAMESPACE], in order to specify the namespace to be 1893[CONTAINER.]POD[%NAMESPACE], in order to specify the namespace to be
@@ -3320,10 +3325,10 @@ The column number is no longer available; the line number will be
3320removed in next Emacs release. 3325removed in next Emacs release.
3321 3326
3322+++ 3327+++
3323** defvar-keymap can now take a ':prefix t' option. 3328** 'defvar-keymap' can now take a ':prefix t' option.
3324This is an abbreviation for using the name of the keymap as the prefix 3329This is an abbreviation for using the name of the keymap as the prefix
3325command name. E.g. (defvar-keymap foo-map :prefix t) is equivalent to 3330command name. E.g., '(defvar-keymap foo-map :prefix t)' is equivalent
3326(defvar-keymap foo-map :prefix 'foo-map). 3331to '(defvar-keymap foo-map :prefix 'foo-map)'.
3327 3332
3328 3333
3329* Changes in Emacs 31.1 on Non-Free Operating Systems 3334* Changes in Emacs 31.1 on Non-Free Operating Systems
diff --git a/lisp/comint.el b/lisp/comint.el
index c7315a90181..b7c609ed469 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -408,7 +408,8 @@ This variable is buffer-local."
408 "Vault" "SSH" "BECOME" 408 "Vault" "SSH" "BECOME"
409 "Enter Auth" "enter auth" "Old" "old" "New" "new" "login" 409 "Enter Auth" "enter auth" "Old" "old" "New" "new" "login"
410 "Kerberos" "CVS" "UNIX" " SMB" "LDAP" "PEM" "SUDO" 410 "Kerberos" "CVS" "UNIX" " SMB" "LDAP" "PEM" "SUDO"
411 "[sudo]" "doas" "Repeat" "Bad" "Retype" "Verify") 411 "[sudo]" "[sudo: authenticate]" "[su: authenticate]"
412 "doas" "Repeat" "Bad" "Retype" "Verify")
412 t) 413 t)
413 ;; Allow for user name to precede password equivalent (Bug#31075). 414 ;; Allow for user name to precede password equivalent (Bug#31075).
414 " +.*\\)" 415 " +.*\\)"
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index 6042209d4f0..a4f74383325 100644
--- a/lisp/net/tramp-cmds.el
+++ b/lisp/net/tramp-cmds.el
@@ -631,9 +631,9 @@ For details, see `tramp-rename-files'."
631(defcustom tramp-file-name-with-method "sudo" 631(defcustom tramp-file-name-with-method "sudo"
632 "Which method to be used in `tramp-file-name-with-sudo'." 632 "Which method to be used in `tramp-file-name-with-sudo'."
633 :group 'tramp 633 :group 'tramp
634 :version "30.1" 634 :version "31.1"
635 :type '(choice (const "su") 635 :type '(choice (const "su") (const "surs")
636 (const "sudo") 636 (const "sudo") (const "sudors")
637 (const "doas") 637 (const "doas")
638 (const "run0") 638 (const "run0")
639 (const "ksu")) 639 (const "ksu"))
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 8922adb7586..98e3cae5a79 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -522,6 +522,42 @@ The string is used in `tramp-methods'.")
522 (tramp-set-completion-function "nc" tramp-completion-function-alist-telnet)) 522 (tramp-set-completion-function "nc" tramp-completion-function-alist-telnet))
523 523
524;;;###tramp-autoload 524;;;###tramp-autoload
525(defun tramp-enable-surs-method ()
526 "Enable \"surs\" method."
527 (add-to-list 'tramp-methods
528 `("surs"
529 (tramp-login-program "su-rs")
530 (tramp-login-args (("-") ("%u")))
531 (tramp-remote-shell ,tramp-default-remote-shell)
532 (tramp-remote-shell-login ("-l"))
533 (tramp-remote-shell-args ("-c"))
534 (tramp-connection-timeout 10)))
535
536 (add-to-list 'tramp-default-user-alist
537 `(,(rx bos "surs" eos) nil ,tramp-root-id-string))
538
539 (tramp-set-completion-function "surs" tramp-completion-function-alist-su))
540
541;;;###tramp-autoload
542(defun tramp-enable-sudors-method ()
543 "Enable \"sudors\" method."
544 (add-to-list 'tramp-methods
545 `("sudors"
546 (tramp-login-program "sudo-rs")
547 (tramp-login-args (("-u" "%u") ("-s") ("%l")))
548 (tramp-remote-shell ,tramp-default-remote-shell)
549 (tramp-remote-shell-login ("-l"))
550 (tramp-remote-shell-args ("-c"))
551 (tramp-connection-timeout 10)
552 (tramp-session-timeout 300)
553 (tramp-password-previous-hop t)))
554
555 (add-to-list 'tramp-default-user-alist
556 `(,(rx bos "sudors" eos) nil ,tramp-root-id-string))
557
558 (tramp-set-completion-function "sudors" tramp-completion-function-alist-su))
559
560;;;###tramp-autoload
525(defun tramp-enable-run0-method () 561(defun tramp-enable-run0-method ()
526 "Enable \"run0\" method." 562 "Enable \"run0\" method."
527 (add-to-list 'tramp-methods 563 (add-to-list 'tramp-methods
@@ -2964,7 +3000,10 @@ the result will be a local, non-Tramp, file name."
2964 ;; use a user name from the config file. 3000 ;; use a user name from the config file.
2965 (when (and (tramp-string-empty-or-nil-p uname) 3001 (when (and (tramp-string-empty-or-nil-p uname)
2966 (string-match-p 3002 (string-match-p
2967 (rx bos (| "su" "sudo" "doas" "run0" "ksu") eos) method)) 3003 (rx bos
3004 (| "su" "surs" "sudo" "sudors" "doas" "run0" "ksu")
3005 eos)
3006 method))
2968 (setq uname user)) 3007 (setq uname user))
2969 (when (setq hname (tramp-get-home-directory v uname)) 3008 (when (setq hname (tramp-get-home-directory v uname))
2970 (setq localname (concat hname fname))))) 3009 (setq localname (concat hname fname)))))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 546ffa5d638..ec57aca0568 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -418,12 +418,12 @@ Notes:
418All these arguments can be overwritten by connection properties. 418All these arguments can be overwritten by connection properties.
419See Info node `(tramp) Predefined connection information'. 419See Info node `(tramp) Predefined connection information'.
420 420
421When using `su', `sudo' or `doas' the phrase \"open connection to 421When using `su', `surs', `sg', `sudo', `sudors', `doas', `run0' or `ksu'
422a remote host\" sounds strange, but it is used nevertheless, for 422the phrase \"open connection to a remote host\" sounds strange, but it
423consistency. No connection is opened to a remote host, but `su', 423is used nevertheless, for consistency. No connection is opened to a
424`sudo' or `doas' is started on the local host. You should 424remote host, but the respective command is started on the local host.
425specify a remote host `localhost' or the name of the local host. 425You should specify a remote host `localhost' or the name of the local
426Another host name is useful only in combination with 426host. Another host name is useful only in combination with
427`tramp-default-proxies-alist'.") 427`tramp-default-proxies-alist'.")
428 428
429(defcustom tramp-default-method 429(defcustom tramp-default-method
@@ -5239,10 +5239,11 @@ Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'.")
5239 vec "Method `%s' is not supported for multi-hops" 5239 vec "Method `%s' is not supported for multi-hops"
5240 (tramp-file-name-method item))))) 5240 (tramp-file-name-method item)))))
5241 5241
5242 ;; Some methods ("su", "sg", "sudo", "doas", "run0", "ksu") do 5242 ;; Some methods ("su", "surs", "sg", "sudo", "sudors", "doas",
5243 ;; not use the host name in their command template. In this 5243 ;; "run0", "ksu") do not use the host name in their command
5244 ;; case, the remote file name must use either a local host name 5244 ;; template. In this case, the remote file name must use either
5245 ;; (first hop), or a host name matching the previous hop. 5245 ;; a local host name (first hop), or a host name matching the
5246 ;; previous hop.
5246 (let ((previous-host (or tramp-local-host-regexp ""))) 5247 (let ((previous-host (or tramp-local-host-regexp "")))
5247 (setq choices target-alist) 5248 (setq choices target-alist)
5248 (while (setq item (pop choices)) 5249 (while (setq item (pop choices))
diff --git a/test/lisp/comint-tests.el b/test/lisp/comint-tests.el
index d981aad7198..0ae5daa70ca 100644
--- a/test/lisp/comint-tests.el
+++ b/test/lisp/comint-tests.el
@@ -38,6 +38,8 @@
38 "Enter your password: " ; python3 -m twine ... Bug#37636 38 "Enter your password: " ; python3 -m twine ... Bug#37636
39 "Passphrase for key root@GNU.ORG: " ; plink 39 "Passphrase for key root@GNU.ORG: " ; plink
40 "[sudo] password for user:" ; Ubuntu sudo 40 "[sudo] password for user:" ; Ubuntu sudo
41 "[sudo: authenticate] Password:" ; sudo-rs
42 "[su: authenticate] Password:" ; su-rs
41 "[sudo] user 的密码:" ; localized 43 "[sudo] user 的密码:" ; localized
42 "doas (user@host) password:" ; OpenBSD doas 44 "doas (user@host) password:" ; OpenBSD doas
43 "PIN for user:" ; Bug#35523 45 "PIN for user:" ; Bug#35523