Skip to content

Commit

Permalink
tests: create intelmq user & group if running privileged
Browse files Browse the repository at this point in the history
if the tests already run with an unprivileged user, all is good, but if
running as root, intelmq won't be able to un-privilege itself if there's
no intelmq user
  • Loading branch information
sebix committed Dec 1, 2024
1 parent 23e5d1c commit 630422f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .github/workflows/scripts/setup-full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ done
# Setup sudo and install intelmq
sudo sed -i '/^Defaults\tsecure_path.*$/ d' /etc/sudoers
sudo pip install .
sudo intelmqsetup --skip-ownership

intelmq_user_exists=$(getent passwd intelmq ||:)
if [[ "$UID" -eq '0' && -z "$intelmq_user_exists" ]]; then
# create an unprivileged user, if currently running as root. Otherwise dropping privileges won't work
groupadd -r intelmq
useradd -r -d /var/lib/intelmq/ -c "user running intelmq" -g intelmq -s /bin/bash intelmq
sudo intelmqsetup
else
sudo intelmqsetup --skip-ownership
fi

# Initialize the postgres database
intelmq_psql_initdb
Expand Down

0 comments on commit 630422f

Please sign in to comment.