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