[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master a600f4c: Add "sg" method to Tramp
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] master a600f4c: Add "sg" method to Tramp |
Date: |
Fri, 15 Jan 2016 10:10:44 +0000 |
branch: master
commit a600f4c69309bf37f67c02cbcc9a9e4ba1e69c76
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
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.
---
doc/misc/tramp.texi | 26 +++++++++++++++-----------
etc/NEWS | 5 +++++
lisp/net/tramp-sh.el | 19 ++++++++++++++++++-
lisp/net/tramp.el | 18 ++++++++++++++++++
4 files changed, 56 insertions(+), 12 deletions(-)
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 447498a..14afb4a 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -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.
address@hidden @option{sg}
address@hidden method sg
address@hidden 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
address@hidden(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 @address@hidden 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 @address@hidden and @command{pscp}
@item @address@hidden and @command{psftp}
@cindex method pscp
@@ -795,7 +799,6 @@ session.
These methods support the @samp{-P} argument.
-
@item @address@hidden 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 @address@hidden
@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.
address@hidden @code{tramp-parse-etc-group}
address@hidden tramp-parse-etc-group
+
+A function which parses @file{/etc/group} files for group names.
+
@item @code{tramp-parse-netrc}
@findex tramp-parse-netrc
diff --git a/etc/NEWS b/etc/NEWS
index 699b169..4265445 100644
--- 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.
+
* New Modes and Packages in Emacs 25.2
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 7b1aa2a..baebb13 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -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")
@@ -445,12 +454,17 @@ The string is used in `tramp-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
(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
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 5c67880..e52f195 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:
* `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\\).*:address@hidden *"
+ ;; `password-word-equivalents' has been introduced with Emacs 24.4.
(if (boundp 'password-word-equivalents)
(regexp-opt (symbol-value 'password-word-equivalents))
"password\\|passphrase"))
@@ -2645,6 +2647,22 @@ Host is always \"localhost\"."
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.
User may be nil."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master a600f4c: Add "sg" method to Tramp,
Michael Albinus <=