From beb39dddb30288154d785cfcd544ee11962b2635 Mon Sep 17 00:00:00 2001 From: Jean-Francois GUILLAUME Date: Wed, 23 Nov 2022 16:13:38 +0000 Subject: [PATCH] Devel --- glicid/services/authentication.scm | 91 ++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 glicid/services/authentication.scm diff --git a/glicid/services/authentication.scm b/glicid/services/authentication.scm new file mode 100644 index 0000000..23baa3f --- /dev/null +++ b/glicid/services/authentication.scm @@ -0,0 +1,91 @@ +(define-module (glicid services authentication) + #:use-module (gnu services) + #:use-module (gnu services shepherd) + #:use-module (guix) + #:use-module (guix records) + #:use-module (ice-9 match) + #:use-module (gnu packages sssd) + #:use-module (glicid system file-systems) + #:export ( + sssd-configuration + sssd-configuration? + sssd-service + sssd-service-type + ) +) + +(define-record-type* + sssd-configuration make-sssd-configuration sssd-configuration? + (sssd-pkg sssd-pkg + (default sssd) + ) + (sssd-conf sssd-conf + (default (file-append sssd-pkg "/lib/sssd/conf/sssd.conf")) + ) + (sssd-logger sssd-logger + (default "stderr") + ) + (sssd-debug-level sssd-debug-level + (default "") + ) + (log-file log-file + (default "/var/log/sssd/sssd.log") + ) +) + +(define sssd-service + (match-lambda + (($ sssd-pkg sssd-conf sssd-logger sssd-debug-level log-file) + (list + (shepherd-service + (provision '(sssd) ) + (documentation "Run sssd.") + (requirement '( + user-processes + )) + (respawn? #t) + (start #~(make-forkexec-constructor + (list + #$(file-append sssd-pkg "/sbin/sssd") + "--interactive" + (list (string-append "--config=" sssd-conf)) + (list(string-append "--logger=" sssd-logger)) + #$@(if sssd-debug-level + (list (string-append "--debug-level=" sssd-debug-level)) + '() + ) + ) + #:log-file #$log-file + )) + (stop #~(make-kill-destructor)) + ) + ) + ) + ) +) + +(define %sssd-activation + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (define (touch file-name) + (call-with-output-file file-name (const #t)) + ) + (mkdir-p "/var/log/sssd") + (mkdir-p "/var/lib/sssd") + #t + ) + ) +) + +(define sssd-service-type + (service-type (name 'sssd) + (extensions + (list + (service-extension shepherd-root-service-type sssd-service) + (service-extension activation-service-type (const %sssd-activation)) + ) + ) + (description "Run sssd") + ) +)