-
Notifications
You must be signed in to change notification settings - Fork 708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ubuntu 24.04 6.1.2.1.2 Ensure systemd-journal-upload authentication #12852
base: master
Are you sure you want to change the base?
Changes from all commits
f123a94
53a6846
c15a18c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
# platform = multi_platform_slmicro | ||
# platform = multi_platform_slmicro,multi_platform_ubuntu | ||
|
||
{{{ bash_instantiate_variables("var_journal_upload_conf_file") }}} | ||
{{{ bash_instantiate_variables("var_journal_upload_server_key_file") }}} | ||
{{{ bash_replace_or_append('/etc/systemd/journal-upload.conf', '^ServerKeyFile', "$var_journal_upload_server_key_file", '%s=%s') }}} | ||
{{{ bash_replace_or_append('$var_journal_upload_conf_file', '^ServerKeyFile', "$var_journal_upload_server_key_file", '%s=%s') }}} | ||
|
||
{{{ bash_instantiate_variables("var_journal_upload_server_certificate_file") }}} | ||
{{{ bash_replace_or_append('/etc/systemd/journal-upload.conf', '^ServerCertificateFile', "$var_journal_upload_server_certificate_file", '%s=%s') }}} | ||
{{{ bash_replace_or_append('$var_journal_upload_conf_file', '^ServerCertificateFile', "$var_journal_upload_server_certificate_file", '%s=%s') }}} | ||
|
||
{{{ bash_instantiate_variables("var_journal_upload_server_trusted_certificate_file") }}} | ||
{{{ bash_replace_or_append('/etc/systemd/journal-upload.conf', '^TrustedCertificateFile', "$var_journal_upload_server_trusted_certificate_file", '%s=%s') }}} | ||
{{{ bash_replace_or_append('$var_journal_upload_conf_file', '^TrustedCertificateFile', "$var_journal_upload_server_trusted_certificate_file", '%s=%s') }}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# packages = systemd-journal-remote | ||
# variables = var_journal_upload_conf_file=/etc/systemd/journal-upload.conf.d/60-journald_upload.conf,var_journal_upload_server_key_file=/etc/ssl/private/journal-upload.pem,var_journal_upload_server_certificate_file=/etc/ssl/certs/journal-upload.pem,var_journal_upload_server_trusted_certificate_file=/etc/ssl/ca/trusted.pem | ||
|
||
a_settings=("URL=192.168.50.42" "ServerKeyFile=/etc/ssl/private/journal-upload.pem" \ | ||
"ServerCertificateFile=/etc/ssl/certs/journal-upload.pem" "TrustedCertificateFile=/etc/ssl/ca/trusted.pem") | ||
[ ! -d /etc/systemd/journal-upload.conf.d/ ] && mkdir /etc/systemd/journal-upload.conf.d/ | ||
if grep -Psq -- '^\h*\[Upload\]' /etc/systemd/journal-upload.conf.d/60-journald_upload.conf; then | ||
printf '%s\n' "" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
else | ||
printf '%s\n' "" "[Upload]" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# packages = systemd-journal-remote | ||
# variables = var_journal_upload_conf_file=/etc/systemd/journal-upload.conf.d/60-journald_upload.conf,var_journal_upload_server_key_file=/etc/ssl/private/journal-upload.pem,var_journal_upload_server_certificate_file=/etc/ssl/certs/journal-upload.pem,var_journal_upload_server_trusted_certificate_file=/etc/ssl/ca/trusted.pem | ||
|
||
a_settings=("URL=192.168.50.42" "ServerKeyFile=/etc/ssl/private/journal-upload.pem" \ | ||
"TrustedCertificateFile=/etc/ssl/ca/trusted.pem") | ||
[ ! -d /etc/systemd/journal-upload.conf.d/ ] && mkdir /etc/systemd/journal-upload.conf.d/ | ||
if grep -Psq -- '^\h*\[Upload\]' /etc/systemd/journal-upload.conf.d/60-journald_upload.conf; then | ||
printf '%s\n' "" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
else | ||
printf '%s\n' "" "[Upload]" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# packages = systemd-journal-remote | ||
# variables = var_journal_upload_conf_file=/etc/systemd/journal-upload.conf.d/60-journald_upload.conf,var_journal_upload_server_key_file=/etc/ssl/private/journal-upload.pem,var_journal_upload_server_certificate_file=/etc/ssl/certs/journal-upload.pem,var_journal_upload_server_trusted_certificate_file=/etc/ssl/ca/trusted.pem | ||
|
||
a_settings=("URL=192.168.50.42" "ServerKeyFile=/etc/ssl/private/journal-upload.pem" \ | ||
"ServerCertificateFile=/etc/ssl/certs/journal-upload1.pem" "TrustedCertificateFile=/etc/ssl/ca/trusted.pem") | ||
[ ! -d /etc/systemd/journal-upload.conf.d/ ] && mkdir /etc/systemd/journal-upload.conf.d/ | ||
if grep -Psq -- '^\h*\[Upload\]' /etc/systemd/journal-upload.conf.d/60-journald_upload.conf; then | ||
printf '%s\n' "" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
else | ||
printf '%s\n' "" "[Upload]" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# packages = systemd-journal-remote | ||
# variables = var_journal_upload_conf_file=/etc/systemd/journal-upload.conf.d/60-journald_upload.conf,var_journal_upload_server_key_file=/etc/ssl/private/journal-upload.pem,var_journal_upload_server_certificate_file=/etc/ssl/certs/journal-upload.pem,var_journal_upload_server_trusted_certificate_file=/etc/ssl/ca/trusted.pem | ||
|
||
a_settings=("URL=192.168.50.42" \ | ||
"ServerCertificateFile=/etc/ssl/certs/journal-upload.pem" "TrustedCertificateFile=/etc/ssl/ca/trusted.pem") | ||
[ ! -d /etc/systemd/journal-upload.conf.d/ ] && mkdir /etc/systemd/journal-upload.conf.d/ | ||
if grep -Psq -- '^\h*\[Upload\]' /etc/systemd/journal-upload.conf.d/60-journald_upload.conf; then | ||
printf '%s\n' "" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
else | ||
printf '%s\n' "" "[Upload]" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# packages = systemd-journal-remote | ||
# variables = var_journal_upload_conf_file=/etc/systemd/journal-upload.conf.d/60-journald_upload.conf,var_journal_upload_server_key_file=/etc/ssl/private/journal-upload.pem,var_journal_upload_server_certificate_file=/etc/ssl/certs/journal-upload.pem,var_journal_upload_server_trusted_certificate_file=/etc/ssl/ca/trusted.pem | ||
|
||
a_settings=("URL=192.168.50.42" "ServerKeyFile=/etc/ssl/private/journal-upload1.pem" \ | ||
"ServerCertificateFile=/etc/ssl/certs/journal-upload.pem" "TrustedCertificateFile=/etc/ssl/ca/trusted.pem") | ||
[ ! -d /etc/systemd/journal-upload.conf.d/ ] && mkdir /etc/systemd/journal-upload.conf.d/ | ||
if grep -Psq -- '^\h*\[Upload\]' /etc/systemd/journal-upload.conf.d/60-journald_upload.conf; then | ||
printf '%s\n' "" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
else | ||
printf '%s\n' "" "[Upload]" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# packages = systemd-journal-remote | ||
# variables = var_journal_upload_conf_file=/etc/systemd/journal-upload.conf.d/60-journald_upload.conf,var_journal_upload_server_key_file=/etc/ssl/private/journal-upload.pem,var_journal_upload_server_certificate_file=/etc/ssl/certs/journal-upload.pem,var_journal_upload_server_trusted_certificate_file=/etc/ssl/ca/trusted.pem | ||
|
||
a_settings=("URL=192.168.50.42" "ServerKeyFile=/etc/ssl/private/journal-upload.pem" \ | ||
"ServerCertificateFile=/etc/ssl/certs/journal-upload.pem") | ||
[ ! -d /etc/systemd/journal-upload.conf.d/ ] && mkdir /etc/systemd/journal-upload.conf.d/ | ||
if grep -Psq -- '^\h*\[Upload\]' /etc/systemd/journal-upload.conf.d/60-journald_upload.conf; then | ||
printf '%s\n' "" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
else | ||
printf '%s\n' "" "[Upload]" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# packages = systemd-journal-remote | ||
# variables = var_journal_upload_conf_file=/etc/systemd/journal-upload.conf.d/60-journald_upload.conf,var_journal_upload_server_key_file=/etc/ssl/private/journal-upload.pem,var_journal_upload_server_certificate_file=/etc/ssl/certs/journal-upload.pem,var_journal_upload_server_trusted_certificate_file=/etc/ssl/ca/trusted.pem | ||
|
||
a_settings=("URL=192.168.50.42" "ServerKeyFile=/etc/ssl/private/journal-upload.pem" \ | ||
"ServerCertificateFile=/etc/ssl/certs/journal-upload.pem" "TrustedCertificateFile=/etc/ssl/ca/trusted1.pem") | ||
[ ! -d /etc/systemd/journal-upload.conf.d/ ] && mkdir /etc/systemd/journal-upload.conf.d/ | ||
if grep -Psq -- '^\h*\[Upload\]' /etc/systemd/journal-upload.conf.d/60-journald_upload.conf; then | ||
printf '%s\n' "" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
else | ||
printf '%s\n' "" "[Upload]" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# packages = systemd-journal-remote | ||
# variables = var_journal_upload_conf_file=/etc/systemd/journal-upload.conf,var_journal_upload_server_key_file=/etc/ssl/private/journal-upload.pem,var_journal_upload_server_certificate_file=/etc/ssl/certs/journal-upload.pem,var_journal_upload_server_trusted_certificate_file=/etc/ssl/ca/trusted.pem | ||
|
||
a_settings=("URL=192.168.50.42" "ServerKeyFile=/etc/ssl/private/journal-upload.pem" \ | ||
"ServerCertificateFile=/etc/ssl/certs/journal-upload.pem" "TrustedCertificateFile=/etc/ssl/ca/trusted.pem") | ||
[ ! -f /etc/systemd/journal-upload.conf/ ] && touch /etc/systemd/journal-upload.conf | ||
if grep -Psq -- '^\h*\[Upload\]' /etc/systemd/journal-upload.conf; then | ||
printf '%s\n' "" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf | ||
else | ||
printf '%s\n' "" "[Upload]" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
# platform = multi_platform_slmicro | ||
# platform = multi_platform_slmicro,multi_platform_ubuntu | ||
|
||
{{{ bash_instantiate_variables("var_journal_upload_conf_file") }}} | ||
{{{ bash_instantiate_variables("var_journal_upload_url") }}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See first comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't setting the default in the var_journal_upload_conf_file.var handle the slmicro case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I compile slmicro5 and it looks like it is ok. |
||
{{{ bash_replace_or_append('/etc/systemd/journal-upload.conf', '^URL', "$var_journal_upload_url", '%s=%s') }}} | ||
{{{ bash_replace_or_append('$var_journal_upload_conf_file', '^URL', "$var_journal_upload_url", '%s=%s') }}} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# packages = systemd-journal-remote | ||
# variables = var_journal_upload_conf_file=/etc/systemd/journal-upload.conf.d/60-journald_upload.conf,var_journal_upload_url=192.168.50.42 | ||
|
||
a_settings=("URL=192.168.50.42" "ServerKeyFile=/etc/ssl/private/journal-upload.pem" \ | ||
"ServerCertificateFile=/etc/ssl/certs/journal-upload.pem" "TrustedCertificateFile=/etc/ssl/ca/trusted.pem") | ||
[ ! -d /etc/systemd/journal-upload.conf.d/ ] && mkdir /etc/systemd/journal-upload.conf.d/ | ||
if grep -Psq -- '^\h*\[Upload\]' /etc/systemd/journal-upload.conf.d/60-journald_upload.conf; then | ||
printf '%s\n' "" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
else | ||
printf '%s\n' "" "[Upload]" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# packages = systemd-journal-remote | ||
# variables = var_journal_upload_conf_file=/etc/systemd/journal-upload.conf.d/60-journald_upload.conf,var_journal_upload_url=192.168.50.42 | ||
|
||
a_settings=("ServerKeyFile=/etc/ssl/private/journal-upload.pem" \ | ||
"ServerCertificateFile=/etc/ssl/certs/journal-upload.pem" "TrustedCertificateFile=/etc/ssl/ca/trusted.pem") | ||
[ ! -d /etc/systemd/journal-upload.conf.d/ ] && mkdir /etc/systemd/journal-upload.conf.d/ | ||
if grep -Psq -- '^\h*\[Upload\]' /etc/systemd/journal-upload.conf.d/60-journald_upload.conf; then | ||
printf '%s\n' "" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
else | ||
printf '%s\n' "" "[Upload]" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# packages = systemd-journal-remote | ||
# variables = var_journal_upload_conf_file=/etc/systemd/journal-upload.conf.d/60-journald_upload.conf,var_journal_upload_url=192.168.50.42 | ||
|
||
a_settings=("URL=192.168.50.41" "ServerKeyFile=/etc/ssl/private/journal-upload.pem" \ | ||
"ServerCertificateFile=/etc/ssl/certs/journal-upload.pem" "TrustedCertificateFile=/etc/ssl/ca/trusted.pem") | ||
[ ! -d /etc/systemd/journal-upload.conf.d/ ] && mkdir /etc/systemd/journal-upload.conf.d/ | ||
if grep -Psq -- '^\h*\[Upload\]' /etc/systemd/journal-upload.conf.d/60-journald_upload.conf; then | ||
printf '%s\n' "" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
else | ||
printf '%s\n' "" "[Upload]" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf.d/60-journald_upload.conf | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# packages = systemd-journal-remote | ||
# variables = var_journal_upload_conf_file=/etc/systemd/journal-upload.conf,var_journal_upload_url=192.168.50.42 | ||
|
||
a_settings=("URL=192.168.50.42" "ServerKeyFile=/etc/ssl/private/journal-upload.pem" \ | ||
"ServerCertificateFile=/etc/ssl/certs/journal-upload.pem" "TrustedCertificateFile=/etc/ssl/ca/trusted.pem") | ||
[ ! -f /etc/systemd/journal-upload.conf ] && mkdir /etc/systemd/journal-upload.conf | ||
if grep -Psq -- '^\h*\[Upload\]' /etc/systemd/journal-upload.conf; then | ||
printf '%s\n' "" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf | ||
else | ||
printf '%s\n' "" "[Upload]" "${a_settings[@]}" >> /etc/systemd/journal-upload.conf | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
documentation_complete: true | ||
|
||
title: 'Remote server for systemd-journal-upload service' | ||
|
||
description: |- | ||
The filepath of the journal-upload config file. Options are /etc/systemd/journal-upload.conf or a | ||
file in the /etc/systemd/journal-upload.conf.d directory. | ||
|
||
type: string | ||
|
||
interactive: true | ||
|
||
options: | ||
default: /etc/systemd/journal-upload.conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes would affect slmicro too.
Use a ubuntu-specific remediation file (ubuntu.sh) or place the code inside conditionals, e.g.
That said, I couldn't find the XCCDF variable
var_journal_upload_conf_file
in the codebase.If you want to introduce a new variable you need to create it, analogous to
/linux_os/guide/system/logging/journald/var_journal_upload_url.var
.For this specific case, I wouldn't recommend using an XCCDF variable though, since config file locations are not something that we generally let the users specify at runtime. Config file paths are mostly hardcoded into the rules. If they differ across OS-es they can be defined via conditionals or via Jinja variables defined in
product.yml
files.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the file you were looking for (that I created): https://github.com/ComplianceAsCode/content/blob/53a6846f6f0f92cc4bbafd56246c32af110f6e8c/linux_os/guide/system/logging/journald/var_journal_upload_conf_file.var
Doesn't the default setting take care of the slmicro case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably 95% of the time, I would think they use the default filename (/etc/systemd/journal-update.conf). But I think the new way of configuring is to create a file in the /etc/systemd/journal-update.conf.d directory now. I needed to be able to change the name of the file for the tests so that I could specify files in the conf.d directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, if you define the default as you did now this will make the slmicro5 remediation work as before, but only as long as the end user doesn't modify the XCCDF variable. I'm not sure if SUSE want this path to be modifiable. If they do, then the ansible remediation also needs to be adjusted, since it will not work the same way the bash remediation works on slmicro5 at the moment.
Regarding introducing the new XCCDF variable for the config file - the only other instance I could find in linux_os is var_nftables_master_config_file. This approach is not very common in CaC, but it does have the advantage that the user can define a custom path for their config if needed. It's not needed for tests though. Instead of hardcoding the variable override in
# variables
, it would work equally to hardcode the paths in separate scenarios, similar to how it's done in sshd_lineinfile template, e.g.missing-servercert.fail.sh
: wipes all configs in.d
directory and writes to/etc/systemd/journal-upload.conf
missing-servercert-confd.fail.sh
: writes to/etc/systemd/journal-upload.conf.d/60-journald_upload.conf
and wipes the contents of/etc/systemd/journal-upload.conf