unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd
@ 2022-03-09 19:21 fesoj000
  2022-03-09 19:36 ` Maxime Devos
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: fesoj000 @ 2022-03-09 19:21 UTC (permalink / raw)
  To: 54309

Currently auditd writes logs to /var/log/audit.log. This is a problem because
auditd changes the permissions of the directory audit.log lives in to
700. /var/log usually has 755, this is assumed by some services. postgresql
for example, fails when used together with auditd.

On redhat for example, auditd uses /var/log/audit/ as its log directory. This
change mirrors this behaviour.

* gnu/services/auditd.scm: add auditd-activation function and extend
activation-service-type.
---
  gnu/services/auditd.scm | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gnu/services/auditd.scm b/gnu/services/auditd.scm
index abde811f51..8478581999 100644
--- a/gnu/services/auditd.scm
+++ b/gnu/services/auditd.scm
@@ -31,7 +31,7 @@ (define-module (gnu services auditd)
              %default-auditd-configuration-directory))
  
  (define auditd.conf
-  (plain-file "auditd.conf" "log_file = /var/log/audit.log\nlog_format = \
+  (plain-file "auditd.conf" "log_file = /var/log/audit/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"))
@@ -50,6 +50,12 @@ (define-record-type* <auditd-configuration>
                             (default audit))
    (configuration-directory auditd-configuration-configuration-directory))      ; file-like
  
+(define (auditd-activation config)
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+        (mkdir-p "/var/log/audit"))))
+
  (define (auditd-shepherd-service config)
    (let* ((audit (auditd-configuration-audit config))
           (configuration-directory (auditd-configuration-configuration-directory config)))
@@ -67,7 +73,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)))))
-- 
2.34.0





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd
  2022-03-09 19:21 [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd fesoj000
@ 2022-03-09 19:36 ` Maxime Devos
  2022-03-09 20:44   ` fesoj000
  2022-03-09 21:00 ` fesoj000
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: Maxime Devos @ 2022-03-09 19:36 UTC (permalink / raw)
  To: fesoj000, 54309

