@@ -26,15 +26,21 @@ (define-module (gnu services auditd)
#:use-module (guix records)
#:use-module (guix gexp)
#:use-module (guix packages)
+ #:use-module (guix modules)
#:export (auditd-configuration
auditd-service-type
%default-auditd-configuration-directory))
(define auditd.conf
- (plain-file "auditd.conf" "log_file = /var/log/audit.log\nlog_format = \
-ENRICHED\nfreq = 1\nspace_left = 5%\nspace_left_action = \
-syslog\nadmin_space_left_action = ignore\ndisk_full_action = \
-ignore\ndisk_error_action = syslog\n"))
+ (plain-file "auditd.conf" "\
+log_format = ENRICHED
+freq = 1
+space_left = 5%
+space_left_action = syslog
+admin_space_left_action = ignore
+disk_full_action = ignore
+disk_error_action = syslog
+"))
(define %default-auditd-configuration-directory
(computed-file "auditd"
@@ -50,6 +56,16 @@ (define-record-type* <auditd-configuration>
(default audit))
(configuration-directory auditd-configuration-configuration-directory)) ; file-like
+(define (auditd-activation config)
+ (with-imported-modules (source-module-closure '((gnu build activation)
+ (guix build utils)))
+ #~(begin
+ (use-modules (gnu build activation)
+ (guix build utils))
+ ;; ensure /var/log exists with default permissions
+ (mkdir-p "/var/log")
+ (mkdir-p/perms "/var/log/audit" (getpwnam "root") #o700))))
+
(define (auditd-shepherd-service config)
(let* ((audit (auditd-configuration-audit config))
(configuration-directory (auditd-configuration-configuration-directory config)))
@@ -67,7 +83,9 @@ (define auditd-service-type
(extensions
(list
(service-extension shepherd-root-service-type
- auditd-shepherd-service)))
+ auditd-shepherd-service)
+ (service-extension activation-service-type
+ auditd-activation)))
(default-value
(auditd-configuration
(configuration-directory %default-auditd-configuration-directory)))))