aboutsummaryrefslogtreecommitdiff
path: root/src/connection/shell-wrap.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-02-26 22:54:11 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-02-27 13:39:52 -0700
commitdb2879636b809e34efc9397c19b646a2695beb51 (patch)
tree5ea4300b201553e34d845af7870deb4da23cda2f /src/connection/shell-wrap.lisp
parent2e1599f51c803560b6b9063fd8ae95d62a601b62 (diff)
downloadconsfigurator-db2879636b809e34efc9397c19b646a2695beb51.tar.gz
attempt to implement umask support for CONNECTION-WRITEFILE
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/connection/shell-wrap.lisp')
-rw-r--r--src/connection/shell-wrap.lisp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/connection/shell-wrap.lisp b/src/connection/shell-wrap.lisp
index 883757b..70d094c 100644
--- a/src/connection/shell-wrap.lisp
+++ b/src/connection/shell-wrap.lisp
@@ -31,10 +31,16 @@
(connection-run c #?"test -r ${path} && cat ${path}" nil))
(if (= 0 exit) out (error "File ~S not readable" path))))
-(defmethod connection-writefile ((conn shell-wrap-connection) path contents)
+(defmethod connection-writefile ((conn shell-wrap-connection)
+ path
+ contents
+ umask)
(with-remote-temporary-file (temp)
- (connection-run conn #?"cat >${temp}" contents)
- (connection-run
- conn
- #?"mv ${(escape-sh-token temp)} ${(escape-sh-token path)}"
- nil)))
+ (connection-run conn
+ (if umask
+ (format nil "( umask ~O; cat >~A )" umask temp)
+ #?"cat >${temp}")
+ contents)
+ (connection-run conn
+ #?"mv ${(escape-sh-token temp)} ${(escape-sh-token path)}"
+ nil)))