aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-03-04 15:46:13 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-03-04 15:49:01 -0700
commitcebded4616c69a59767f2f19a071dfda0357d513 (patch)
treefb89edf3b94b34479c16af928ba39bda8f6bc499
parente7d9644ee17d2ab80f19bee07ed775e130c5a645 (diff)
downloadconsfigurator-cebded4616c69a59767f2f19a071dfda0357d513.tar.gz
add SECRET-UPLOADED and HOST-SECRET-UPLOADED
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--src/package.lisp2
-rw-r--r--src/property/file.lisp16
2 files changed, 18 insertions, 0 deletions
diff --git a/src/package.lisp b/src/package.lisp
index 6bb1824..323af1c 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -181,6 +181,8 @@
#:contains-lines
#:data-uploaded
#:host-data-uploaded
+ #:secret-uploaded
+ #:host-secret-uploaded
#:regex-replaced-lines))
(defpackage :consfigurator.data.asdf
diff --git a/src/property/file.lisp b/src/property/file.lisp
index 9516f7f..c398ace 100644
--- a/src/property/file.lisp
+++ b/src/property/file.lisp
@@ -55,6 +55,22 @@ point in doing that here because WRITEFILE is synchronous."
(:apply
(data-uploaded (get-hostname) destination destination)))
+(defprop secret-uploaded :posix (iden1 iden2 destination)
+ (:hostattrs
+ (declare (ignore destination))
+ (require-data iden1 iden2))
+ (:apply
+ (when (test "-e" destination)
+ (mrun "chmod" "600" destination))
+ (writefile destination (get-data-stream iden1 iden2)
+ :try-preserve t :umask #o077)))
+
+(defprop host-secret-uploaded :posix (destination)
+ (:hostattrs
+ (require-data (get-hostname) destination))
+ (:apply
+ (secret-uploaded (get-hostname) destination destination)))
+
(defprop regex-replaced-lines :posix (file regex replace)
"Like s/REGEX/REPLACE/ on the lines of FILE.
Uses CL-PPCRE:REGEX-REPLACE, which see for the syntax of REPLACE."