aboutsummaryrefslogtreecommitdiff
path: root/src/property/user.lisp
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-03-13 13:08:46 -0400
committerSean Whitton <spwhitton@spwhitton.name>2021-03-13 10:12:32 -0700
commit83e7d2b1b90c29180d4ed1ea5977b5782b093734 (patch)
tree8c8aaf16256845147f8541ef4cec6308d508a36d /src/property/user.lisp
parent9f865d9016508bcef48b921ce9998a4943b0e97f (diff)
downloadconsfigurator-83e7d2b1b90c29180d4ed1ea5977b5782b093734.tar.gz
Add user property, modelled on apt property
Signed-off-by: David Bremner <david@tethera.net>
Diffstat (limited to 'src/property/user.lisp')
-rw-r--r--src/property/user.lisp31
1 files changed, 31 insertions, 0 deletions
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@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)))