Skip to content

Commit 309c873

Browse files
Add tests
Signed-off-by: Alan Moore <alan.moore@canonical.com>
1 parent f914570 commit 309c873

35 files changed

Lines changed: 366 additions & 3 deletions

linux_os/guide/system/logging/journald/dir_groupowner_system_journal/rule.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ severity: medium
2121

2222
fixtext: |
2323
Configure the system to set the appropriate ownership to the directories
24-
used by the systemd journal. Add or modify the following lines in the
25-
"/usr/lib/tmpfiles.d/systemd.conf" file:
24+
used by the systemd journal.
25+
Create a drop-in file if it does not already exist with the following command:
26+
<pre>
27+
$ sudo vi /etc/tmpfiles.d/zzz-systemd-stig.conf
28+
</pre>
29+
Add or modify the following lines in the "/usr/lib/tmpfiles.d/zzz-systemd-stig.conf" file:
2630
<pre>
2731
z /run/log/journal 2640 root systemd-journal - -
2832
z /var/log/journal 2640 root systemd-journal - -
2933
</pre>
30-
Restart the system for the changes to take effect.
34+
Note: Restart the system for the changes to take effect.
3135
3236
template:
3337
name: file_groupowner
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# platform = multi_platform_ubuntu
3+
4+
getent group "systemd-journal" &>/dev/null || groupadd systemd-journal
5+
6+
mkdir -p /run/log/journal /var/log/journal
7+
chgrp -R systemd-journal /run/log/journal /var/log/journal
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
# platform = multi_platform_ubuntu
3+
4+
getent group "systemd-journal" &>/dev/null || groupadd systemd-journal
5+
6+
mkdir -p /run/log/journal /var/log/journal
7+
mkdir -p /var/log/journal/wrong_group_dir
8+
chgrp -R systemd-journal /run/log/journal /var/log/journal
9+
chgrp -R nogroup /var/log/journal/wrong_group_dir
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
# platform = multi_platform_ubuntu
3+
4+
getent group "systemd-journal" &>/dev/null || groupadd systemd-journal
5+
6+
machine_id="$(cat /etc/machine-id)"
7+
mkdir -p "/run/log/journal/${machine_id}/nested/deeper"
8+
mkdir -p "/var/log/journal/${machine_id}/nested/deeper"
9+
10+
chgrp nogroup "/run/log/journal/${machine_id}/nested/deeper"
11+
chgrp nogroup "/var/log/journal/${machine_id}/nested/deeper"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# platform = multi_platform_ubuntu
3+
4+
getent group "systemd-journal" &>/dev/null || groupadd systemd-journal
5+
6+
mkdir -p /run/log/journal /var/log/journal
7+
chgrp systemd-journal /run/log/journal /var/log/journal
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# platform = multi_platform_ubuntu
3+
4+
mkdir -p /run/log/journal /var/log/journal
5+
chown -R root /run/log/journal /var/log/journal
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
# platform = multi_platform_ubuntu
3+
4+
useradd testuser_123
5+
6+
mkdir -p /run/log/journal /var/log/journal
7+
mkdir -p /run/log/journal/wrong_owner_dir
8+
chown -R testuser_123 /run/log/journal/wrong_owner_dir
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
# platform = multi_platform_ubuntu
3+
4+
id testuser_123 &>/dev/null || useradd testuser_123
5+
6+
machine_id="$(cat /etc/machine-id)"
7+
mkdir -p "/run/log/journal/${machine_id}/nested/deeper"
8+
mkdir -p "/var/log/journal/${machine_id}/nested/deeper"
9+
10+
chown testuser_123 "/run/log/journal/${machine_id}/nested/deeper"
11+
chown testuser_123 "/var/log/journal/${machine_id}/nested/deeper"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# platform = multi_platform_ubuntu
3+
4+
mkdir -p /run/log/journal /var/log/journal
5+
chown root /run/log/journal /var/log/journal
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# platform = multi_platform_ubuntu
3+
4+
mkdir -p /run/log/journal /var/log/journal
5+
find /run/log/journal /var/log/journal -type d -exec chmod 2750 {} \;

0 commit comments

Comments
 (0)