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 d94c303 commit b7f9cf3
Show file tree
Hide file tree
Showing 2 changed files with 11 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
### Tests
- Install build dependencies for `pymssql` on Python 3.8 as there are no wheels available for this Python version (PR#2542 by Sebastian Wagner).
- Install `psql` explicitly for workflow support on other plattforms such as act (PR#2542 by Sebastian Wagner).
- Create intelmq user & group if running privileged to allow dropping privileges (PR#2542 by Sebastian Wagner).

### Tools

Expand Down

0 comments on commit b7f9cf3

Please sign in to comment.