aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2022-06-24 10:50:08 -0300
committerSean Whitton <spwhitton@spwhitton.name>2022-06-24 14:15:56 -0700
commit6ceda7ecff3e6b8e8a661ae20b8c2ca09363e2c9 (patch)
treee8efccbcee9bb8b85cd80c2cd05d86673b099db7
parent1a19be7ea65fbfa0b192b2bf18a735f230f16675 (diff)
downloadconsfigurator-6ceda7ecff3e6b8e8a661ae20b8c2ca09363e2c9.tar.gz
add USER:GROUP-EXISTS
This is essentially a copy of HAS-ACCOUNT, with the equivalent of USER-EXISTS inlined. Signed-off-by: David Bremner <david@tethera.net>
-rw-r--r--src/package.lisp1
-rw-r--r--src/property/user.lisp10
2 files changed, 11 insertions, 0 deletions
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."