[-- Attachment #1: Type: text/plain, Size: 826 bytes --]

fesoj000 schreef op wo 09-03-2022 om 20:21 [+0100]:
> Currently auditd writes logs to /var/log/audit.log. This is a problem because
> auditd changes the permissions of the directory audit.log lives in to
> 700.

Why is auditd doing this?  Can this behaviour be patched out? Is there
an upstream report?

>  /var/log usually has 755, this is assumed by some services. postgresql
> for example, fails when used together with auditd.

Why does postgresql care about the group and other bits?
Could postgresql be modified not to care?

What are the reasons for changing the group and other bits?
Perhaps that should be done by default by Guix when creating
/var/log (POLA)?

In any case, I would recommend adding to auditd.scm to make clear
why the default log location is unacceptable.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd
  2022-03-09 19:36 ` Maxime Devos
@ 2022-03-09 20:44   ` fesoj000
  0 siblings, 0 replies; 22+ messages in thread
From: fesoj000 @ 2022-03-09 20:44 UTC (permalink / raw)
  To: Maxime Devos, 54309

Hi,

On 3/9/22 8:36 PM, Maxime Devos wrote:
> fesoj000 schreef op wo 09-03-2022 om 20:21 [+0100]:
>> Currently auditd writes logs to /var/log/audit.log. This is a problem because
>> auditd changes the permissions of the directory audit.log lives in to
>> 700.
> 
> Why is auditd doing this?  Can this behaviour be patched out? Is there
> an upstream reportThis is the default behavior. auditd will always change the permissions, but
some attributes for this permission change can be configured in the config file.

This behavior could be patched, but i don't think this is a good idea. Even the
manpages assume /var/log/audit as the default log directory in some paragraphs.

The auditd logfile contains events which can be usefull for debugging but
usually this information is used in the aftermath of an cyberattack to learn more
about what happend. It is even recommended to use a separate partition for
/var/log/audit. auditd measures disk space and having /var/log/audit on a separate
partition would deny unrelated processes from filling up the disk, effectively
disabling audit logging.

I think having /var/log/audit as the default log directory for auditd would not
hurt. This would be more in line with other distros and further would allow to use
a different partition.

>>   /var/log usually has 755, this is assumed by some services. postgresql
>> for example, fails when used together with auditd.
> 
> Why does postgresql care about the group and other bits?
> Could postgresql be modified not to care?
Maybe postgresql could be changed to gracefully handle this, but i am not sure what
the benefit would be in this context. In my mind this is obviously a problem of how
auditd is handled currently by auditd-service-type.

Postgresql might be not the only service behaving this way. I did use postgresql as
an example because this was the case i run into.

> What are the reasons for changing the group and other bits?
> Perhaps that should be done by default by Guix when creating
> /var/log (POLA)?
guix creates /var/log as 755, auditd changes its log directory to prevent access
from unprivileged processes. Maybe auditd is paranoid in this case, but it is fine
as long as it gets its own directory.

> In any case, I would recommend adding to auditd.scm to make clear
> why the default log location is unacceptable.
The log location is configured by the configuration file. This configuration file is
generated by auditd-service-type. The upstream [0] default configuration uses
/var/log/audit as log directory. I think that documenting upstream default behavior
does not add much value here. In fact, i think we can remove the log_file statement
all together, because the built in default config uses /var/log/audit/audit.log [1].
I will prepare and test a new diff which removes the log_file statement.


[0] https://github.com/linux-audit/audit-userspace/blob/master/init.d/auditd.conf
[1] https://github.com/linux-audit/audit-userspace/blob/master/src/auditd-config.c#L314

BR




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd
  2022-03-09 19:21 [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd fesoj000
  2022-03-09 19:36 ` Maxime Devos
@ 2022-03-09 21:00 ` fesoj000
  2022-03-10  7:12   ` Liliana Marie Prikler
  2022-03-10 16:29 ` fesoj000
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: fesoj000 @ 2022-03-09 21:00 UTC (permalink / raw)
  To: 54309

Use the upstream default log file for auditd.

* gnu/services/auditd.scm: add auditd-activation function and extend
activation-service-type.
---
  gnu/services/auditd.scm | 17 ++++++++++++-----
  1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/gnu/services/auditd.scm b/gnu/services/auditd.scm
index abde811f51..c88e974adb 100644
--- a/gnu/services/auditd.scm
+++ b/gnu/services/auditd.scm
@@ -31,10 +31,9 @@ (define-module (gnu services auditd)
              %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\nfreq = 1\nspace_left = 5% \
+\nspace_left_action = syslog\nadmin_space_left_action = ignore\
+\ndisk_full_action = ignore\ndisk_error_action = syslog\n"))
  
  (define %default-auditd-configuration-directory
    (computed-file "auditd"
@@ -50,6 +49,12 @@ (define-record-type* <auditd-configuration>
                             (default audit))
    (configuration-directory auditd-configuration-configuration-directory))      ; file-like
  
+(define (auditd-activation config)
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+        (mkdir-p "/var/log/audit"))))
+
  (define (auditd-shepherd-service config)
    (let* ((audit (auditd-configuration-audit config))
           (configuration-directory (auditd-configuration-configuration-directory config)))
@@ -67,7 +72,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)))))
-- 
2.34.0





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd
  2022-03-09 21:00 ` fesoj000
@ 2022-03-10  7:12   ` Liliana Marie Prikler
  2022-03-10 10:36     ` fesoj000
  0 siblings, 1 reply; 22+ messages in thread
From: Liliana Marie Prikler @ 2022-03-10  7:12 UTC (permalink / raw)
  To: fesoj000, 54309

Hi,

Am Mittwoch, dem 09.03.2022 um 22:00 +0100 schrieb fesoj000:
> Use the upstream default log file for auditd.
> 
> * gnu/services/auditd.scm: add auditd-activation function and extend
> activation-service-type.
> ---
>   gnu/services/auditd.scm | 17 ++++++++++++-----
>   1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/gnu/services/auditd.scm b/gnu/services/auditd.scm
> index abde811f51..c88e974adb 100644
> --- a/gnu/services/auditd.scm
> +++ b/gnu/services/auditd.scm
> @@ -31,10 +31,9 @@ (define-module (gnu services auditd)
>               %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\nfreq =
> 1\nspace_left = 5% \
> +\nspace_left_action = syslog\nadmin_space_left_action = ignore\
> +\ndisk_full_action = ignore\ndisk_error_action = syslog\n"))
I'm not sure what the rationale behind writing auditd.conf this way is,
but note that can simply writethis as "\
log_format = ENRICHED
freq = 1
space_left = 5%
..."

Doing this, it would take up some more vertical real estate, but imho
it'd be easier to read.  We might also want to make some of these
configurable later on, e.g. space_left, but that's not relevant to this
patch set.

>   (define %default-auditd-configuration-directory
>     (computed-file "auditd"
> @@ -50,6 +49,12 @@ (define-record-type* <auditd-configuration>
>                              (default audit))
>     (configuration-directory auditd-configuration-configuration-
> directory))      ; file-like
>   
> +(define (auditd-activation config)
> +  (with-imported-modules '((guix build utils))
> +    #~(begin
> +        (use-modules (guix build utils))
> +        (mkdir-p "/var/log/audit"))))
I think guix should already create this directory with the 700
permissions auditd demands, to prevent any TOCTOU-style tampering.


Cheers




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd
  2022-03-10  7:12   ` Liliana Marie Prikler
