aboutsummaryrefslogtreecommitdiff
path: root/src/property/user.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-06-18 10:02:17 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-06-18 10:02:17 -0700
commit326542be481a5bbc63df4ed0238a7a384ce13232 (patch)
treed2774d5c77b0c3149dac9f53605cca56861b8669 /src/property/user.lisp
parent92f58e96e1edc9bc3944cb87d0ee5d3a94157824 (diff)
downloadconsfigurator-326542be481a5bbc63df4ed0238a7a384ce13232.tar.gz
add USER:HAS-DESKTOP-GROUPS
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property/user.lisp')
-rw-r--r--src/property/user.lisp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/property/user.lisp b/src/property/user.lisp
index 9f7f13b..be7ca36 100644
--- a/src/property/user.lisp
+++ b/src/property/user.lisp
@@ -41,6 +41,25 @@ Note that this uses getent(1) and so is not strictly POSIX-compatible."
(assert-euid-root)
(mrun "usermod" "-a" "-G" groups* username)))
+(defparameter *desktop-groups*
+ '("audio" "cdrom" "dip" "floppy" "video" "plugdev" "netdev" "scanner"
+ "bluetooth" "debian-tor" "lpadmin")
+ "See the debconf template passwd/user-default-groups for package user-setup.")
+
+(defprop has-desktop-groups :posix (username)
+ "Add user to the secondary groups to which the OS installer normally adds the
+default account it creates. Skips over groups which do not exist yet, pending
+the installation of other software."
+ (:desc #?"${username} is in standard desktop groups")
+ (:hostattrs (os:required 'os:debianlike))
+ (:apply
+ (let ((existing-groups
+ (loop for line in (lines (readfile "/etc/group"))
+ collect (car (split-string line :separator ":")))))
+ (apply #'has-groups username (loop for group in *desktop-groups*
+ when (memstring= group existing-groups)
+ collect group)))))
+
(defprop has-login-shell :posix (username shell)
"Ensures that USERNAME has login shell SHELL.
Note that this uses getent(1) and so is not strictly POSIX-compatible."