[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hang forever with an invalid tramp filename
From: |
Thierry Volpiatto |
Subject: |
Re: hang forever with an invalid tramp filename |
Date: |
Mon, 07 Nov 2011 21:49:05 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux) |
Hi Michael,
Michael Albinus <address@hidden> writes:
>
> Good idea. I will check, which functions coujld be merged; likely more
> than only tramp-parse-shosts and tramp-parse-sconfig.
I did some work on this, not guaranteed it work, not tested, see
patch attached.
=== modified file 'lisp/net/tramp.el'
*** lisp/net/tramp.el 2011-10-19 20:21:35 +0000
--- lisp/net/tramp.el 2011-11-05 17:50:58 +0000
***************
*** 2393,2413 ****
(unless (zerop (+ (length user) (length host)))
(tramp-completion-make-tramp-file-name method user host nil)))
! ;;;###tramp-autoload
! (defun tramp-parse-rhosts (filename)
"Return a list of (user host) tuples allowed to access.
! Either user or host may be nil."
;; On Windows, there are problems in completion when
;; `default-directory' is remote.
! (let ((default-directory (tramp-compat-temporary-file-directory))
! res)
(when (file-readable-p filename)
(with-temp-buffer
(insert-file-contents filename)
(goto-char (point-min))
! (while (not (eobp))
! (push (tramp-parse-rhosts-group) res))))
! res))
(defun tramp-parse-rhosts-group ()
"Return a (user host) tuple allowed to access.
--- 2393,2428 ----
(unless (zerop (+ (length user) (length host)))
(tramp-completion-make-tramp-file-name method user host nil)))
! ;; Generic function
! (defun tramp-parse-sgroup (regexp match-level skip-regexp)
! "Return a (user host) tuple allowed to access.
! User is always nil."
! (let (result)
! (when (re-search-forward regexp (point-at-eol) t)
! (setq result (list nil (match-string match-level))))
! (or
! (> (skip-chars-forward skip-regexp) 0)
! (forward-line 1))
! result))
!
! ;; Generic function
! (defun tramp-parse-sfile (filename function)
"Return a list of (user host) tuples allowed to access.
! User is always nil."
;; On Windows, there are problems in completion when
;; `default-directory' is remote.
! (let ((default-directory (tramp-compat-temporary-file-directory)))
(when (file-readable-p filename)
(with-temp-buffer
(insert-file-contents filename)
(goto-char (point-min))
! (loop while (not (eobp)) collect (funcall function))))))
!
! ;;;###tramp-autoload
! (defun tramp-parse-rhosts (filename)
! "Return a list of (user host) tuples allowed to access.
! Either user or host may be nil."
! (tramp-parse-sfile filename 'tramp-parse-rhosts-group))
(defun tramp-parse-rhosts-group ()
"Return a (user host) tuple allowed to access.
***************
*** 2417,2426 ****
(concat
"^\\(" tramp-host-regexp "\\)"
"\\([ \t]+" "\\(" tramp-user-regexp "\\)" "\\)?")))
! (narrow-to-region (point) (point-at-eol))
! (when (re-search-forward regexp nil t)
(setq result (append (list (match-string 3) (match-string 1)))))
- (widen)
(forward-line 1)
result))
--- 2432,2439 ----
(concat
"^\\(" tramp-host-regexp "\\)"
"\\([ \t]+" "\\(" tramp-user-regexp "\\)" "\\)?")))
! (when (re-search-forward regexp (point-at-eol) t)
(setq result (append (list (match-string 3) (match-string 1)))))
(forward-line 1)
result))
***************
*** 2428,2551 ****
(defun tramp-parse-shosts (filename)
"Return a list of (user host) tuples allowed to access.
User is always nil."
! ;; On Windows, there are problems in completion when
! ;; `default-directory' is remote.
! (let ((default-directory (tramp-compat-temporary-file-directory))
! res)
! (when (file-readable-p filename)
! (with-temp-buffer
! (insert-file-contents filename)
! (goto-char (point-min))
! (while (not (eobp))
! (push (tramp-parse-shosts-group) res))))
! res))
(defun tramp-parse-shosts-group ()
"Return a (user host) tuple allowed to access.
User is always nil."
! (let ((result)
! (regexp (concat "^\\(" tramp-host-regexp "\\)")))
! (narrow-to-region (point) (point-at-eol))
! (when (re-search-forward regexp nil t)
! (setq result (list nil (match-string 1))))
! (widen)
! (or
! (> (skip-chars-forward ",") 0)
! (forward-line 1))
! result))
;;;###tramp-autoload
(defun tramp-parse-sconfig (filename)
"Return a list of (user host) tuples allowed to access.
User is always nil."
! ;; On Windows, there are problems in completion when
! ;; `default-directory' is remote.
! (let ((default-directory (tramp-compat-temporary-file-directory))
! res)
! (when (file-readable-p filename)
! (with-temp-buffer
! (insert-file-contents filename)
! (goto-char (point-min))
! (while (not (eobp))
! (push (tramp-parse-sconfig-group) res))))
! res))
(defun tramp-parse-sconfig-group ()
"Return a (user host) tuple allowed to access.
User is always nil."
! (let ((result)
! (regexp (concat "^[ \t]*Host[ \t]+" "\\(" tramp-host-regexp "\\)")))
! (narrow-to-region (point) (point-at-eol))
! (when (re-search-forward regexp nil t)
! (setq result (list nil (match-string 1))))
! (widen)
! (or
! (> (skip-chars-forward ",") 0)
! (forward-line 1))
! result))
! ;;;###tramp-autoload
! (defun tramp-parse-shostkeys (dirname)
"Return a list of (user host) tuples allowed to access.
User is always nil."
;; On Windows, there are problems in completion when
;; `default-directory' is remote.
(let* ((default-directory (tramp-compat-temporary-file-directory))
! (regexp (concat "^key_[0-9]+_\\(" tramp-host-regexp "\\)\\.pub$"))
! (files (when (file-directory-p dirname) (directory-files dirname)))
! result)
! (while files
! (when (string-match regexp (car files))
! (push (list nil (match-string 1 (car files))) result))
! (setq files (cdr files)))
! result))
(defun tramp-parse-sknownhosts (dirname)
"Return a list of (user host) tuples allowed to access.
User is always nil."
! ;; On Windows, there are problems in completion when
! ;; `default-directory' is remote.
! (let* ((default-directory (tramp-compat-temporary-file-directory))
! (regexp (concat "^\\(" tramp-host-regexp
! "\\)\\.ssh-\\(dss\\|rsa\\)\\.pub$"))
! (files (when (file-directory-p dirname) (directory-files dirname)))
! result)
! (while files
! (when (string-match regexp (car files))
! (push (list nil (match-string 1 (car files))) result))
! (setq files (cdr files)))
! result))
;;;###tramp-autoload
(defun tramp-parse-hosts (filename)
"Return a list of (user host) tuples allowed to access.
User is always nil."
! ;; On Windows, there are problems in completion when
! ;; `default-directory' is remote.
! (let ((default-directory (tramp-compat-temporary-file-directory))
! res)
! (when (file-readable-p filename)
! (with-temp-buffer
! (insert-file-contents filename)
! (goto-char (point-min))
! (while (not (eobp))
! (push (tramp-parse-hosts-group) res))))
! res))
(defun tramp-parse-hosts-group ()
"Return a (user host) tuple allowed to access.
User is always nil."
! (let ((result)
! (regexp
! (concat "^\\(" tramp-ipv6-regexp "\\|" tramp-host-regexp "\\)")))
! (narrow-to-region (point) (point-at-eol))
! (when (re-search-forward regexp nil t)
! (setq result (list nil (match-string 1))))
! (widen)
! (or
! (> (skip-chars-forward " \t") 0)
! (forward-line 1))
! result))
;; For su-alike methods it would be desirable to return "address@hidden"
;; as default. Unfortunately, we have no information whether any user name
--- 2441,2502 ----
(defun tramp-parse-shosts (filename)
"Return a list of (user host) tuples allowed to access.
User is always nil."
! (tramp-parse-sfile filename 'tramp-parse-shosts-group))
(defun tramp-parse-shosts-group ()
"Return a (user host) tuple allowed to access.
User is always nil."
! (tramp-parse-sgroup
! (concat "^\\(" tramp-host-regexp "\\)") 1 ","))
;;;###tramp-autoload
(defun tramp-parse-sconfig (filename)
"Return a list of (user host) tuples allowed to access.
User is always nil."
! (tramp-parse-sfile filename 'tramp-parse-sconfig-group))
(defun tramp-parse-sconfig-group ()
"Return a (user host) tuple allowed to access.
User is always nil."
! (tramp-parse-sgroup
! (concat "^[ \t]*Host[ \t]+" "\\(" tramp-host-regexp "\\)") 1 ","))
! ;; Generic function
! (defun tramp-parse-shostkeys-sknownhosts (dirname regexp)
"Return a list of (user host) tuples allowed to access.
User is always nil."
;; On Windows, there are problems in completion when
;; `default-directory' is remote.
(let* ((default-directory (tramp-compat-temporary-file-directory))
! (files (and (file-directory-p dirname) (directory-files dirname))))
! (loop for f in files when (string-match regexp f) collect
! (list nil (match-string 1 f)))))
!
! ;;;###tramp-autoload
! (defun tramp-parse-shostkeys (dirname)
! "Return a list of (user host) tuples allowed to access.
! User is always nil."
! (tramp-parse-shostkeys-sknownhosts
! dirname (concat "^key_[0-9]+_\\(" tramp-host-regexp "\\)\\.pub$")))
(defun tramp-parse-sknownhosts (dirname)
"Return a list of (user host) tuples allowed to access.
User is always nil."
! (tramp-parse-shostkeys-sknownhosts
! dirname (regexp (concat "^\\(" tramp-host-regexp
! "\\)\\.ssh-\\(dss\\|rsa\\)\\.pub$"))))
;;;###tramp-autoload
(defun tramp-parse-hosts (filename)
"Return a list of (user host) tuples allowed to access.
User is always nil."
! (tramp-parse-sfile filename 'tramp-parse-hosts-group))
(defun tramp-parse-hosts-group ()
"Return a (user host) tuple allowed to access.
User is always nil."
! (tramp-parse-sgroup
! (concat "^\\(" tramp-ipv6-regexp "\\|" tramp-host-regexp "\\)") 1 " \t"))
;; For su-alike methods it would be desirable to return "address@hidden"
;; as default. Unfortunately, we have no information whether any user name
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
Re: hang forever with an invalid tramp filename, Michael Albinus, 2011/11/07