@ 2022-03-10 10:36     ` fesoj000
  0 siblings, 0 replies; 22+ messages in thread
From: fesoj000 @ 2022-03-10 10:36 UTC (permalink / raw)
  To: Liliana Marie Prikler, 54309

Hi,

On 3/10/22 8:12 AM, Liliana Marie Prikler wrote:
> Hi,
> 
> Am Mittwoch, dem 09.03.2022 um 22:00 +0100 schrieb fesoj000:
>> Use the upstream default log file for auditd.
>>
>> * gnu/services/auditd.scm: add auditd-activation function and extend
>> activation-service-type.
>> ---
>>    gnu/services/auditd.scm | 17 ++++++++++++-----
>>    1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/gnu/services/auditd.scm b/gnu/services/auditd.scm
>> index abde811f51..c88e974adb 100644
>> --- a/gnu/services/auditd.scm
>> +++ b/gnu/services/auditd.scm
>> @@ -31,10 +31,9 @@ (define-module (gnu services auditd)
>>                %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\nfreq =
>> 1\nspace_left = 5% \
>> +\nspace_left_action = syslog\nadmin_space_left_action = ignore\
>> +\ndisk_full_action = ignore\ndisk_error_action = syslog\n"))
> I'm not sure what the rationale behind writing auditd.conf this way is,
> but note that can simply writethis as "\
> log_format = ENRICHED
> freq = 1
> space_left = 5%
> ..."
> 
> Doing this, it would take up some more vertical real estate, but imho
> it'd be easier to read.  We might also want to make some of these
> configurable later on, e.g. space_left, but that's not relevant to this
> patch set.
Sure, i will send a new patch later.

>>    (define %default-auditd-configuration-directory
>>      (computed-file "auditd"
>> @@ -50,6 +49,12 @@ (define-record-type* <auditd-configuration>
>>                               (default audit))
>>      (configuration-directory auditd-configuration-configuration-
>> directory))      ; file-like
>>    
>> +(define (auditd-activation config)
>> +  (with-imported-modules '((guix build utils))
>> +    #~(begin
>> +        (use-modules (guix build utils))
>> +        (mkdir-p "/var/log/audit"))))
> I think guix should already create this directory with the 700
> permissions auditd demands, to prevent any TOCTOU-style tampering.
Good point.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd
  2022-03-09 19:21 [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd fesoj000
  2022-03-09 19:36 ` Maxime Devos
  2022-03-09 21:00 ` fesoj000
@ 2022-03-10 16:29 ` fesoj000
  2022-03-18 19:17 ` [bug#54309] What is the process from here? fesoj000
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 22+ messages in thread
From: fesoj000 @ 2022-03-10 16:29 UTC (permalink / raw)
  To: 54309

Use /var/log/audit for auditd. This is the upstream default.

Further, rework the config file generated by auditd-service-type. Only
write values which diverge from the upstream default.

* gnu/services/auditd.scm: add auditd-activation function and extend
activation-service-type.
---
  gnu/services/auditd.scm | 20 +++++++++++++++-----
  1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/gnu/services/auditd.scm b/gnu/services/auditd.scm
index abde811f51..1eb0ed291b 100644
--- a/gnu/services/auditd.scm
+++ b/gnu/services/auditd.scm
@@ -31,10 +31,10 @@ (define-module (gnu services auditd)
              %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" "\
+space_left = 5%
+space_left_action = syslog
+"))
  
  (define %default-auditd-configuration-directory
    (computed-file "auditd"
@@ -50,6 +50,14 @@ (define-record-type* <auditd-configuration>
                             (default audit))
    (configuration-directory auditd-configuration-configuration-directory))      ; file-like
  
+(define (auditd-activation config)
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+        (let ((var-log-audit "/var/log/audit"))
+          (mkdir-p var-log-audit)
+          (chmod var-log-audit #o700)))))
+
  (define (auditd-shepherd-service config)
    (let* ((audit (auditd-configuration-audit config))
           (configuration-directory (auditd-configuration-configuration-directory config)))
@@ -67,7 +75,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)))))
-- 
2.34.0





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#54309] What is the process from here?
  2022-03-09 19:21 [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd fesoj000
                   ` (2 preceding siblings ...)
  2022-03-10 16:29 ` fesoj000
@ 2022-03-18 19:17 ` fesoj000
  2022-03-18 20:06   ` Liliana Marie Prikler
  2022-03-19 11:34 ` [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd fesoj000
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: fesoj000 @ 2022-03-18 19:17 UTC (permalink / raw)
  To: 54309

Hi there,

i don't think this is the right spot to ask this, but i am not sure where else
i could ask this.

What is the patch acceptance process? I am wondering, what are steps from patch
to commit? I have quite some packages, services and other patches laying around
in varying quality. I recently started cleaning them up. I plan to get them
integrated into master at some point.

So, i assume that there has to be interest and time from a guix developer to
review, maybe test and then integrate the changes/packages into one of the
branches.

Is there something i can do to help the process along? Maybe we could use this
very patch as an example. Currently i am uncertain if this patch is appropriate
for master, because of the risk that changing the auditd default log directory
might break some setups. This could be 'fixed' by writing a news snippet. But i
am not sure. Or is there still something else missing?

BR




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] What is the process from here?
  2022-03-18 19:17 ` [bug#54309] What is the process from here? fesoj000
@ 2022-03-18 20:06   ` Liliana Marie Prikler
  2022-03-18 21:48     ` fesoj000
  0 siblings, 1 reply; 22+ messages in thread
From: Liliana Marie Prikler @ 2022-03-18 20:06 UTC (permalink / raw)
  To: fesoj000, 54309

Hi,

Am Freitag, dem 18.03.2022 um 20:17 +0100 schrieb fesoj000:
> Hi there,
> 
> i don't think this is the right spot to ask this, but i am not sure
> where else i could ask this.
> 
> What is the patch acceptance process? I am wondering, what are steps
> from patch to commit?  I have quite some packages, services and other
> patches laying around in varying quality.  I recently started
> cleaning them up.  I plan to get them integrated into master at some
> point.
In general it's send a patch, wait for review (this might take some
time), argue with the reviewer, reluctantly send v2, v3, ... until your
patch passes the quality criteria, gets stamped and arrives upstream
via avian carrier.

> So, i assume that there has to be interest and time from a guix
> developer to review, maybe test and then integrate the
> changes/packages into one of the branches.
Note that there have already been two people reviewing; you currently
owe me a v2 addressing the TOCTOU "race" of creating the audit
directory without 700 permissions. 

> Is there something i can do to help the process along?  Maybe we
> could use this very patch as an example.  Currently i am uncertain if
> this patch is appropriate for master, because of the risk that
> changing the auditd default log directory might break some setups.
> This could be 'fixed' by writing a news snippet. But i
> am not sure.  Or is there still something else missing?
In general, you should read the reviews carefully, reflect on them,
implement suggested changes (or come up with better alternative
solutions) and resend the patches with said changes; rinse and repeat
until you hear a "LGTM".  If the reviewer in question is a committer,
you might hear a "Thanks, pushed" instead.  As a rule of thumb, others
will rarely actively fix up your code and if they do it's mostly minor
things.  Any work more than that takes them away from other review or
their own submissions.

Cheers




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] What is the process from here?
  2022-03-18 20:06   ` Liliana Marie Prikler
