Commit a600f4c6 authored by Michael Albinus's avatar Michael Albinus

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

* lisp/net/tramp.el (tramp-completion-function-alist): Adapt docstring.
(tramp-parse-etc-group, tramp-parse-etc-group-group): New defuns.
parent de8c5f9d
......@@ -590,7 +590,6 @@ specifies the file size for such optimization.
@command{rsh} is an option for connecting to hosts within local
networks since @command{rsh} is not as secure as other methods.
@item @option{ssh}
@cindex method ssh
@cindex ssh method
......@@ -610,7 +609,6 @@ host name, a hash sign, then a port number). It is the same as passing
Connecting to a remote host with @command{telnet} is as insecure
as the @option{rsh} method.
@item @option{su}
@cindex method su
@cindex su method
......@@ -627,6 +625,16 @@ the host returned by the function @command{(system-name)}. See
Similar to @option{su} method, @option{sudo} uses @command{sudo}.
@command{sudo} must have sufficient rights to start a shell.
@item @option{sg}
@cindex method sg
@cindex sg method
The @command{sg} program allows editing as different group. The host
can be either @samp{localhost} or the host returned by the function
@command{(system-name)}. The user name must be specified, but it
denotes a group name. See @ref{Multi-hops} for an exception to this
@item @option{sshx}
@cindex method sshx
@cindex sshx method
......@@ -663,7 +671,6 @@ This method is also similar to @option{ssh}. It uses the
This is another method from the Kerberos suite. It behaves like @option{su}.
@item @option{plink}
@cindex method plink
@cindex plink method
......@@ -677,7 +684,6 @@ session.
@option{plink} method supports the @samp{-P} argument.
@item @option{plinkx}
@cindex method plinkx
@cindex plinkx method
......@@ -754,7 +760,6 @@ is lost if the file exists only on one side of the connection.
This method supports the @samp{-p} argument.
@item @option{scpx}---@command{ssh} and @command{scp}
@cindex method scpx
@cindex scpx method
......@@ -771,7 +776,6 @@ shell prompts that confuses @value{tramp}.
This method supports the @samp{-p} argument.
@item @option{pscp}---@command{plink} and @command{pscp}
@item @option{psftp}---@command{plink} and @command{psftp}
@cindex method pscp
......@@ -795,7 +799,6 @@ session.
These methods support the @samp{-P} argument.
@item @option{fcp}---@command{fsh} and @command{fcp}
@cindex method fcp
@cindex fcp method
......@@ -839,7 +842,6 @@ When @value{tramp} uses @option{ftp}, it forwards requests to whatever
ftp program is specified by Ange FTP. This external program must be
capable of servicing requests from @value{tramp}.
@item @option{smb}---@command{smbclient}
@cindex method smb
@cindex smb method
......@@ -911,7 +913,6 @@ access remote files using UNC file names instead of @value{tramp}:
UNC file name specification does not allow to specify a different user
name for authentication like the @command{smbclient} can.
@item @option{adb}
@cindex method adb
@cindex adb method
......@@ -993,7 +994,6 @@ but with SSL encryption. Both methods support the port numbers.
OBEX is an FTP-like access protocol for cell phones and similar simple
devices. @value{tramp} supports OBEX over Bluetooth.
@item @option{sftp}
@cindex method sftp
@cindex sftp method
......@@ -1054,7 +1054,6 @@ For authentication, this protocol uses only @option{Basic
Authentication} (see RFC 2617). When no port number is specified, this
protocol defaults to @option{8080}.
@item @option{socks}
@cindex method socks
@cindex socks method
......@@ -1478,6 +1477,11 @@ A function dedicated to @file{/etc/hosts} for host names.
A function which parses @file{/etc/passwd} files for user names.
@item @code{tramp-parse-etc-group}
@findex tramp-parse-etc-group
A function which parses @file{/etc/group} files for group names.
@item @code{tramp-parse-netrc}
@findex tramp-parse-netrc
......@@ -59,6 +59,11 @@ in these situations.
*** The kqueue library is integrated for *BSD and Mac OS X machines.
** Tramp
*** New connection method "sg", which allows to edit files under
different group ID.
* New Modes and Packages in Emacs 25.2
......@@ -284,6 +284,15 @@ The string is used in `tramp-methods'.")
(tramp-remote-shell-args ("-c"))
(tramp-connection-timeout 10)))
(tramp-login-program "sg")
(tramp-login-args (("-") ("%u")))
(tramp-remote-shell "/bin/sh")
(tramp-remote-shell-args ("-c"))
(tramp-connection-timeout 10)))
(add-to-list 'tramp-methods
(tramp-login-program "sudo")
......@@ -444,6 +453,11 @@ The string is used in `tramp-methods'.")
'((tramp-parse-passwd "/etc/passwd"))
"Default list of (FUNCTION FILE) pairs to be examined for su methods.")
(defconst tramp-completion-function-alist-sg
'((tramp-parse-etc-group "/etc/group"))
"Default list of (FUNCTION FILE) pairs to be examined for sg methods.")
(defconst tramp-completion-function-alist-putty
......@@ -470,6 +484,7 @@ The string is used in `tramp-methods'.")
(tramp-set-completion-function "su" tramp-completion-function-alist-su)
(tramp-set-completion-function "sudo" tramp-completion-function-alist-su)
(tramp-set-completion-function "ksu" tramp-completion-function-alist-su)
(tramp-set-completion-function "sg" tramp-completion-function-alist-sg)
"krlogin" tramp-completion-function-alist-rsh)
(tramp-set-completion-function "plink" tramp-completion-function-alist-ssh)
......@@ -5724,5 +5739,7 @@ function cell is returned to be applied on a buffer."
;; rsync).
;; * Keep a second connection open for out-of-band methods like scp or
;; rsync.
;; * Check, whether we could also use "getent passwd" and "getent
;; group" for user/group name completion.
;;; tramp-sh.el ends here
......@@ -432,6 +432,7 @@ names from FILE for completion. The following predefined FUNCTIONs exists:
* `tramp-parse-sknownhosts' for \"~/.ssh2/knownhosts/*\" like files,
* `tramp-parse-hosts' for \"/etc/hosts\" like files,
* `tramp-parse-passwd' for \"/etc/passwd\" like files.
* `tramp-parse-etc-group' for \"/etc/group\" like files.
* `tramp-parse-netrc' for \"~/.netrc\" like files.
* `tramp-parse-putty' for PuTTY registered sessions.
......@@ -509,6 +510,7 @@ This regexp must match both `tramp-initial-end-of-output' and
(defcustom tramp-password-prompt-regexp
(format "^.*\\(%s\\).*:\^@? *"
;; `password-word-equivalents' has been introduced with Emacs 24.4.
(if (boundp 'password-word-equivalents)
(regexp-opt (symbol-value 'password-word-equivalents))
......@@ -2644,6 +2646,22 @@ Host is always \"localhost\"."
(forward-line 1)
(defun tramp-parse-etc-group (filename)
"Return a list of (group host) tuples allowed to access.
Host is always \"localhost\"."
(tramp-parse-file filename 'tramp-parse-etc-group-group))
(defun tramp-parse-etc-group-group ()
"Return a (group host) tuple allowed to access.
Host is always \"localhost\"."
(let ((result)
(split (split-string (buffer-substring (point) (point-at-eol)) ":")))
(when (member (user-login-name) (split-string (nth 3 split) "," 'omit))
(setq result (list (nth 0 split) "localhost")))
(forward-line 1)
(defun tramp-parse-netrc (filename)
"Return a list of (user host) tuples allowed to access.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment