diff --git a/ordo/connection/ssh.scm b/ordo/connection/ssh.scm index bb3635d..d06e7f7 100644 --- a/ordo/connection/ssh.scm +++ b/ordo/connection/ssh.scm @@ -23,10 +23,10 @@ this program. If not, see . #:use-module (ssh channel) #:use-module (ssh auth) #:use-module (ssh popen) - #:use-module (ssh sftp) #:use-module (ordo connection base) #:use-module (ordo connection sudo) #:use-module (ordo util read-lines) + #:use-module (ordo util shell-quote) #:export ()) (define-class () @@ -64,7 +64,8 @@ this program. If not, see . (userauth-password! s (ssh-connection-password c)) (userauth-public-key/auto! s)))) (unless (equal? 'success user-auth) - (error (format #f "userauth: ~a" user-auth))))))) + (error (format #f "userauth: ~a" user-auth)))))) + (next-method)) (define-method (remote-exec (c ) (command )) (let* ((channel (open-remote-input-pipe (slot-ref c 'session) command)) @@ -73,18 +74,20 @@ this program. If not, see . (close channel) (values output exit-status))) -(define-method (sftp-session (c )) - (unless (slot-bound? c 'sftp-session) - (slot-set! c 'sftp-session (make-sftp-session (session c)))) - (slot-ref c 'sftp-session)) - (define-method (with-remote-input-file (c ) (filename ) (proc )) - (call-with-remote-input-file (sftp-session c) filename proc)) + (let* ((channel (open-remote-input-pipe (slot-ref c 'session) (string-append "cat " (string-shell-quote filename)))) + (result (proc channel))) + (close channel) + result)) (define-method (with-remote-output-file (c ) (filename ) (proc )) - (call-with-remote-output-file (sftp-session c) filename proc)) + (let* ((channel (open-remote-output-pipe (slot-ref c 'session) (string-append "cat >" (string-shell-quote filename)))) + (result (proc channel))) + (close channel) + result)) (define-method (teardown (c )) + (next-method) (when (slot-bound? c 'session) (let ((s (slot-ref c 'session))) (when (connected? s) diff --git a/ordo/connection/sudo.scm b/ordo/connection/sudo.scm index 60a95c0..0caac17 100644 --- a/ordo/connection/sudo.scm +++ b/ordo/connection/sudo.scm @@ -51,10 +51,10 @@ this program. If not, see . (next-method)) ((and (become-user conn) (become-password conn)) - (format #f "cat ~a - | sudo -k -S -H -u ~a -- ~a" (string-shell-quote (password-tmp-file conn)) (string-shell-quote (become-user conn)) (next-method))) + (format #f "cat ~a | sudo -k -S -H -u ~a -- ~a" (string-shell-quote (password-tmp-file conn)) (string-shell-quote (become-user conn)) (next-method))) ((become-password conn) - (format #f "cat ~a - | sudo -k -S -H -- ~a" (string-shell-quote (password-tmp-file conn)) (next-method))) + (format #f "cat ~a | sudo -k -S -H -- ~a" (string-shell-quote (password-tmp-file conn)) (next-method))) ((become-user conn) (format #f "sudo -k -n -H -u ~a -- ~a" (string-shell-quote (become-user conn)) (next-method)))