@ 2022-03-18 21:48     ` fesoj000
  2022-03-18 22:36       ` Liliana Marie Prikler
  0 siblings, 1 reply; 22+ messages in thread
From: fesoj000 @ 2022-03-18 21:48 UTC (permalink / raw)
  To: Liliana Marie Prikler, 54309

On 3/18/22 9:06 PM, Liliana Marie Prikler wrote:
>> So, i assume that there has to be interest and time from a guix
>> developer to review, maybe test and then integrate the
>> changes/packages into one of the branches.
> Note that there have already been two people reviewing; you currently
> owe me a v2 addressing the TOCTOU "race" of creating the audit
> directory without 700 permissions.
Yes, that is true. But i addressed the rest, i think. New version inline.


 From 0605a2b5cc8beb816e3ff557d7be060a050f91b7 Mon Sep 17 00:00:00 2001
From: fesoj000 <fesoj000@gmail.com>
Date: Wed, 9 Mar 2022 20:07:42 +0100
Subject: [PATCH] services: auditd: use exclusive log directory for auditd

Use /var/log/audit for auditd. This is the upstream default.

Further, rework the config file generated by auditd-service-type. Only
write values which diverge from the upstream default.

* gnu/services/auditd.scm: add auditd-activation function and extend
activation-service-type.
---
  gnu/services/auditd.scm | 20 +++++++++++++++-----
  1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/gnu/services/auditd.scm b/gnu/services/auditd.scm
index abde811f51..602a6c5a48 100644
--- a/gnu/services/auditd.scm
+++ b/gnu/services/auditd.scm
@@ -31,10 +31,10 @@ (define-module (gnu services auditd)
              %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" "\
+space_left = 5%
+space_left_action = syslog
+"))
  
  (define %default-auditd-configuration-directory
    (computed-file "auditd"
@@ -50,6 +50,14 @@ (define-record-type* <auditd-configuration>
                             (default audit))
    (configuration-directory auditd-configuration-configuration-directory))      ; file-like
  
+(define (auditd-activation config)
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+        (let ((var-log-audit "/var/log/audit"))
+          (umask #o077)
+          (mkdir-p var-log-audit)))))
+
  (define (auditd-shepherd-service config)
    (let* ((audit (auditd-configuration-audit config))
           (configuration-directory (auditd-configuration-configuration-directory config)))
@@ -67,7 +75,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)))))
-- 
2.34.0




^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#54309] What is the process from here?
  2022-03-18 21:48     ` fesoj000
@ 2022-03-18 22:36       ` Liliana Marie Prikler
  2022-03-19 11:10         ` fesoj000
  2022-03-19 23:09         ` Maxime Devos
  0 siblings, 2 replies; 22+ messages in thread
From: Liliana Marie Prikler @ 2022-03-18 22:36 UTC (permalink / raw)
  To: fesoj000, 54309

Am Freitag, dem 18.03.2022 um 22:48 +0100 schrieb fesoj000:
> On 3/18/22 9:06 PM, Liliana Marie Prikler wrote:
> > > So, i assume that there has to be interest and time from a guix
> > > developer to review, maybe test and then integrate the
> > > changes/packages into one of the branches.
> > Note that there have already been two people reviewing; you
> > currently
> > owe me a v2 addressing the TOCTOU "race" of creating the audit
> > directory without 700 permissions.
> Yes, that is true. But i addressed the rest, i think. New version
> inline.
For the record, inline patches generate noise that's hard to separate
when applying, so you'd probably want to avoid them.  If you don't have
git send-email set up regular attachments also work for some, though
they do become tedious as well with series.

