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

Introduce --no-impersonate flag #10321

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Introduce --no-impersonate flag #10321

wants to merge 2 commits into from

Conversation

oxzi
Copy link
Member

@oxzi oxzi commented Jan 24, 2025

  • Remove unnecessary GetImpersonationLevel in childs

    The base class CLICommand implements the GetImpersonationLevel method to always return ImpersonateIcinga. This method was overridden in some child classes with the exact same implementation.

    As this is both unnecessary and I am planning to rewrite the base class implementation, these overridden methods were removed. Now there is only the base implementation and one child with another ImpersonationLevel
    left.

  • Dynamic ImpersonationLevel via --no-impersonate flag

    By default, icinga2 uses icinga:icinga as user and group, or whatever is configured via ICINGA2_USER and ICINGA2_GROUP. Thus, it is required to launch icinga2 as this user or as a privileged user, allowed to setuid.

    The only command where no user impersonation is necessary is "icinga2 console".

    However, in certain scenarios one cannot switch to a static user. There might also be the case that privileges are already dropped, e.g., by an init manager. Therefore, the "--no-impersonate" flag was introduced, skipping all impersonation logic.

    $ icinga2 daemon
    critical/cli: Invalid group specified: icinga
    $ icinga2 daemon --no-impersonate
    [2025-01-24 10:42:41 +0100] information/cli: Icinga application loader (version: v2.14.0-439-ga5980d362)

Closes #10307.
Closes #10308.

oxzi added 2 commits January 23, 2025 17:35
The base class CLICommand implements the GetImpersonationLevel method to
always return ImpersonateIcinga. This method was overridden in some
child classes with the exact same implementation.

As this is both unnecessary and I am planning to rewrite the base class
implementation, these overridden methods were removed. Now there is only
the base implementation and one child with another ImpersonationLevel
left.
By default, icinga2 uses icinga:icinga as user and group, or whatever is
configured via ICINGA2_USER and ICINGA2_GROUP. Thus, it is required to
launch icinga2 as this user or as a privileged user, allowed to setuid.

The only command where no user impersonation is necessary is "icinga2
console".

However, in certain scenarios one cannot switch to a static user. There
might also be the case that privileges are already dropped, e.g., by an
init manager. Therefore, the "--no-impersonate" flag was introduced,
skipping all impersonation logic.

> $ icinga2 daemon
critical/cli: Invalid group specified: icinga
> $ icinga2 daemon --no-impersonate
[2025-01-24 10:42:41 +0100] information/cli: Icinga application loader (version: v2.14.0-439-ga5980d362)

Closes #10307.
@oxzi
Copy link
Member Author

oxzi commented Jan 24, 2025

I would also like to document this feature, but created #10323 first as there were some outdated information in this section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli Command line helpers cla/signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow running as arbitrary UID for unprivileged Container Environments (OpenShift)
1 participant