Skip to content
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

ENH: utils: acquire groups of intelmq user in drop_privileges #2507

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### Configuration

### Core
- `intelmq.lib.utils.drop_privileges`: When IntelMQ is called as `root` and dropping the privileges to user `intelmq`, also set the non-primary groups associated with the `intelmq` user. Makes the behaviour of running intelmqctl as `root` closer to the behaviour of `sudo -u intelmq ...` (PR#2507 by Mikk Margus Möll).

### Development

Expand Down
1 change: 1 addition & 0 deletions intelmq/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ def drop_privileges() -> bool:
"""
if os.geteuid() == 0:
try:
os.setgroups([group.gr_gid for group in grp.getgrall() if 'intelmq' in group.gr_mem])
os.setgid(grp.getgrnam('intelmq').gr_gid)
os.setuid(pwd.getpwnam('intelmq').pw_uid)
except (OSError, KeyError):
Expand Down
Loading