> From 0605a2b5cc8beb816e3ff557d7be060a050f91b7 Mon Sep 17 00:00:00
> 2001
> From: fesoj000 <fesoj000@gmail.com>
> Date: Wed, 9 Mar 2022 20:07:42 +0100
> Subject: [PATCH] services: auditd: use exclusive log directory for
> auditd
> 
> Use /var/log/audit for auditd. This is the upstream default.
> 
> Further, rework the config file generated by auditd-service-type.
> Only
> write values which diverge from the upstream default.
> 
> * gnu/services/auditd.scm: add auditd-activation function and extend
> activation-service-type.
> ---
>   gnu/services/auditd.scm | 20 +++++++++++++++-----
>   1 file changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/gnu/services/auditd.scm b/gnu/services/auditd.scm
> index abde811f51..602a6c5a48 100644
> --- a/gnu/services/auditd.scm
> +++ b/gnu/services/auditd.scm
> @@ -31,10 +31,10 @@ (define-module (gnu services auditd)
>               %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" "\
> +space_left = 5%
> +space_left_action = syslog
> +"))
I can understand discarding the log_file entry because we now use
upstream default, but the rest should remain imo.
 
>   (define %default-auditd-configuration-directory
>     (computed-file "auditd"
> @@ -50,6 +50,14 @@ (define-record-type* <auditd-configuration>
>                              (default audit))
>     (configuration-directory auditd-configuration-configuration-
> directory))      ; file-like
>   
> +(define (auditd-activation config)
> +  (with-imported-modules '((guix build utils))
> +    #~(begin
> +        (use-modules (guix build utils))
> +        (let ((var-log-audit "/var/log/audit"))
> +          (umask #o077)
> +          (mkdir-p var-log-audit)))))
> +
This would also apply umask 077 to /var and /var/log if those don't
already exist.  More importantly, code executed after that will also
inherit the umask, which I don't think is the intended consequence.


Cheers




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] What is the process from here?
  2022-03-18 22:36       ` Liliana Marie Prikler
@ 2022-03-19 11:10         ` fesoj000
  2022-03-19 23:09         ` Maxime Devos
  1 sibling, 0 replies; 22+ messages in thread
From: fesoj000 @ 2022-03-19 11:10 UTC (permalink / raw)
  To: Liliana Marie Prikler, 54309



On 3/18/22 11:36 PM, Liliana Marie Prikler wrote:
> Am Freitag, dem 18.03.2022 um 22:48 +0100 schrieb fesoj000:
>> On 3/18/22 9:06 PM, Liliana Marie Prikler wrote:
>>>> So, i assume that there has to be interest and time from a guix
>>>> developer to review, maybe test and then integrate the
>>>> changes/packages into one of the branches.
>>> Note that there have already been two people reviewing; you
>>> currently
>>> owe me a v2 addressing the TOCTOU "race" of creating the audit
>>> directory without 700 permissions.
>> Yes, that is true. But i addressed the rest, i think. New version
>> inline.
> For the record, inline patches generate noise that's hard to separate
> when applying, so you'd probably want to avoid them.  If you don't have
> git send-email set up regular attachments also work for some, though
> they do become tedious as well with series.
> 
>>  From 0605a2b5cc8beb816e3ff557d7be060a050f91b7 Mon Sep 17 00:00:00
>> 2001
>> From: fesoj000 <fesoj000@gmail.com>
>> Date: Wed, 9 Mar 2022 20:07:42 +0100
>> Subject: [PATCH] services: auditd: use exclusive log directory for
>> auditd
>>
>> Use /var/log/audit for auditd. This is the upstream default.
>>
>> Further, rework the config file generated by auditd-service-type.
>> Only
>> write values which diverge from the upstream default.
>>
>> * gnu/services/auditd.scm: add auditd-activation function and extend
>> activation-service-type.
>> ---
>>    gnu/services/auditd.scm | 20 +++++++++++++++-----
>>    1 file changed, 15 insertions(+), 5 deletions(-)
>>
>> diff --git a/gnu/services/auditd.scm b/gnu/services/auditd.scm
>> index abde811f51..602a6c5a48 100644
>> --- a/gnu/services/auditd.scm
>> +++ b/gnu/services/auditd.scm
>> @@ -31,10 +31,10 @@ (define-module (gnu services auditd)
>>                %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" "\
>> +space_left = 5%
>> +space_left_action = syslog
>> +"))
> I can understand discarding the log_file entry because we now use
> upstream default, but the rest should remain imo.
Alright. Lets first keep all options. At another point in time we can
rethink the default options. Maybe when implementing configuration for
auditd.

>>    (define %default-auditd-configuration-directory
>>      (computed-file "auditd"
>> @@ -50,6 +50,14 @@ (define-record-type* <auditd-configuration>
>>                               (default audit))
>>      (configuration-directory auditd-configuration-configuration-
>> directory))      ; file-like
>>    
>> +(define (auditd-activation config)
>> +  (with-imported-modules '((guix build utils))
>> +    #~(begin
>> +        (use-modules (guix build utils))
>> +        (let ((var-log-audit "/var/log/audit"))
>> +          (umask #o077)
>> +          (mkdir-p var-log-audit)))))
>> +
> This would also apply umask 077 to /var and /var/log if those don't
> already exist.
Hm, it seems that 'gnu/services.scm: (activation-script)' ensures the
existence of /var/log before the auditd activation gexp is running. So,
the reasoning behind your remark is that we can not guarantee the
existence of /var/log in every case? What cases might that be? I will
take care of it anyway for the sake of robustness, but i am curious.

> More importantly, code executed after that will also
> inherit the umask, which I don't think is the intended consequence.
I was under the impression that every activation script is run it its
own process. But that is not the case. This changes things, more care
is needed.

Patch will follow later.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd
  2022-03-09 19:21 [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd fesoj000
                   ` (3 preceding siblings ...)
  2022-03-18 19:17 ` [bug#54309] What is the process from here? fesoj000
@ 2022-03-19 11:34 ` fesoj000
  2022-03-19 23:13   ` Maxime Devos
  2022-03-23 20:22 ` [bug#54309] [PATCHv2] " fesoj000
  2022-03-23 20:39 ` [bug#54309] [PATCHv3] " fesoj000
  6 siblings, 1 reply; 22+ messages in thread
From: fesoj000 @ 2022-03-19 11:34 UTC (permalink / raw)
  To: 54309

Use /var/log/audit for auditd. This is the upstream default.

Further, make the inline config file more readable.

* gnu/services/auditd.scm: add auditd-activation function and extend
activation-service-type.
---
  gnu/services/auditd.scm | 27 ++++++++++++++++++++++-----
  1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/gnu/services/auditd.scm b/gnu/services/auditd.scm
index abde811f51..e9e19c61be 100644
--- a/gnu/services/auditd.scm
+++ b/gnu/services/auditd.scm
@@ -31,10 +31,15 @@ (define-module (gnu services auditd)
              %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 +55,16 @@ (define-record-type* <auditd-configuration>
                             (default audit))
    (configuration-directory auditd-configuration-configuration-directory))      ; file-like
  
+(define (auditd-activation config)
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+        ;; make sure /var/log exists before changing umask
+        (mkdir-p "/var/log")
+        (let* ((previous-umask (umask #o077)))
+          (mkdir-p "/var/log/audit")
+          (umask previous-umask)))))
+
  (define (auditd-shepherd-service config)
    (let* ((audit (auditd-configuration-audit config))
           (configuration-directory (auditd-configuration-configuration-directory config)))
@@ -67,7 +82,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)))))
-- 
2.34.0





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#54309] What is the process from here?
  2022-03-18 22:36       ` Liliana Marie Prikler
  2022-03-19 11:10         ` fesoj000
@ 2022-03-19 23:09         ` Maxime Devos
  2022-03-22 16:50           ` fesoj000
  1 sibling, 1 reply; 22+ messages in thread
From: Maxime Devos @ 2022-03-19 23:09 UTC (permalink / raw)
  To: Liliana Marie Prikler, fesoj000, 54309

[-- Attachment #1: Type: text/plain, Size: 982 bytes --]

Liliana Marie Prikler schreef op vr 18-03-2022 om 23:36 [+0100]:
> > +(define (auditd-activation config)
> > +  (with-imported-modules '((guix build utils))
> > +    #~(begin
> > +        (use-modules (guix build utils))
> > +        (let ((var-log-audit "/var/log/audit"))
> > +          (umask #o077)
> > +          (mkdir-p var-log-audit)))))
> > +
> This would also apply umask 077 to /var and /var/log if those don't
> already exist.  More importantly, code executed after that will also
> inherit the umask, which I don't think is the intended consequence.

More concretely, the procedure 'mkdir-p/perms' would address the umask
issue, but not the potential ‘oops too restrictive permissions for /var
and /var/log' issue.  Additionally, as var-log-audit is only used in a
single place, you could simplify to

  #~(begin
      (use-modules ...)
      (mkdir-p/perms "/var/log/audit"))

here.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd
  2022-03-19 11:34 ` [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd fesoj000
@ 2022-03-19 23:13   ` Maxime Devos
  2022-03-20 20:22     ` fesoj000
  0 siblings, 1 reply; 22+ messages in thread
From: Maxime Devos @ 2022-03-19 23:13 UTC (permalink / raw)
  To: fesoj000, 54309

[-- Attachment #1: Type: text/plain, Size: 422 bytes --]

fesoj000 schreef op za 19-03-2022 om 12:34 [+0100]:
> +        (let* ((previous-umask (umask #o077)))
> +          (mkdir-p "/var/log/audit")
> +          (umask previous-umask)))))

I cannot recommend this, what if 'mkdir-p' throws an exception?
That might cause problems.  Or maybe not, but it would require
some analysis that can be avoided with 'mkdir-p/perms'.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd
  2022-03-19 23:13   ` Maxime Devos
@ 2022-03-20 20:22     ` fesoj000
  2022-03-20 20:30       ` Maxime Devos
  0 siblings, 1 reply; 22+ messages in thread
From: fesoj000 @ 2022-03-20 20:22 UTC (permalink / raw)
  To: Maxime Devos, 54309

On 3/20/22 12:13 AM, Maxime Devos wrote:
> fesoj000 schreef op za 19-03-2022 om 12:34 [+0100]:
>> +        (let* ((previous-umask (umask #o077)))
>> +          (mkdir-p "/var/log/audit")
>> +          (umask previous-umask)))))
> 
> I cannot recommend this, what if 'mkdir-p' throws an exception?
> That might cause problems.  Or maybe not, but it would require
> some analysis that can be avoided with 'mkdir-p/perms'.
Hm, but i still have to set umask to prevent TOCTOU, the
implementation of 'mkdir-p/perms' does not take care of that.

BR




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd
  2022-03-20 20:22     ` fesoj000
@ 2022-03-20 20:30       ` Maxime Devos
  2022-03-20 20:35         ` Maxime Devos
  0 siblings, 1 reply; 22+ messages in thread
From: Maxime Devos @ 2022-03-20 20:30 UTC (permalink / raw)
  To: fesoj000, 54309

[-- Attachment #1: Type: text/plain, Size: 714 bytes --]

fesoj000 schreef op zo 20-03-2022 om 21:22 [+0100]:
> > I cannot recommend this, what if 'mkdir-p' throws an exception?
> > That might cause problems.  Or maybe not, but it would require
> > some analysis that can be avoided with 'mkdir-p/perms'.
> Hm, but i still have to set umask to prevent TOCTOU, the
> implementation of 'mkdir-p/perms' does not take care of that.

mkdir-p/perms could be modified to take care of that.
If that is done, then other users of mkdir-p/perms would benefit as
well.

To implement this, I recommend using the prodecures from
<https://lists.gnu.org/archive/html/guile-devel/2021-11/msg00005.html>
-- that patch was written to remove the TOCTOU!

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd
  2022-03-20 20:30       ` Maxime Devos
@ 2022-03-20 20:35         ` Maxime Devos
  0 siblings, 0 replies; 22+ messages in thread
From: Maxime Devos @ 2022-03-20 20:35 UTC (permalink / raw)
  To: fesoj000, 54309

[-- Attachment #1: Type: text/plain, Size: 940 bytes --]

Maxime Devos schreef op zo 20-03-2022 om 21:30 [+0100]:
> fesoj000 schreef op zo 20-03-2022 om 21:22 [+0100]:
> > > I cannot recommend this, what if 'mkdir-p' throws an exception?
> > > That might cause problems.  Or maybe not, but it would require
> > > some analysis that can be avoided with 'mkdir-p/perms'.
> > Hm, but i still have to set umask to prevent TOCTOU, the
> > implementation of 'mkdir-p/perms' does not take care of that.
> 
> mkdir-p/perms could be modified to take care of that.
> If that is done, then other users of mkdir-p/perms would benefit as
> well.
> 
> To implement this, I recommend using the prodecures from
> <https://lists.gnu.org/archive/html/guile-devel/2021-11/msg00005.html
> > 
> -- that patch was written to remove the TOCTOU!

It seems to be ignored so far upstream, so I'll look into defining
a Guile package variant that can be used by the activation code.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] What is the process from here?
  2022-03-19 23:09         ` Maxime Devos
@ 2022-03-22 16:50           ` fesoj000
  2022-03-22 20:06             ` Liliana Marie Prikler
  0 siblings, 1 reply; 22+ messages in thread
From: fesoj000 @ 2022-03-22 16:50 UTC (permalink / raw)
  To: Maxime Devos, Liliana Marie Prikler, 54309

On 3/20/22 12:09 AM, Maxime Devos wrote:
> Liliana Marie Prikler schreef op vr 18-03-2022 om 23:36 [+0100]:
>>> +(define (auditd-activation config)
>>> +  (with-imported-modules '((guix build utils))
>>> +    #~(begin
>>> +        (use-modules (guix build utils))
>>> +        (let ((var-log-audit "/var/log/audit"))
>>> +          (umask #o077)
>>> +          (mkdir-p var-log-audit)))))
>>> +
>> This would also apply umask 077 to /var and /var/log if those don't
>> already exist.  More importantly, code executed after that will also
>> inherit the umask, which I don't think is the intended consequence.
> 
> More concretely, the procedure 'mkdir-p/perms' would address the umask
> issue, but not the potential ‘oops too restrictive permissions for /var
> and /var/log' issue.
Ok, i can assume that a future version of 'mkdir-p/perms' will handle the
umask.

Should the activation now handle potential permission problems from past
activations and auditd starts? Can you try to explain in more detail
please?

BR




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] What is the process from here?
  2022-03-22 16:50           ` fesoj000
@ 2022-03-22 20:06             ` Liliana Marie Prikler
  0 siblings, 0 replies; 22+ messages in thread
From: Liliana Marie Prikler @ 2022-03-22 20:06 UTC (permalink / raw)
  To: fesoj000, Maxime Devos, 54309

Am Dienstag, dem 22.03.2022 um 17:50 +0100 schrieb fesoj000:
> On 3/20/22 12:09 AM, Maxime Devos wrote:
> > Liliana Marie Prikler schreef op vr 18-03-2022 om 23:36 [+0100]:
> > > > +(define (auditd-activation config)
> > > > +  (with-imported-modules '((guix build utils))
> > > > +    #~(begin
> > > > +        (use-modules (guix build utils))
> > > > +        (let ((var-log-audit "/var/log/audit"))
> > > > +          (umask #o077)
> > > > +          (mkdir-p var-log-audit)))))
> > > > +
> > > This would also apply umask 077 to /var and /var/log if those
> > > don't already exist.  More importantly, code executed after that
> > > will also inherit the umask, which I don't think is the intended
> > > consequence.
> > 
> > More concretely, the procedure 'mkdir-p/perms' would address the
> > umask issue, but not the potential ‘oops too restrictive
> > permissions for /var and /var/log' issue.
> Ok, i can assume that a future version of 'mkdir-p/perms' will handle
> the umask.
> 
> Should the activation now handle potential permission problems from
> past activations and auditd starts? Can you try to explain in more
> detail please?
My personal solution would be to use (mkdir-p "/var/log") followed by
(mkdir "/var/log/audit" #o700).

Cheers 




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#54309] [PATCHv2] services: auditd: use exclusive log directory for auditd
  2022-03-09 19:21 [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd fesoj000
                   ` (4 preceding siblings ...)
  2022-03-19 11:34 ` [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd fesoj000
@ 2022-03-23 20:22 ` fesoj000
  2022-03-23 20:39 ` [bug#54309] [PATCHv3] " fesoj000
  6 siblings, 0 replies; 22+ messages in thread
From: fesoj000 @ 2022-03-23 20:22 UTC (permalink / raw)
  To: 54309

Use /var/log/audit for auditd. This is the upstream default.

* gnu/services/auditd.scm: add auditd-activation function and extend
activation-service-type.
---
  gnu/services/auditd.scm | 25 ++++++++++++++++++++-----
  1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/gnu/services/auditd.scm b/gnu/services/auditd.scm
index abde811f51..8e3d5fd2bc 100644
--- a/gnu/services/auditd.scm
+++ b/gnu/services/auditd.scm
@@ -31,10 +31,15 @@ (define-module (gnu services auditd)
              %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 +55,14 @@ (define-record-type* <auditd-configuration>
                             (default audit))
    (configuration-directory auditd-configuration-configuration-directory))      ; file-like
  
+(define (auditd-activation config)
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+        ;; ensure /var/log exists with default permissions
+        (mkdir-p "/var/log")
+        (mkdir-p/perm "/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 +80,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)))))
-- 
2.34.0





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#54309] [PATCHv3] services: auditd: use exclusive log directory for auditd
  2022-03-09 19:21 [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd fesoj000
                   ` (5 preceding siblings ...)
  2022-03-23 20:22 ` [bug#54309] [PATCHv2] " fesoj000
@ 2022-03-23 20:39 ` fesoj000
  6 siblings, 0 replies; 22+ messages in thread
From: fesoj000 @ 2022-03-23 20:39 UTC (permalink / raw)
  To: 54309

Use /var/log/audit for auditd. This is the upstream default.

* gnu/services/auditd.scm: add auditd-activation function and extend
activation-service-type.
---
  gnu/services/auditd.scm | 28 +++++++++++++++++++++++-----
  1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/gnu/services/auditd.scm b/gnu/services/auditd.scm
index abde811f51..33849155a1 100644
--- a/gnu/services/auditd.scm
+++ b/gnu/services/auditd.scm
@@ -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)))))
-- 
2.34.0





