[PATCH consfigurator] Add user property, modelled on apt property

David Bremner david at tethera.net
Sun Mar 7 19:28:45 GMT 2021


Signed-off-by: David Bremner <david at tethera.net>
---
 consfigurator.asd      |  1 +
 src/package.lisp       |  5 +++++
 src/property/user.lisp | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+)
 create mode 100644 src/property/user.lisp

diff --git a/consfigurator.asd b/consfigurator.asd
index 6f29d8b..7e063f2 100644
--- a/consfigurator.asd
+++ b/consfigurator.asd
@@ -29,5 +29,6 @@
 	       (:file "src/property/os")
 	       (:file "src/property/apt")
 	       (:file "src/property/chroot")
+	       (:file "src/property/user")
 	       (:file "src/data/asdf")
 	       (:file "src/data/pgp")))
diff --git a/src/package.lisp b/src/package.lisp
index 8b0d0eb..ca1ff10 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -207,6 +207,11 @@
 		    (#:os  #:consfigurator.property.os))
   (:export #:installed))
 
+(defpackage :consfigurator.property.user
+  (:use #:cl #:consfigurator)
+  (:local-nicknames (#:os  #:consfigurator.property.os))
+  (:export #:has-account))
+
 (defpackage :consfigurator.data.asdf
   (:use #:cl #:consfigurator))
 
diff --git a/src/property/user.lisp b/src/property/user.lisp
new file mode 100644
index 0000000..fdca269
--- /dev/null
+++ b/src/property/user.lisp
@@ -0,0 +1,33 @@
+;;; Consfigurator -- Lisp declarative configuration management system
+
+;;; Copyright (C) 2021  David Bremner <david at tethera.net>
+
+;;; This file is free software; you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3, or (at your option)
+;;; any later version.
+
+;;; This file is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+(in-package :consfigurator.property.user)
+(named-readtables:in-readtable :interpol-syntax)
+
+(defprop has-account :posix (user-name)
+  "ensure there is an account for USER-NAME."
+  (:desc #?"account for ${user-name}")
+  (:hostattrs
+   (declare (ignore user-name))
+   (os:required 'os:unixlike))
+  (:check
+   (user-exists user-name))
+  (:apply
+   (run "useradd" "-m" user-name)))
+
+(defun user-exists (user-name)
+  (zerop (run :for-exit "getent" "passwd" user-name)))
-- 
2.30.1




More information about the sgo-software-discuss mailing list