From 4e0a4c107e4a2ee708e6e7a9f3edf189fe858f14 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 11 Mar 2022 15:27:00 -0700 Subject: replace ESCAPE-SH-TOKEN and ESCAPE-SH-COMMAND with new SH-ESCAPE Signed-off-by: Sean Whitton --- src/connection/chroot.lisp | 3 +-- src/connection/linux-namespace.lisp | 2 +- src/connection/shell-wrap.lisp | 4 ++-- src/connection/ssh.lisp | 2 +- src/connection/su.lisp | 3 +-- src/connection/sudo.lisp | 4 ++-- 6 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/connection') diff --git a/src/connection/chroot.lisp b/src/connection/chroot.lisp index aeae134..aae0ad5 100644 --- a/src/connection/chroot.lisp +++ b/src/connection/chroot.lisp @@ -145,8 +145,7 @@ should be the mount point, without the chroot's root prefixed.") (defmethod connection-shell-wrap ((connection shell-chroot-connection) cmd) (format nil "chroot ~A sh -c ~A" - (escape-sh-token (unix-namestring (slot-value connection 'into))) - (escape-sh-token cmd))) + (sh-escape (slot-value connection 'into)) (sh-escape cmd))) (defmethod connection-teardown :before ((connection shell-chroot-connection)) (dolist (mount (chroot-mounts connection)) diff --git a/src/connection/linux-namespace.lisp b/src/connection/linux-namespace.lisp index 498cad9..a6f2e0a 100644 --- a/src/connection/linux-namespace.lisp +++ b/src/connection/linux-namespace.lisp @@ -84,7 +84,7 @@ (format nil "nsenter ~@[-S ~D ~]~@[-G ~D ~]-at ~D env -i ~{~A~^ ~} sh -c ~A" - uid gid pid (mapcar #'escape-sh-token env) (escape-sh-token cmd)))) + uid gid pid (mapcar #'sh-escape env) (sh-escape cmd)))) (defmethod establish-connection ((type (eql :nsenter)) remaining &key name pid uid gid) diff --git a/src/connection/shell-wrap.lisp b/src/connection/shell-wrap.lisp index 49cfd83..2867e20 100644 --- a/src/connection/shell-wrap.lisp +++ b/src/connection/shell-wrap.lisp @@ -28,7 +28,7 @@ (defun %readfile (c path &optional delete) (multiple-value-bind (out exit) - (let* ((path (escape-sh-token path)) + (let* ((path (sh-escape path)) (base #?"test -r ${path} && cat ${path}") (cmd (if delete (strcat base #?" && rm ${path}") base))) (connection-run c cmd nil)) @@ -57,7 +57,7 @@ mv \"$tmpf\" ~A" (mkstemp-cmd (merge-pathnames "tmp.XXXXXX" (pathname-directory-pathname path))) mode - (escape-sh-token (unix-namestring path))))) + (sh-escape path)))) (multiple-value-bind (out exit) (connection-run conn cmd content) (unless (zerop exit) (error "Failed to write ~A: ~A" path out))))) diff --git a/src/connection/ssh.lisp b/src/connection/ssh.lisp index f4d30cc..1154578 100644 --- a/src/connection/ssh.lisp +++ b/src/connection/ssh.lisp @@ -46,4 +46,4 @@ ;; wrap in 'sh -c' in case the login shell is not POSIX (format nil "ssh ~A ~A" (ssh-host connection) - (escape-sh-token (format nil "sh -c ~A" (escape-sh-token cmd))))) + (sh-escape (format nil "sh -c ~A" (sh-escape cmd))))) diff --git a/src/connection/su.lisp b/src/connection/su.lisp index 785302f..bd6657f 100644 --- a/src/connection/su.lisp +++ b/src/connection/su.lisp @@ -32,5 +32,4 @@ ;; argument to su(1) on, e.g., FreeBSD. So this should be fairly portable. (defmethod connection-shell-wrap ((connection su-connection) cmd) (format nil "su ~A -c ~A" - (escape-sh-token (slot-value connection 'user)) - (escape-sh-token cmd))) + (sh-escape (slot-value connection 'user)) (sh-escape cmd))) diff --git a/src/connection/sudo.lisp b/src/connection/sudo.lisp index da50673..486c8eb 100644 --- a/src/connection/sudo.lisp +++ b/src/connection/sudo.lisp @@ -79,7 +79,7 @@ (user (connection-connattr connection :remote-user)) (prefix (if file (format nil "cat ~A - | sudo -HkS --prompt=\"\"" - (escape-sh-token file)) + (sh-escape file)) "sudo -Hkn"))) ;; Wrap in sh -c so that it is more likely we are either asked for a ;; password for all our commands or not asked for one for any. @@ -94,4 +94,4 @@ (mrun :may-fail :input input (format nil "~A ~:[~;--preserve-env=SSH_AUTH_SOCK ~]--user=~A sh -c ~A" - prefix (string= user "root") user (escape-sh-token cmd))))) + prefix (string= user "root") user (sh-escape cmd))))) -- cgit v1.2.3