aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2008-02-08 05:14:03 +0000
committerGlenn Morris2008-02-08 05:14:03 +0000
commit1e2eefdd0ccd5046af514a692a5e48ef4a498d31 (patch)
tree9fbd1f8da13b33061569a3306fff8f3512c7bbf0
parent9c519cf2a09c560dddb563cc56e0c9f65f158ebe (diff)
downloademacs-1e2eefdd0ccd5046af514a692a5e48ef4a498d31.tar.gz
emacs-1e2eefdd0ccd5046af514a692a5e48ef4a498d31.zip
(top-level): Move provide statement to end.
(pcmpl-unix-group-file, pcmpl-unix-passwd-file): Remove leading `*' from doc-string. Allow to be nil. (pcmpl-ssh-known-hosts-file): Convert comment into expanded doc-string. Allow to be nil. Add :version. (pcmpl-ssh-hosts): Move definition before use. Handle lines without hostnames, and multiple hostnames per line.
-rw-r--r--lisp/ChangeLog15
-rw-r--r--lisp/pcmpl-unix.el70
2 files changed, 48 insertions, 37 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 60dfd4a09b6..1d4af67aac4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,18 @@
12008-02-08 Glenn Morris <rgm@gnu.org>
2
3 * pcmpl-unix.el (top-level): Move provide statement to end.
4 (pcmpl-unix-group-file, pcmpl-unix-passwd-file): Remove leading
5 `*' from doc-string. Allow to be nil.
6 (pcmpl-ssh-known-hosts-file): Convert comment into expanded doc-string.
7 Allow to be nil. Add :version.
8 (pcmpl-ssh-hosts): Move definition before use. Handle lines
9 without hostnames, and multiple hostnames per line.
10
112008-02-08 Phil Hagelberg <phil@evri.com>
12
13 * pcmpl-unix.el (pcmpl-ssh-known-hosts-file): New defcustom.
14 (pcomplete/ssh, pcomplete/scp, pcmpl-ssh-hosts): New functions.
15
12008-02-07 Timo Savola <timo.savola@iki.fi> 162008-02-07 Timo Savola <timo.savola@iki.fi>
2 17
3 * startup.el (command-line-x-option-alist): Add --parent-id. 18 * startup.el (command-line-x-option-alist): Add --parent-id.
diff --git a/lisp/pcmpl-unix.el b/lisp/pcmpl-unix.el
index d22e9bdd867..d213c3ae8e3 100644
--- a/lisp/pcmpl-unix.el
+++ b/lisp/pcmpl-unix.el
@@ -24,26 +24,29 @@
24 24
25;;; Code: 25;;; Code:
26 26
27(provide 'pcmpl-unix)
28
29(require 'pcomplete) 27(require 'pcomplete)
30 28
31;; User Variables: 29;; User Variables:
32 30
33(defcustom pcmpl-unix-group-file "/etc/group" 31(defcustom pcmpl-unix-group-file "/etc/group"
34 "*If non-nil, a string naming the group file on your system." 32 "If non-nil, a string naming the group file on your system."
35 :type 'file 33 :type '(choice file (const nil))
36 :group 'pcmpl-unix) 34 :group 'pcmpl-unix)
37 35
38(defcustom pcmpl-unix-passwd-file "/etc/passwd" 36(defcustom pcmpl-unix-passwd-file "/etc/passwd"
39 "*If non-nil, a string naming the passwd file on your system." 37 "If non-nil, a string naming the passwd file on your system."
40 :type 'file 38 :type '(choice file (const nil))
41 :group 'pcmpl-unix) 39 :group 'pcmpl-unix)
42 40
43(defcustom pcmpl-ssh-known-hosts-file "~/.ssh/known_hosts" 41(defcustom pcmpl-ssh-known-hosts-file "~/.ssh/known_hosts"
44 "The location of the user's SSH `known_hosts' file." 42 "If non-nil, a string naming your SSH \"known_hosts\" file.
45 :type 'file 43This allows completion of SSH host names. Note that newer
46 :group 'pcmpl-unix) 44versions of ssh hash the hosts by default to prevent
45Island-hopping SSH attacks. This can be disabled, at some risk,
46with the SSH option \"HashKnownHosts no\"."
47 :type '(choice file (const nil))
48 :group 'pcmpl-unix
49 :version "23.1")
47 50
48;; Functions: 51;; Functions:
49 52
@@ -128,21 +131,24 @@
128 (pcomplete-here* (pcmpl-unix-group-names))) 131 (pcomplete-here* (pcmpl-unix-group-names)))
129 (while (pcomplete-here (pcomplete-entries)))) 132 (while (pcomplete-here (pcomplete-entries))))
130 133
134
131;; ssh support by Phil Hagelberg. 135;; ssh support by Phil Hagelberg.
132;; http://www.emacswiki.org/cgi-bin/wiki/pcmpl-ssh.el 136;; http://www.emacswiki.org/cgi-bin/wiki/pcmpl-ssh.el
133 137
134;; This will allow eshell to autocomplete SSH hosts from the list of 138(defun pcmpl-ssh-hosts ()
135;; known hosts in your ~/.ssh/known_hosts file. Note that newer 139 "Return a list of hosts found in `pcmpl-ssh-known-hosts-file'."
136;; versions of ssh hash the hosts by default to prevent Island-hopping 140 (when (and pcmpl-ssh-known-hosts-file
137;; SSH attacks. (https://itso.iu.edu/Hashing_the_OpenSSH_known__hosts_File) 141 (file-readable-p pcmpl-ssh-known-hosts-file))
138;; You can disable this by putting the following line in your ~/.ssh/config 142 (with-temp-buffer
139;; file following the "Host *" directive: 143 (insert-file-contents-literally pcmpl-ssh-known-hosts-file)
140 144 (let (ssh-hosts-list)
141;; HashKnownHosts no 145 (while (re-search-forward "^ *\\([-.[:alnum:]]+\\)[, ]" nil t)
142 146 (add-to-list 'ssh-hosts-list (match-string 1))
143;; Note that this will make you vulnerable to the Island-hopping 147 (while (and (looking-back ",")
144;; attack described in the link above if you allow key-based 148 (re-search-forward "\\([-.[:alnum:]]+\\)[, ]"
145;; passwordless logins and your account is compromised. 149 (line-end-position) t))
150 (add-to-list 'ssh-hosts-list (match-string 1))))
151 ssh-hosts-list))))
146 152
147;;;###autoload 153;;;###autoload
148(defun pcomplete/ssh () 154(defun pcomplete/ssh ()
@@ -153,24 +159,14 @@
153;;;###autoload 159;;;###autoload
154(defun pcomplete/scp () 160(defun pcomplete/scp ()
155 "Completion rules for the `scp' command. 161 "Completion rules for the `scp' command.
156
157Includes files as well as host names followed by a colon." 162Includes files as well as host names followed by a colon."
158 (pcomplete-opt "1246BCpqrvcFiloPS") 163 (pcomplete-opt "1246BCpqrvcFiloPS")
159 (while t (pcomplete-here (append (pcomplete-all-entries) 164 (while t (pcomplete-here (append (pcomplete-all-entries)
160 (mapcar (lambda (host) (concat host ":")) (pcmpl-ssh-hosts)))))) 165 (mapcar (lambda (host)
166 (concat host ":"))
167 (pcmpl-ssh-hosts))))))
161 168
162(defun pcmpl-ssh-hosts () 169(provide 'pcmpl-unix)
163 "Returns a list of hosts found in the users `known_hosts' file." 170
164 (if (file-readable-p pcmpl-ssh-known-hosts-file) 171;; arch-tag: 3f9eb5af-7e0e-449d-b586-381cbbf8fc5c
165 (with-temp-buffer
166 (insert-file-contents-literally pcmpl-ssh-known-hosts-file)
167 (let ((ssh-hosts-list) '())
168 (while (not (eobp))
169 (let ((hostname (buffer-substring (point) (- (search-forward-regexp "[, ]") 1))))
170 (unless (string-match "^|" hostname)
171 (add-to-list 'ssh-hosts-list hostname)))
172 (forward-line))
173 ssh-hosts-list))))
174
175;;; arch-tag: 3f9eb5af-7e0e-449d-b586-381cbbf8fc5c
176;;; pcmpl-unix.el ends here 172;;; pcmpl-unix.el ends here