aboutsummaryrefslogtreecommitdiff
path: root/src/connection
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-03-11 15:27:00 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-03-11 16:40:08 -0700
commit4e0a4c107e4a2ee708e6e7a9f3edf189fe858f14 (patch)
treeb8e51af43f895a98ebd943580c51c1da38151bdf /src/connection
parentf2ba47b7ef017a01a4b6c13982ff43a67cc6abd5 (diff)
downloadconsfigurator-4e0a4c107e4a2ee708e6e7a9f3edf189fe858f14.tar.gz
replace ESCAPE-SH-TOKEN and ESCAPE-SH-COMMAND with new SH-ESCAPE
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/connection')
-rw-r--r--src/connection/chroot.lisp3
-rw-r--r--src/connection/linux-namespace.lisp2
-rw-r--r--src/connection/shell-wrap.lisp4
-rw-r--r--src/connection/ssh.lisp2
-rw-r--r--src/connection/su.lisp3
-rw-r--r--src/connection/sudo.lisp4
6 files changed, 8 insertions, 10 deletions
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)))))