^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2022-03-23 20:40 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-09 19:21 [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd fesoj000
2022-03-09 19:36 ` Maxime Devos
2022-03-09 20:44   ` fesoj000
2022-03-09 21:00 ` fesoj000
2022-03-10  7:12   ` Liliana Marie Prikler
2022-03-10 10:36     ` fesoj000
2022-03-10 16:29 ` fesoj000
2022-03-18 19:17 ` [bug#54309] What is the process from here? fesoj000
2022-03-18 20:06   ` Liliana Marie Prikler
2022-03-18 21:48     ` fesoj000
2022-03-18 22:36       ` Liliana Marie Prikler
2022-03-19 11:10         ` fesoj000
2022-03-19 23:09         ` Maxime Devos
2022-03-22 16:50           ` fesoj000
2022-03-22 20:06             ` Liliana Marie Prikler
2022-03-19 11:34 ` [bug#54309] [PATCH] services: auditd: use exclusive log directory for auditd fesoj000
2022-03-19 23:13   ` Maxime Devos
2022-03-20 20:22     ` fesoj000
2022-03-20 20:30       ` Maxime Devos
2022-03-20 20:35         ` Maxime Devos
2022-03-23 20:22 ` [bug#54309] [PATCHv2] " fesoj000
2022-03-23 20:39 ` [bug#54309] [PATCHv3] " fesoj000

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).