From 6ceda7ecff3e6b8e8a661ae20b8c2ca09363e2c9 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Fri, 24 Jun 2022 10:50:08 -0300 Subject: add USER:GROUP-EXISTS This is essentially a copy of HAS-ACCOUNT, with the equivalent of USER-EXISTS inlined. Signed-off-by: David Bremner --- 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." -- cgit v1.2.3