Skip to content

Commit

Permalink
test: add test case for issue user journal corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
mrc0mmand authored and yuwata committed Feb 14, 2024
1 parent a37453f commit ed231f1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/TEST-04-JOURNAL/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ test_append_files() {
mkdir -p "$dropin_dir"
printf '[Service]\nStandardOutput=journal+console\nStandardError=journal+console' >"$dropin_dir/99-stdout.conf"
fi

image_install sudo
inst /etc/sudoers
inst_recursive /usr/libexec/sudo/
}

do_test "$@"
2 changes: 1 addition & 1 deletion test/test-functions
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,7 @@ install_testuser() {
# create unprivileged user for user manager tests
mkdir -p "${initdir:?}/etc/sysusers.d"
cat >"$initdir/etc/sysusers.d/testuser.conf" <<EOF
u testuser 4711 "Test User" /home/testuser
u testuser 4711 "Test User" /home/testuser /bin/bash
EOF

mkdir -p "$initdir/home/testuser"
Expand Down
31 changes: 31 additions & 0 deletions test/units/testsuite-04.user-corrupt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux
set -o pipefail

mkdir -p /etc/sudoers.d/
echo "testuser ALL=(ALL) NOPASSWD: ALL" >/etc/sudoers.d/testuser

REPRO_SCRIPT="$(mktemp)"

cat >"$REPRO_SCRIPT" <<\EOF
#!/bin/bash
set -eux
set -o pipefail
journalctl --rotate --vacuum-files=1
# Nuke all archived journals, so we start with a clean slate
rm -f /var/log/journal/$(</etc/machine-id)/system@*.journal
rm -f /var/log/journal/$(</etc/machine-id)/user-*@*.journal
journalctl --header | grep path
for i in {0..10}; do
journalctl --rotate
journalctl --sync
SYSTEMD_LOG_LEVEL=debug journalctl -n1 -q
(! journalctl -n0 -q |& grep corrupted)
done
EOF
chmod +x "$REPRO_SCRIPT"

systemd-run --wait --pipe --user -M testuser@ -- sudo "$REPRO_SCRIPT"

0 comments on commit ed231f1

Please sign in to comment.