/[tramp]/tramp/lisp/tramp.el
ViewVC logotype

Diff of /tramp/lisp/tramp.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2.144 by kai, Fri Jul 26 20:26:21 2002 UTC revision 2.145 by kai, Sat Jul 27 12:21:55 2002 UTC
# Line 2616  This is like `dired-recursive-delete-dir Line 2616  This is like `dired-recursive-delete-dir
2616  (defun tramp-handle-insert-directory  (defun tramp-handle-insert-directory
2617    (filename switches &optional wildcard full-directory-p)    (filename switches &optional wildcard full-directory-p)
2618    "Like `insert-directory' for tramp files."    "Like `insert-directory' for tramp files."
2619      (setq filename (expand-file-name filename))
2620    (with-parsed-tramp-file-name filename nil    (with-parsed-tramp-file-name filename nil
2621      (when (tramp-ange-ftp-file-name-p multi-method method)      (when (tramp-ange-ftp-file-name-p multi-method method)
2622        (tramp-invoke-ange-ftp 'insert-directory        (tramp-invoke-ange-ftp 'insert-directory
# Line 3719  Maybe the different regular expressions Line 3720  Maybe the different regular expressions
3720               (found nil)               (found nil)
3721               (pw nil))               (pw nil))
3722          (process-kill-without-query p)          (process-kill-without-query p)
3723          (tramp-message 9 "Waiting for login prompt...")          (set-buffer (tramp-get-buffer multi-method method user host))
3724          (unless (tramp-wait-for-regexp p nil tramp-login-prompt-regexp)          (erase-buffer)
3725            (pop-to-buffer (buffer-name))          (tramp-process-actions multi-method method user host
3726            (kill-process p)                                 tramp-actions-before-shell)
3727            (error "Couldn't find remote login prompt"))  
3728          (erase-buffer)  ;;         (tramp-message 9 "Waiting for login prompt...")
3729          ;; Remote login defaults to local one.  ;;         (unless (tramp-wait-for-regexp p nil tramp-login-prompt-regexp)
3730          (tramp-message 9 "Sending login name %s" (or user (user-login-name)))  ;;           (pop-to-buffer (buffer-name))
3731          (process-send-string p (concat (or user (user-login-name))  ;;           (kill-process p)
3732                                         tramp-rsh-end-of-line))  ;;           (error "Couldn't find remote login prompt"))
3733          (tramp-message 9 "Waiting for password prompt...")  ;;         (erase-buffer)
3734          (unless (setq found (tramp-wait-for-regexp  ;;         ;; Remote login defaults to local one.
3735                               p nil tramp-password-prompt-regexp))  ;;         (tramp-message 9 "Sending login name %s" (or user (user-login-name)))
3736            (pop-to-buffer (buffer-name))  ;;         (process-send-string p (concat (or user (user-login-name))
3737            (kill-process p)  ;;                                        tramp-rsh-end-of-line))
3738            (error "Couldn't find remote password prompt"))  ;;         (tramp-message 9 "Waiting for password prompt...")
3739          (erase-buffer)  ;;         (unless (setq found (tramp-wait-for-regexp
3740          (setq pw (tramp-read-passwd (car found)))  ;;                              p nil tramp-password-prompt-regexp))
3741          (tramp-message 9 "Sending password")  ;;           (pop-to-buffer (buffer-name))
3742          (process-send-string p (concat pw tramp-rsh-end-of-line))  ;;           (kill-process p)
3743          (tramp-message 9 "Waiting 30s for remote shell to come up...")  ;;           (error "Couldn't find remote password prompt"))
3744          (unless (setq found  ;;         (erase-buffer)
3745                        (tramp-wait-for-regexp  ;;         (setq pw (tramp-read-passwd (car found)))
3746                         p 30 (format "\\(%s\\)\\|\\(%s\\)\\'"  ;;         (tramp-message 9 "Sending password")
3747                                      tramp-wrong-passwd-regexp  ;;         (process-send-string p (concat pw tramp-rsh-end-of-line))
3748                                      shell-prompt-pattern)))  ;;         (tramp-message 9 "Waiting 30s for remote shell to come up...")
3749            (pop-to-buffer (buffer-name))  ;;         (unless (setq found
3750            (kill-process p)  ;;                       (tramp-wait-for-regexp
3751            (error "Couldn't find remote shell prompt"))  ;;                        p 30 (format "\\(%s\\)\\|\\(%s\\)\\'"
3752          (when (nth 1 found)  ;;                                     tramp-wrong-passwd-regexp
3753            (pop-to-buffer (buffer-name))  ;;                                     shell-prompt-pattern)))
3754            (kill-process p)  ;;           (pop-to-buffer (buffer-name))
3755            (error "Login failed: %s" (nth 1 found)))  ;;           (kill-process p)
3756    ;;           (error "Couldn't find remote shell prompt"))
3757    ;;         (when (nth 1 found)
3758    ;;           (pop-to-buffer (buffer-name))
3759    ;;           (kill-process p)
3760    ;;           (error "Login failed: %s" (nth 1 found)))
3761    
3762          (tramp-open-connection-setup-interactive-shell          (tramp-open-connection-setup-interactive-shell
3763           p multi-method method user host)           p multi-method method user host)
3764          (tramp-post-connection multi-method method user host)))))          (tramp-post-connection multi-method method user host)))))
3765    
3766    (defvar tramp-actions-before-shell
3767      '((tramp-password-prompt-regexp tramp-action-password)
3768        (tramp-login-prompt-regexp tramp-action-login)
3769        (shell-prompt-pattern tramp-action-succeed)
3770        (tramp-wrong-passwd-regexp tramp-action-permission-denied))
3771      "List of pattern/action pairs.
3772    Whenever a pattern matches, the corresponding action is performed.
3773    Each item looks like (PATTERN ACTION).
3774    
3775    The PATTERN should be a symbol, a variable.  The value of this
3776    variable gives the regular expression to search for.  Note that the
3777    regexp must match at the end of the buffer, \"\\'\" is implicitly
3778    appended to it.
3779    
3780    The ACTION should also be a symbol, but a function.  When the
3781    corresponding PATTERN matches, the ACTION function is called.")
3782    
3783    (defun tramp-action-login (multi-method method user host)
3784      "Send the login name."
3785      (tramp-message 9 "Sending login name `%s'"
3786                     (or user (user-login-name)))
3787      (process-send-string nil (concat (or user (user-login-name))
3788                                       tramp-rsh-end-of-line)))
3789    
3790    (defun tramp-action-password (multi-method method user host)
3791      "Query the user for a password."
3792      (when (tramp-method-out-of-band-p multi-method method)
3793        (kill-process (get-buffer-process (current-buffer)))
3794        (error (concat "Out of band method `%s' not applicable "
3795                       "for remote shell asking for a password")
3796               method))
3797      (tramp-enter-password (match-string 0)))
3798    
3799    (defun tramp-action-succeed (multi-method method user host)
3800      "Signal success in finding shell prompt."
3801      (tramp-message 9 "Found remote shell prompt.")
3802      (throw 'tramp-action 'ok))
3803    
3804    (defun tramp-action-permission-denied (multi-method method user host)
3805      "Signal permission denied."
3806      (tramp-message 9 "Permission denied by remote host.")
3807      (kill-process (get-buffer-process (current-buffer)))
3808      (throw 'tramp-action 'permission-denied))
3809    
3810    (defun tramp-process-one-action (multi-method method user host actions)
3811      "Wait for output from the shell and perform one action."
3812      (let (found item pattern action)
3813        (erase-buffer)
3814        (tramp-message 9 "Waiting 60s for prompt from remote shell")
3815        (with-timeout (60 (throw 'tramp-action 'timeout))
3816          (while (not found)
3817            (accept-process-output nil 1)
3818            (goto-char (point-min))
3819            (while actions
3820              (setq item (pop actions))
3821              (setq pattern (symbol-value (nth 0 item)))
3822              (setq action (nth 1 item))
3823              (when (re-search-forward (concat pattern "\\'") nil t)
3824                (setq found (funcall action multi-method method user host)))))
3825          found)))
3826    
3827    (defun tramp-process-actions (multi-method method user host actions)
3828      "Perform actions until success."
3829      (let (exit)
3830        (while (not exit)
3831          (setq exit
3832                (catch 'tramp-action
3833                  (tramp-process-one-action multi-method method user host actions)
3834                  nil)))
3835        (unless (eq exit 'ok)
3836          (error "Login failed"))))
3837                
3838  ;; HHH: Changed to handle the case when USER is nil.  ;; HHH: Changed to handle the case when USER is nil.
3839  (defun tramp-open-connection-rsh (multi-method method user host)  (defun tramp-open-connection-rsh (multi-method method user host)
3840    "Open a connection using an rsh METHOD.    "Open a connection using an rsh METHOD.
# Line 3811  arguments, and xx will be used as the ho Line 3890  arguments, and xx will be used as the ho
3890                           host rsh-args)))                           host rsh-args)))
3891               (found nil))               (found nil))
3892          (process-kill-without-query p)          (process-kill-without-query p)
3893          (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host)  
3894          (setq found          (set-buffer buf)
3895                (tramp-wait-for-regexp          (tramp-process-actions multi-method method user host
3896                 p 60                                 tramp-actions-before-shell)
3897                 (format  
3898                  "\\(%s\\)\\|\\(%s\\)\\'"  ;;         (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host)
3899                  tramp-password-prompt-regexp  ;;         (setq found
3900                  shell-prompt-pattern)))  ;;               (tramp-wait-for-regexp
3901          (unless found  ;;                p 60
3902            (pop-to-buffer (buffer-name))  ;;                (format
3903            (kill-process p)  ;;                 "\\(%s\\)\\|\\(%s\\)\\'"
3904            (error "Couldn't find remote shell or passwd prompt"))  ;;                 tramp-password-prompt-regexp
3905          (when (nth 1 found)  ;;                 shell-prompt-pattern)))
3906            (when (tramp-method-out-of-band-p multi-method method)  ;;         (unless found
3907              (pop-to-buffer (buffer-name))  ;;           (pop-to-buffer (buffer-name))
3908              (kill-process p)  ;;           (kill-process p)
3909              (error (concat "Out of band method `%s' not applicable"  ;;           (error "Couldn't find remote shell or passwd prompt"))
3910                             " for remote shell asking for a password")  ;;         (when (nth 1 found)
3911                     method))  ;;           (when (tramp-method-out-of-band-p multi-method method)
3912            (erase-buffer)  ;;             (pop-to-buffer (buffer-name))
3913            (tramp-message 9 "Sending password...")  ;;             (kill-process p)
3914            (tramp-enter-password p (nth 1 found))  ;;             (error (concat "Out of band method `%s' not applicable"
3915            (tramp-message 9 "Sent password, waiting 60s for remote shell prompt")  ;;                            " for remote shell asking for a password")
3916            (setq found (tramp-wait-for-regexp p 60  ;;                    method))
3917                                               (format "\\(%s\\)\\|\\(%s\\)\\'"  ;;           (erase-buffer)
3918                                                       tramp-wrong-passwd-regexp  ;;           (tramp-message 9 "Sending password...")
3919                                                       shell-prompt-pattern))))  ;;           (tramp-enter-password p (nth 1 found))
3920          (unless found  ;;           (tramp-message 9 "Sent password, waiting 60s for remote shell prompt")
3921            (pop-to-buffer (buffer-name))  ;;           (setq found (tramp-wait-for-regexp p 60
3922            (kill-process p)  ;;                                              (format "\\(%s\\)\\|\\(%s\\)\\'"
3923            (error "Couldn't find remote shell prompt"))  ;;                                                      tramp-wrong-passwd-regexp
3924          (when (nth 1 found)  ;;                                                      shell-prompt-pattern))))
3925            (pop-to-buffer (buffer-name))  ;;         (unless found
3926            (kill-process p)  ;;           (pop-to-buffer (buffer-name))
3927            (error "Login failed: %s" (nth 1 found)))  ;;           (kill-process p)
3928    ;;           (error "Couldn't find remote shell prompt"))
3929    ;;         (when (nth 1 found)
3930    ;;           (pop-to-buffer (buffer-name))
3931    ;;           (kill-process p)
3932    ;;           (error "Login failed: %s" (nth 1 found)))
3933    
3934          (tramp-message 7 "Initializing remote shell")          (tramp-message 7 "Initializing remote shell")
3935          (tramp-open-connection-setup-interactive-shell          (tramp-open-connection-setup-interactive-shell
3936           p multi-method method user host)           p multi-method method user host)

Legend:
Removed from v.2.144  
changed lines
  Added in v.2.145

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26