diff options
| author | Michael Albinus | 2016-01-23 16:20:21 +0100 |
|---|---|---|
| committer | Michael Albinus | 2016-01-23 16:20:21 +0100 |
| commit | 8cdb9ac0fb060366bc823de84ecdba258716addb (patch) | |
| tree | 0c2008763028cfbe60e2d69158b9cee6c6b949c1 | |
| parent | 9b2375008348da99b5ec414cd3ca8c4669a12576 (diff) | |
| download | emacs-8cdb9ac0fb060366bc823de84ecdba258716addb.tar.gz emacs-8cdb9ac0fb060366bc823de84ecdba258716addb.zip | |
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.
| -rw-r--r-- | lisp/net/tramp-cmds.el | 2 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 2 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 39 |
3 files changed, 25 insertions, 18 deletions
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index f9b66d43074..5e9af0b18eb 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el | |||
| @@ -145,7 +145,7 @@ This includes password cache, file cache, connection cache, buffers." | |||
| 145 | "Kill all remote buffers." | 145 | "Kill all remote buffers." |
| 146 | (interactive) | 146 | (interactive) |
| 147 | 147 | ||
| 148 | ;; Remove all Tramp related buffers. | 148 | ;; Remove all Tramp related connections. |
| 149 | (tramp-cleanup-all-connections) | 149 | (tramp-cleanup-all-connections) |
| 150 | 150 | ||
| 151 | ;; Remove all buffers with a remote default-directory. | 151 | ;; Remove all buffers with a remote default-directory. |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index baebb13dd22..ab4f07fc020 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -5739,7 +5739,5 @@ function cell is returned to be applied on a buffer." | |||
| 5739 | ;; rsync). | 5739 | ;; rsync). |
| 5740 | ;; * Keep a second connection open for out-of-band methods like scp or | 5740 | ;; * Keep a second connection open for out-of-band methods like scp or |
| 5741 | ;; rsync. | 5741 | ;; rsync. |
| 5742 | ;; * Check, whether we could also use "getent passwd" and "getent | ||
| 5743 | ;; group" for user/group name completion. | ||
| 5744 | 5742 | ||
| 5745 | ;;; tramp-sh.el ends here | 5743 | ;;; tramp-sh.el ends here |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index e52f1958592..4543c0d1a47 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -1048,7 +1048,7 @@ entry does not exist, return nil." | |||
| 1048 | (replace-regexp-in-string "^tramp-" "" (symbol-name param)))) | 1048 | (replace-regexp-in-string "^tramp-" "" (symbol-name param)))) |
| 1049 | (if (tramp-connection-property-p vec hash-entry) | 1049 | (if (tramp-connection-property-p vec hash-entry) |
| 1050 | ;; We use the cached property. | 1050 | ;; We use the cached property. |
| 1051 | (tramp-get-connection-property vec hash-entry nil) | 1051 | (tramp-get-connection-property vec hash-entry nil) |
| 1052 | ;; Use the static value from `tramp-methods'. | 1052 | ;; Use the static value from `tramp-methods'. |
| 1053 | (let ((methods-entry | 1053 | (let ((methods-entry |
| 1054 | (assoc param (assoc (tramp-file-name-method vec) tramp-methods)))) | 1054 | (assoc param (assoc (tramp-file-name-method vec) tramp-methods)))) |
| @@ -2624,17 +2624,18 @@ User is always nil." | |||
| 2624 | (tramp-parse-group | 2624 | (tramp-parse-group |
| 2625 | (concat "^\\(" tramp-ipv6-regexp "\\|" tramp-host-regexp "\\)") 1 " \t")) | 2625 | (concat "^\\(" tramp-ipv6-regexp "\\|" tramp-host-regexp "\\)") 1 " \t")) |
| 2626 | 2626 | ||
| 2627 | ;; For su-alike methods it would be desirable to return "root@localhost" | ||
| 2628 | ;; as default. Unfortunately, we have no information whether any user name | ||
| 2629 | ;; has been typed already. So we use `tramp-current-user' as indication, | ||
| 2630 | ;; assuming it is set in `tramp-completion-handle-file-name-all-completions'. | ||
| 2631 | ;;;###tramp-autoload | 2627 | ;;;###tramp-autoload |
| 2632 | (defun tramp-parse-passwd (filename) | 2628 | (defun tramp-parse-passwd (filename) |
| 2633 | "Return a list of (user host) tuples allowed to access. | 2629 | "Return a list of (user host) tuples allowed to access. |
| 2634 | Host is always \"localhost\"." | 2630 | Host is always \"localhost\"." |
| 2635 | (if (zerop (length tramp-current-user)) | 2631 | (with-tramp-connection-property nil "parse-passwd" |
| 2636 | '(("root" nil)) | 2632 | (if (executable-find "getent") |
| 2637 | (tramp-parse-file filename 'tramp-parse-passwd-group))) | 2633 | (with-temp-buffer |
| 2634 | (when (zerop (tramp-call-process nil "getent" nil t nil "passwd")) | ||
| 2635 | (goto-char (point-min)) | ||
| 2636 | (loop while (not (eobp)) collect | ||
| 2637 | (tramp-parse-etc-group-group)))) | ||
| 2638 | (tramp-parse-file filename 'tramp-parse-passwd-group)))) | ||
| 2638 | 2639 | ||
| 2639 | (defun tramp-parse-passwd-group () | 2640 | (defun tramp-parse-passwd-group () |
| 2640 | "Return a (user host) tuple allowed to access. | 2641 | "Return a (user host) tuple allowed to access. |
| @@ -2650,7 +2651,14 @@ Host is always \"localhost\"." | |||
| 2650 | (defun tramp-parse-etc-group (filename) | 2651 | (defun tramp-parse-etc-group (filename) |
| 2651 | "Return a list of (group host) tuples allowed to access. | 2652 | "Return a list of (group host) tuples allowed to access. |
| 2652 | Host is always \"localhost\"." | 2653 | Host is always \"localhost\"." |
| 2653 | (tramp-parse-file filename 'tramp-parse-etc-group-group)) | 2654 | (with-tramp-connection-property nil "parse-group" |
| 2655 | (if (executable-find "getent") | ||
| 2656 | (with-temp-buffer | ||
| 2657 | (when (zerop (tramp-call-process nil "getent" nil t nil "group")) | ||
| 2658 | (goto-char (point-min)) | ||
| 2659 | (loop while (not (eobp)) collect | ||
| 2660 | (tramp-parse-etc-group-group)))) | ||
| 2661 | (tramp-parse-file filename 'tramp-parse-etc-group-group)))) | ||
| 2654 | 2662 | ||
| 2655 | (defun tramp-parse-etc-group-group () | 2663 | (defun tramp-parse-etc-group-group () |
| 2656 | "Return a (group host) tuple allowed to access. | 2664 | "Return a (group host) tuple allowed to access. |
| @@ -2686,12 +2694,13 @@ User may be nil." | |||
| 2686 | "Return a list of (user host) tuples allowed to access. | 2694 | "Return a list of (user host) tuples allowed to access. |
| 2687 | User is always nil." | 2695 | User is always nil." |
| 2688 | (if (memq system-type '(windows-nt)) | 2696 | (if (memq system-type '(windows-nt)) |
| 2689 | (with-temp-buffer | 2697 | (with-tramp-connection-property nil "parse-putty" |
| 2690 | (when (zerop (tramp-call-process | 2698 | (with-temp-buffer |
| 2691 | nil "reg" nil t nil "query" registry-or-dirname)) | 2699 | (when (zerop (tramp-call-process |
| 2692 | (goto-char (point-min)) | 2700 | nil "reg" nil t nil "query" registry-or-dirname)) |
| 2693 | (loop while (not (eobp)) collect | 2701 | (goto-char (point-min)) |
| 2694 | (tramp-parse-putty-group registry-or-dirname)))) | 2702 | (loop while (not (eobp)) collect |
| 2703 | (tramp-parse-putty-group registry-or-dirname))))) | ||
| 2695 | ;; UNIX case. | 2704 | ;; UNIX case. |
| 2696 | (tramp-parse-shostkeys-sknownhosts | 2705 | (tramp-parse-shostkeys-sknownhosts |
| 2697 | registry-or-dirname (concat "^\\(" tramp-host-regexp "\\)$")))) | 2706 | registry-or-dirname (concat "^\\(" tramp-host-regexp "\\)$")))) |