aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-06-08 13:24:51 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-06-08 13:24:51 -0700
commit14b86639825699489ac1c18700da12f593f41188 (patch)
tree79055fbc98bc890be5358bffb14c8cbeb8ded79d
parent463654cf07b06cab40d6b4a08ed6a6a456850fbe (diff)
downloadconsfigurator-14b86639825699489ac1c18700da12f593f41188.tar.gz
add FILE:HAS-OWNERSHIP
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--src/package.lisp1
-rw-r--r--src/property/file.lisp13
2 files changed, 14 insertions, 0 deletions
diff --git a/src/package.lisp b/src/package.lisp
index ba500ef..daf1604 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -283,6 +283,7 @@
#:contains-lines
#:lacks-lines
#:has-mode
+ #:has-ownership
#:does-not-exist
#:directory-does-not-exist
#:data-uploaded
diff --git a/src/property/file.lisp b/src/property/file.lisp
index 4ee33e6..214b69f 100644
--- a/src/property/file.lisp
+++ b/src/property/file.lisp
@@ -68,6 +68,19 @@ CONTENT can be a list of lines or a single string."
(with-change-if-changes-file (path)
(mrun (format nil "chmod ~O ~A" mode path)))))
+(defprop has-ownership :posix (path &key user group)
+ "Ensure that a file has particular ownership and group ownership."
+ (:desc (format nil "~A has~:[~; owner ~:*~A~]~:[~;~2:*~:[~;,~] group ~A~]"
+ path user group))
+ (:hostattrs
+ (unless (or user group)
+ (inapplicable-property "Not enough arguments.")))
+ (:apply
+ (with-change-if-changes-file (path)
+ (if user
+ (mrun "chown" "-h" (format nil "~A~:[~;:~:*~A~]" user group) path)
+ (mrun "chgrp" "-h" group path)))))
+
(defprop does-not-exist :posix (&rest paths)
"Ensure that files do not exist."
(:desc (if (cdr paths)