]> code.delx.au - gnu-emacs/commitdiff
Add "sg" method to Tramp
authorMichael Albinus <michael.albinus@gmx.de>
Fri, 15 Jan 2016 10:10:37 +0000 (11:10 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Fri, 15 Jan 2016 10:10:37 +0000 (11:10 +0100)
* 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.

doc/misc/tramp.texi
etc/NEWS
lisp/net/tramp-sh.el
lisp/net/tramp.el

index 447498a3521532b71f7a58a68ec3867321692c85..14afb4ad353bc4c8e56ecce90ed8b43f74dd6a7a 100644 (file)
@@ -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
+behavior.
+
 @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
 
index 699b1690090aa7cb32533c42a44700ea5a6cafcc..42654457573d71f5908d005d089b9ac418a750dd 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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.
+
 \f
 * New Modes and Packages in Emacs 25.2
 
index 7b1aa2a13b075717fa2137a0b605b5a50c3d1721..baebb13dd228352d0551a40dc724ed2d8886164b 100644 (file)
@@ -284,6 +284,15 @@ The string is used in `tramp-methods'.")
     (tramp-remote-shell-args    ("-c"))
     (tramp-connection-timeout   10)))
 ;;;###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
   '("sudo"
     (tramp-login-program        "sudo")
@@ -444,13 +453,18 @@ The string is used in `tramp-methods'.")
   '((tramp-parse-passwd "/etc/passwd"))
   "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
 (defconst tramp-completion-function-alist-putty
   `((tramp-parse-putty
      ,(if (memq system-type '(windows-nt))
          "HKEY_CURRENT_USER\\Software\\SimonTatham\\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
 (eval-after-load 'tramp
@@ -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)
      (tramp-set-completion-function
       "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
index 5c6788082b1e1f3da6a811996315b278f035d706..e52f1958592336eba7ce358c0ffa8de6dcd5c4c2 100644 (file)
@@ -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))
            "password\\|passphrase"))
@@ -2644,6 +2646,22 @@ Host is always \"localhost\"."
      (forward-line 1)
      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
 (defun tramp-parse-netrc (filename)
   "Return a list of (user host) tuples allowed to access.