[PATCH consfigurator] add user:group-exists
David Bremner
david at tethera.net
Fri Jun 24 14:50:08 BST 2022
This is essentially a copy of has-account, with the equivalent of
USER-EXISTS inlined.
Signed-off-by: David Bremner <david at tethera.net>
---
src/package.lisp | 1 +
src/property/user.lisp | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/src/package.lisp b/src/package.lisp
index a8b298e..c65b04b 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -558,6 +558,7 @@
(#:os #:consfigurator.property.os))
(:export #:has-account
#:has-account-with-uid
+ #:group-exists
#:has-groups
#:has-desktop-groups
#:has-login-shell
diff --git a/src/property/user.lisp b/src/property/user.lisp
index 1dd9f1d..67190df 100644
--- a/src/property/user.lisp
+++ b/src/property/user.lisp
@@ -52,6 +52,16 @@ that group, and ~USERNAME and its contents are owned by UID:GID."
(has-account username)
(%has-uid-gid username uid gid))
+(defprop group-exists :posix (groupname)
+ "Ensure there is a group GROUPNAME.
+Note that this uses getent(1) and so is not strictly POSIX-compatible."
+ (:desc #?"Group ${groupname} exists")
+ (:check
+ (zerop (mrun :for-exit "getent" "group" groupname)))
+ (:apply
+ (assert-remote-euid-root)
+ (mrun "groupadd" groupname)))
+
(defprop has-groups :posix
(username &rest groups &aux (groups* (format nil "~{~A~^,~}" groups)))
"Ensure that USERNAME is a member of secondary groups GROUPS."
--
2.35.2
More information about the sgo-software-discuss
mailing list