diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-06 15:02:28 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-06 15:57:19 -0700 |
commit | 17a990340aa1e77b4b2b890032aa171e407739ad (patch) | |
tree | 80f8ef247888df066f34a4f111977e483e15f7d2 /src/connection/shell-wrap.lisp | |
parent | c10312f2f603b0be1d82fbcb7bded518f4111810 (diff) | |
download | consfigurator-17a990340aa1e77b4b2b890032aa171e407739ad.tar.gz |
CONNECTION-WRITEFILE: deal in modes rather than umasks
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/connection/shell-wrap.lisp')
-rw-r--r-- | src/connection/shell-wrap.lisp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/connection/shell-wrap.lisp b/src/connection/shell-wrap.lisp index 99d1735..345a59d 100644 --- a/src/connection/shell-wrap.lisp +++ b/src/connection/shell-wrap.lisp @@ -33,16 +33,19 @@ (defmethod connection-writefile ((conn shell-wrap-connection) path - contents - umask) - ;; TODO do we want a CONNECTION-ERROR condition? - (with-remote-temporary-file (temp :connection conn) + content + mode) + (with-remote-temporary-file + (temp :connection conn :directory (pathname-directory-pathname path)) + ;; TODO do we want a CONNECTION-ERROR condition to tidy this up? (multiple-value-bind (out exit) - (connection-run conn (if umask - (format nil "( umask ~O; cat >~A )" - umask temp) - #?"cat >${temp}") - contents) + (connection-run conn + (format nil "chmod ~O ~A" mode + (escape-sh-token temp)) + nil) + (unless (zerop exit) (error "Failed to chmod ~A: ~A" temp out))) + (multiple-value-bind (out exit) + (connection-run conn #?"cat >${temp}" content) (unless (zerop exit) (error "Failed to write ~A: ~A" temp out))) (multiple-value-bind (out exit) (connection-run |