From 14b86639825699489ac1c18700da12f593f41188 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 8 Jun 2021 13:24:51 -0700 Subject: add FILE:HAS-OWNERSHIP Signed-off-by: Sean Whitton --- src/property/file.lisp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/property/file.lisp') 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) -- cgit v1.2.3