aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2016-01-15 11:10:37 +0100
committerMichael Albinus2016-01-15 11:10:37 +0100
commita600f4c69309bf37f67c02cbcc9a9e4ba1e69c76 (patch)
treef09fffe5f206e9d2568243d799023cc636ae33ea
parentde8c5f9db50a22ef5640bb83c0c7c755b78be895 (diff)
downloademacs-a600f4c69309bf37f67c02cbcc9a9e4ba1e69c76.tar.gz
emacs-a600f4c69309bf37f67c02cbcc9a9e4ba1e69c76.zip
Add "sg" method to Tramp
* doc/misc/tramp.texi (Inline methods): Add "sg" method. (Customizing Completion): Add function `tramp-parse-etc-group'. * lisp/net/tramp-sh.el (tramp-methods) <sg>: Add. (Bug#22329) (tramp-completion-function-alist-sg): New defconst. (top): Completion function for "sg" is `tramp-completion-function-alist-sg'. * lisp/net/tramp.el (tramp-completion-function-alist): Adapt docstring. (tramp-parse-etc-group, tramp-parse-etc-group-group): New defuns.
-rw-r--r--doc/misc/tramp.texi26
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/net/tramp-sh.el19
-rw-r--r--lisp/net/tramp.el18
4 files changed, 56 insertions, 12 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 447498a3521..14afb4ad353 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -590,7 +590,6 @@ specifies the file size for such optimization.
590@command{rsh} is an option for connecting to hosts within local 590@command{rsh} is an option for connecting to hosts within local
591networks since @command{rsh} is not as secure as other methods. 591networks since @command{rsh} is not as secure as other methods.
592 592
593
594@item @option{ssh} 593@item @option{ssh}
595@cindex method ssh 594@cindex method ssh
596@cindex ssh method 595@cindex ssh method
@@ -610,7 +609,6 @@ host name, a hash sign, then a port number). It is the same as passing
610Connecting to a remote host with @command{telnet} is as insecure 609Connecting to a remote host with @command{telnet} is as insecure
611as the @option{rsh} method. 610as the @option{rsh} method.
612 611
613
614@item @option{su} 612@item @option{su}
615@cindex method su 613@cindex method su
616@cindex su method 614@cindex su method
@@ -627,6 +625,16 @@ the host returned by the function @command{(system-name)}. See
627Similar to @option{su} method, @option{sudo} uses @command{sudo}. 625Similar to @option{su} method, @option{sudo} uses @command{sudo}.
628@command{sudo} must have sufficient rights to start a shell. 626@command{sudo} must have sufficient rights to start a shell.
629 627
628@item @option{sg}
629@cindex method sg
630@cindex sg method
631
632The @command{sg} program allows editing as different group. The host
633can be either @samp{localhost} or the host returned by the function
634@command{(system-name)}. The user name must be specified, but it
635denotes a group name. See @ref{Multi-hops} for an exception to this
636behavior.
637
630@item @option{sshx} 638@item @option{sshx}
631@cindex method sshx 639@cindex method sshx
632@cindex sshx method 640@cindex sshx method
@@ -663,7 +671,6 @@ This method is also similar to @option{ssh}. It uses the
663 671
664This is another method from the Kerberos suite. It behaves like @option{su}. 672This is another method from the Kerberos suite. It behaves like @option{su}.
665 673
666
667@item @option{plink} 674@item @option{plink}
668@cindex method plink 675@cindex method plink
669@cindex plink method 676@cindex plink method
@@ -677,7 +684,6 @@ session.
677 684
678@option{plink} method supports the @samp{-P} argument. 685@option{plink} method supports the @samp{-P} argument.
679 686
680
681@item @option{plinkx} 687@item @option{plinkx}
682@cindex method plinkx 688@cindex method plinkx
683@cindex plinkx method 689@cindex plinkx method
@@ -754,7 +760,6 @@ is lost if the file exists only on one side of the connection.
754 760
755This method supports the @samp{-p} argument. 761This method supports the @samp{-p} argument.
756 762
757
758@item @option{scpx}---@command{ssh} and @command{scp} 763@item @option{scpx}---@command{ssh} and @command{scp}
759@cindex method scpx 764@cindex method scpx
760@cindex scpx method 765@cindex scpx method
@@ -771,7 +776,6 @@ shell prompts that confuses @value{tramp}.
771 776
772This method supports the @samp{-p} argument. 777This method supports the @samp{-p} argument.
773 778
774
775@item @option{pscp}---@command{plink} and @command{pscp} 779@item @option{pscp}---@command{plink} and @command{pscp}
776@item @option{psftp}---@command{plink} and @command{psftp} 780@item @option{psftp}---@command{plink} and @command{psftp}
777@cindex method pscp 781@cindex method pscp
@@ -795,7 +799,6 @@ session.
795 799
796These methods support the @samp{-P} argument. 800These methods support the @samp{-P} argument.
797 801
798
799@item @option{fcp}---@command{fsh} and @command{fcp} 802@item @option{fcp}---@command{fsh} and @command{fcp}
800@cindex method fcp 803@cindex method fcp
801@cindex fcp method 804@cindex fcp method
@@ -839,7 +842,6 @@ When @value{tramp} uses @option{ftp}, it forwards requests to whatever
839ftp program is specified by Ange FTP. This external program must be 842ftp program is specified by Ange FTP. This external program must be
840capable of servicing requests from @value{tramp}. 843capable of servicing requests from @value{tramp}.
841 844
842
843@item @option{smb}---@command{smbclient} 845@item @option{smb}---@command{smbclient}
844@cindex method smb 846@cindex method smb
845@cindex smb method 847@cindex smb method
@@ -911,7 +913,6 @@ access remote files using UNC file names instead of @value{tramp}:
911UNC file name specification does not allow to specify a different user 913UNC file name specification does not allow to specify a different user
912name for authentication like the @command{smbclient} can. 914name for authentication like the @command{smbclient} can.
913 915
914
915@item @option{adb} 916@item @option{adb}
916@cindex method adb 917@cindex method adb
917@cindex adb method 918@cindex adb method
@@ -993,7 +994,6 @@ but with SSL encryption. Both methods support the port numbers.
993OBEX is an FTP-like access protocol for cell phones and similar simple 994OBEX is an FTP-like access protocol for cell phones and similar simple
994devices. @value{tramp} supports OBEX over Bluetooth. 995devices. @value{tramp} supports OBEX over Bluetooth.
995 996
996
997@item @option{sftp} 997@item @option{sftp}
998@cindex method sftp 998@cindex method sftp
999@cindex sftp method 999@cindex sftp method
@@ -1054,7 +1054,6 @@ For authentication, this protocol uses only @option{Basic
1054Authentication} (see RFC 2617). When no port number is specified, this 1054Authentication} (see RFC 2617). When no port number is specified, this
1055protocol defaults to @option{8080}. 1055protocol defaults to @option{8080}.
1056 1056
1057
1058@item @option{socks} 1057@item @option{socks}
1059@cindex method socks 1058@cindex method socks
1060@cindex socks method 1059@cindex socks method
@@ -1478,6 +1477,11 @@ A function dedicated to @file{/etc/hosts} for host names.
1478 1477
1479A function which parses @file{/etc/passwd} files for user names. 1478A function which parses @file{/etc/passwd} files for user names.
1480 1479
1480@item @code{tramp-parse-etc-group}
1481@findex tramp-parse-etc-group
1482
1483A function which parses @file{/etc/group} files for group names.
1484
1481@item @code{tramp-parse-netrc} 1485@item @code{tramp-parse-netrc}
1482@findex tramp-parse-netrc 1486@findex tramp-parse-netrc
1483 1487
diff --git a/etc/NEWS b/etc/NEWS
index 699b1690090..42654457573 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -59,6 +59,11 @@ in these situations.
59 59
60*** The kqueue library is integrated for *BSD and Mac OS X machines. 60*** The kqueue library is integrated for *BSD and Mac OS X machines.
61 61
62** Tramp
63
64*** New connection method "sg", which allows to edit files under
65different group ID.
66
62 67
63* New Modes and Packages in Emacs 25.2 68* New Modes and Packages in Emacs 25.2
64 69
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 7b1aa2a13b0..baebb13dd22 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -284,6 +284,15 @@ The string is used in `tramp-methods'.")
284 (tramp-remote-shell-args ("-c")) 284 (tramp-remote-shell-args ("-c"))
285 (tramp-connection-timeout 10))) 285 (tramp-connection-timeout 10)))
286;;;###tramp-autoload 286;;;###tramp-autoload
287(add-to-list
288 'tramp-methods
289 '("sg"
290 (tramp-login-program "sg")
291 (tramp-login-args (("-") ("%u")))
292 (tramp-remote-shell "/bin/sh")
293 (tramp-remote-shell-args ("-c"))
294 (tramp-connection-timeout 10)))
295;;;###tramp-autoload
287(add-to-list 'tramp-methods 296(add-to-list 'tramp-methods
288 '("sudo" 297 '("sudo"
289 (tramp-login-program "sudo") 298 (tramp-login-program "sudo")
@@ -445,12 +454,17 @@ The string is used in `tramp-methods'.")
445 "Default list of (FUNCTION FILE) pairs to be examined for su methods.") 454 "Default list of (FUNCTION FILE) pairs to be examined for su methods.")
446 455
447;;;###tramp-autoload 456;;;###tramp-autoload
457(defconst tramp-completion-function-alist-sg
458 '((tramp-parse-etc-group "/etc/group"))
459 "Default list of (FUNCTION FILE) pairs to be examined for sg methods.")
460
461;;;###tramp-autoload
448(defconst tramp-completion-function-alist-putty 462(defconst tramp-completion-function-alist-putty
449 `((tramp-parse-putty 463 `((tramp-parse-putty
450 ,(if (memq system-type '(windows-nt)) 464 ,(if (memq system-type '(windows-nt))
451 "HKEY_CURRENT_USER\\Software\\SimonTatham\\PuTTY\\Sessions" 465 "HKEY_CURRENT_USER\\Software\\SimonTatham\\PuTTY\\Sessions"
452 "~/.putty/sessions"))) 466 "~/.putty/sessions")))
453 "Default list of (FUNCTION REGISTRY) pairs to be examined for putty sessions.") 467 "Default list of (FUNCTION REGISTRY) pairs to be examined for putty sessions.")
454 468
455;;;###tramp-autoload 469;;;###tramp-autoload
456(eval-after-load 'tramp 470(eval-after-load 'tramp
@@ -470,6 +484,7 @@ The string is used in `tramp-methods'.")
470 (tramp-set-completion-function "su" tramp-completion-function-alist-su) 484 (tramp-set-completion-function "su" tramp-completion-function-alist-su)
471 (tramp-set-completion-function "sudo" tramp-completion-function-alist-su) 485 (tramp-set-completion-function "sudo" tramp-completion-function-alist-su)
472 (tramp-set-completion-function "ksu" tramp-completion-function-alist-su) 486 (tramp-set-completion-function "ksu" tramp-completion-function-alist-su)
487 (tramp-set-completion-function "sg" tramp-completion-function-alist-sg)
473 (tramp-set-completion-function 488 (tramp-set-completion-function
474 "krlogin" tramp-completion-function-alist-rsh) 489 "krlogin" tramp-completion-function-alist-rsh)
475 (tramp-set-completion-function "plink" tramp-completion-function-alist-ssh) 490 (tramp-set-completion-function "plink" tramp-completion-function-alist-ssh)
@@ -5724,5 +5739,7 @@ function cell is returned to be applied on a buffer."
5724;; rsync). 5739;; rsync).
5725;; * Keep a second connection open for out-of-band methods like scp or 5740;; * Keep a second connection open for out-of-band methods like scp or
5726;; rsync. 5741;; rsync.
5742;; * Check, whether we could also use "getent passwd" and "getent
5743;; group" for user/group name completion.
5727 5744
5728;;; tramp-sh.el ends here 5745;;; tramp-sh.el ends here
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 5c6788082b1..e52f1958592 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -432,6 +432,7 @@ names from FILE for completion. The following predefined FUNCTIONs exists:
432 * `tramp-parse-sknownhosts' for \"~/.ssh2/knownhosts/*\" like files, 432 * `tramp-parse-sknownhosts' for \"~/.ssh2/knownhosts/*\" like files,
433 * `tramp-parse-hosts' for \"/etc/hosts\" like files, 433 * `tramp-parse-hosts' for \"/etc/hosts\" like files,
434 * `tramp-parse-passwd' for \"/etc/passwd\" like files. 434 * `tramp-parse-passwd' for \"/etc/passwd\" like files.
435 * `tramp-parse-etc-group' for \"/etc/group\" like files.
435 * `tramp-parse-netrc' for \"~/.netrc\" like files. 436 * `tramp-parse-netrc' for \"~/.netrc\" like files.
436 * `tramp-parse-putty' for PuTTY registered sessions. 437 * `tramp-parse-putty' for PuTTY registered sessions.
437 438
@@ -509,6 +510,7 @@ This regexp must match both `tramp-initial-end-of-output' and
509 510
510(defcustom tramp-password-prompt-regexp 511(defcustom tramp-password-prompt-regexp
511 (format "^.*\\(%s\\).*:\^@? *" 512 (format "^.*\\(%s\\).*:\^@? *"
513 ;; `password-word-equivalents' has been introduced with Emacs 24.4.
512 (if (boundp 'password-word-equivalents) 514 (if (boundp 'password-word-equivalents)
513 (regexp-opt (symbol-value 'password-word-equivalents)) 515 (regexp-opt (symbol-value 'password-word-equivalents))
514 "password\\|passphrase")) 516 "password\\|passphrase"))
@@ -2645,6 +2647,22 @@ Host is always \"localhost\"."
2645 result)) 2647 result))
2646 2648
2647;;;###tramp-autoload 2649;;;###tramp-autoload
2650(defun tramp-parse-etc-group (filename)
2651 "Return a list of (group host) tuples allowed to access.
2652Host is always \"localhost\"."
2653 (tramp-parse-file filename 'tramp-parse-etc-group-group))
2654
2655(defun tramp-parse-etc-group-group ()
2656 "Return a (group host) tuple allowed to access.
2657Host is always \"localhost\"."
2658 (let ((result)
2659 (split (split-string (buffer-substring (point) (point-at-eol)) ":")))
2660 (when (member (user-login-name) (split-string (nth 3 split) "," 'omit))
2661 (setq result (list (nth 0 split) "localhost")))
2662 (forward-line 1)
2663 result))
2664
2665;;;###tramp-autoload
2648(defun tramp-parse-netrc (filename) 2666(defun tramp-parse-netrc (filename)
2649 "Return a list of (user host) tuples allowed to access. 2667 "Return a list of (user host) tuples allowed to access.
2650User may be nil." 2668User may be nil."