diff options
author | David Bremner <david@tethera.net> | 2021-03-13 13:08:46 -0400 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-13 10:12:32 -0700 |
commit | 83e7d2b1b90c29180d4ed1ea5977b5782b093734 (patch) | |
tree | 8c8aaf16256845147f8541ef4cec6308d508a36d | |
parent | 9f865d9016508bcef48b921ce9998a4943b0e97f (diff) | |
download | consfigurator-83e7d2b1b90c29180d4ed1ea5977b5782b093734.tar.gz |
Add user property, modelled on apt property
Signed-off-by: David Bremner <david@tethera.net>
-rw-r--r-- | consfigurator.asd | 1 | ||||
-rw-r--r-- | src/package.lisp | 5 | ||||
-rw-r--r-- | src/property/user.lisp | 31 |
3 files changed, 37 insertions, 0 deletions
diff --git a/consfigurator.asd b/consfigurator.asd index f4a8b9a..f269261 100644 --- a/consfigurator.asd +++ b/consfigurator.asd @@ -30,5 +30,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 d70ef4a..c0da43f 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -221,6 +221,11 @@ #:mirror #:standard-sources.list)) +(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@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))) |