[PATCH consfigurator 3/3] Add user property, modelled on apt property
David Bremner
david at tethera.net
Thu Mar 11 02:21:07 GMT 2021
Signed-off-by: David Bremner <david at tethera.net>
---
consfigurator.asd | 1 +
src/package.lisp | 5 +++++
src/property/user.lisp | 31 +++++++++++++++++++++++++++++++
3 files changed, 37 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 4098e49..ace7440 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -209,6 +209,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..48ac810
--- /dev/null
+++ b/src/property/user.lisp
@@ -0,0 +1,31 @@
+;;; 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}")
+ (:check
+ (user-exists user-name))
+ (:apply
+ (assert-euid-root)
+ (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