aboutsummaryrefslogtreecommitdiff
path: root/src/connection/sudo.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-02-22 08:47:41 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-02-22 08:47:41 -0700
commit9f941b0d27c0892a6aa7481c26dd6f67981736f9 (patch)
tree10ce61f963cb7234bd55d03ba48140554e90a7ab /src/connection/sudo.lisp
parentea7cdaf4506e59df67d046254ca8fbc86d8ecb6d (diff)
downloadconsfigurator-9f941b0d27c0892a6aa7481c26dd6f67981736f9.tar.gz
handle both possible values of INPUT
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/connection/sudo.lisp')
-rw-r--r--src/connection/sudo.lisp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/connection/sudo.lisp b/src/connection/sudo.lisp
index ec372a1..f97f03b 100644
--- a/src/connection/sudo.lisp
+++ b/src/connection/sudo.lisp
@@ -71,17 +71,19 @@
(defmethod connection-run ((c sudo-connection) cmd &optional input)
;; send the password followed by ^M, then the real stdin. use CODE-CHAR in
;; this way so that we can be sure ASCII ^M is what will get emitted.
- (let* ((password (slot-value c 'password))
+ (let* ((input-stream
+ (if (streamp input) input (make-string-input-stream input)))
+ (password (slot-value c 'password))
(password-stream (and password
(make-string-input-stream
(format nil "~A~A" password (code-char 13)))))
(new-input (cond
((and password input)
- (make-concatenated-stream password-stream input))
+ (make-concatenated-stream password-stream input-stream))
(password
password-stream)
(input
- (make-string-input-stream input))
+ input-stream)
(t
nil))))
(run :input new-input (sudocmd c cmd))))