Improve user name completion in Tramp
* lisp/net/tramp.el (tramp-parse-passwd, tramp-parse-etc-group): Call also "getent passwd" or "getent group", if possible. (tramp-parse-putty): Cache the result.
This commit is contained in:
parent
9b23750083
commit
8cdb9ac0fb
3 changed files with 25 additions and 18 deletions
|
@ -145,7 +145,7 @@ This includes password cache, file cache, connection cache, buffers."
|
|||
"Kill all remote buffers."
|
||||
(interactive)
|
||||
|
||||
;; Remove all Tramp related buffers.
|
||||
;; Remove all Tramp related connections.
|
||||
(tramp-cleanup-all-connections)
|
||||
|
||||
;; Remove all buffers with a remote default-directory.
|
||||
|
|
|
@ -5739,7 +5739,5 @@ 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
|
||||
|
|
|
@ -1048,7 +1048,7 @@ entry does not exist, return nil."
|
|||
(replace-regexp-in-string "^tramp-" "" (symbol-name param))))
|
||||
(if (tramp-connection-property-p vec hash-entry)
|
||||
;; We use the cached property.
|
||||
(tramp-get-connection-property vec hash-entry nil)
|
||||
(tramp-get-connection-property vec hash-entry nil)
|
||||
;; Use the static value from `tramp-methods'.
|
||||
(let ((methods-entry
|
||||
(assoc param (assoc (tramp-file-name-method vec) tramp-methods))))
|
||||
|
@ -2624,17 +2624,18 @@ User is always nil."
|
|||
(tramp-parse-group
|
||||
(concat "^\\(" tramp-ipv6-regexp "\\|" tramp-host-regexp "\\)") 1 " \t"))
|
||||
|
||||
;; For su-alike methods it would be desirable to return "root@localhost"
|
||||
;; as default. Unfortunately, we have no information whether any user name
|
||||
;; has been typed already. So we use `tramp-current-user' as indication,
|
||||
;; assuming it is set in `tramp-completion-handle-file-name-all-completions'.
|
||||
;;;###tramp-autoload
|
||||
(defun tramp-parse-passwd (filename)
|
||||
"Return a list of (user host) tuples allowed to access.
|
||||
Host is always \"localhost\"."
|
||||
(if (zerop (length tramp-current-user))
|
||||
'(("root" nil))
|
||||
(tramp-parse-file filename 'tramp-parse-passwd-group)))
|
||||
(with-tramp-connection-property nil "parse-passwd"
|
||||
(if (executable-find "getent")
|
||||
(with-temp-buffer
|
||||
(when (zerop (tramp-call-process nil "getent" nil t nil "passwd"))
|
||||
(goto-char (point-min))
|
||||
(loop while (not (eobp)) collect
|
||||
(tramp-parse-etc-group-group))))
|
||||
(tramp-parse-file filename 'tramp-parse-passwd-group))))
|
||||
|
||||
(defun tramp-parse-passwd-group ()
|
||||
"Return a (user host) tuple allowed to access.
|
||||
|
@ -2650,7 +2651,14 @@ Host is always \"localhost\"."
|
|||
(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))
|
||||
(with-tramp-connection-property nil "parse-group"
|
||||
(if (executable-find "getent")
|
||||
(with-temp-buffer
|
||||
(when (zerop (tramp-call-process nil "getent" nil t nil "group"))
|
||||
(goto-char (point-min))
|
||||
(loop while (not (eobp)) collect
|
||||
(tramp-parse-etc-group-group))))
|
||||
(tramp-parse-file filename 'tramp-parse-etc-group-group))))
|
||||
|
||||
(defun tramp-parse-etc-group-group ()
|
||||
"Return a (group host) tuple allowed to access.
|
||||
|
@ -2686,12 +2694,13 @@ User may be nil."
|
|||
"Return a list of (user host) tuples allowed to access.
|
||||
User is always nil."
|
||||
(if (memq system-type '(windows-nt))
|
||||
(with-temp-buffer
|
||||
(when (zerop (tramp-call-process
|
||||
nil "reg" nil t nil "query" registry-or-dirname))
|
||||
(goto-char (point-min))
|
||||
(loop while (not (eobp)) collect
|
||||
(tramp-parse-putty-group registry-or-dirname))))
|
||||
(with-tramp-connection-property nil "parse-putty"
|
||||
(with-temp-buffer
|
||||
(when (zerop (tramp-call-process
|
||||
nil "reg" nil t nil "query" registry-or-dirname))
|
||||
(goto-char (point-min))
|
||||
(loop while (not (eobp)) collect
|
||||
(tramp-parse-putty-group registry-or-dirname)))))
|
||||
;; UNIX case.
|
||||
(tramp-parse-shostkeys-sknownhosts
|
||||
registry-or-dirname (concat "^\\(" tramp-host-regexp "\\)$"))))
|
||||
|
|
Loading…
Add table
Reference in a new issue