| 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2019 Danny Milosavljevic <dannym@scratchpost.org> |
| 3 | ;;; |
| 4 | ;;; This file is part of GNU Guix. |
| 5 | ;;; |
| 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
| 7 | ;;; under the terms of the GNU General Public License as published by |
| 8 | ;;; the Free Software Foundation; either version 3 of the License, or (at |
| 9 | ;;; your option) any later version. |
| 10 | ;;; |
| 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
| 12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | ;;; GNU General Public License for more details. |
| 15 | ;;; |
| 16 | ;;; You should have received a copy of the GNU General Public License |
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
| 18 | |
| 19 | (define-module (gnu services auditd) |
| 20 | #:use-module (gnu services) |
| 21 | #:use-module (gnu services configuration) |
| 22 | #:use-module (gnu services base) |
| 23 | #:use-module (gnu services shepherd) |
| 24 | #:use-module (gnu packages admin) |
| 25 | #:use-module (guix records) |
| 26 | #:use-module (guix gexp) |
| 27 | #:use-module (guix packages) |
| 28 | #:export (auditd-configuration |
| 29 | auditd-service-type)) |
| 30 | |
| 31 | ; /etc/audit/audit.rules |
| 32 | |
| 33 | (define-configuration auditd-configuration |
| 34 | (audit |
| 35 | (package audit) |
| 36 | "Audit package.")) |
| 37 | |
| 38 | (define (auditd-shepherd-service config) |
| 39 | (let* ((audit (auditd-configuration-audit config))) |
| 40 | (list (shepherd-service |
| 41 | (documentation "Auditd allows you to audit file system accesses.") |
| 42 | (provision '(auditd)) |
| 43 | (start #~(make-forkexec-constructor |
| 44 | (list (string-append #$audit "/sbin/auditd")))) |
| 45 | (stop #~(make-kill-destructor)))))) |
| 46 | |
| 47 | (define auditd-service-type |
| 48 | (service-type (name 'auditd) |
| 49 | (description "Allows auditing file system accesses.") |
| 50 | (extensions |
| 51 | (list |
| 52 | (service-extension shepherd-root-service-type |
| 53 | auditd-shepherd-service))) |
| 54 | (default-value (auditd-configuration)))) |