diff options
| author | Michael Albinus | 2025-10-15 10:30:29 +0200 |
|---|---|---|
| committer | Michael Albinus | 2025-10-15 10:30:29 +0200 |
| commit | 53fa2b72183e110cc6da3ce172c48e40d3fea3c7 (patch) | |
| tree | 7168f7b85363aca07ef77b917a160d9f2637a2e4 /lisp | |
| parent | 7845936cbbf8c56a4d57700fbd10246b7288aa01 (diff) | |
| download | emacs-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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/comint.el | 3 | ||||
| -rw-r--r-- | lisp/net/tramp-cmds.el | 6 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 41 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 21 |
4 files changed, 56 insertions, 15 deletions
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: | |||
| 418 | All these arguments can be overwritten by connection properties. | 418 | All these arguments can be overwritten by connection properties. |
| 419 | See Info node `(tramp) Predefined connection information'. | 419 | See Info node `(tramp) Predefined connection information'. |
| 420 | 420 | ||
| 421 | When using `su', `sudo' or `doas' the phrase \"open connection to | 421 | When using `su', `surs', `sg', `sudo', `sudors', `doas', `run0' or `ksu' |
| 422 | a remote host\" sounds strange, but it is used nevertheless, for | 422 | the phrase \"open connection to a remote host\" sounds strange, but it |
| 423 | consistency. No connection is opened to a remote host, but `su', | 423 | is used nevertheless, for consistency. No connection is opened to a |
| 424 | `sudo' or `doas' is started on the local host. You should | 424 | remote host, but the respective command is started on the local host. |
| 425 | specify a remote host `localhost' or the name of the local host. | 425 | You should specify a remote host `localhost' or the name of the local |
| 426 | Another host name is useful only in combination with | 426 | host. 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)) |