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

use runuser instead of su to run rake as the foreman user #9839

Merged
merged 1 commit into from
Sep 21, 2023

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented Sep 21, 2023

foreman-rake is designed to be run as root (and switch to foreman) or by foreman directly. any other user can't use it as it is installed in sbin and the foreman user has no password set, making switching users as non root impossible, but su will still try it:

[nobody@foreman /]$ su foreman -s /bin/bash -c id
Password:
[nobody@foreman /]$ foreman-rake console
Password:

runuser is designed to be used in scripts and refuses to work as non root:

[nobody@foreman /]$ runuser foreman -s /bin/bash -c id
runuser: may not be used by non-root users
[nobody@foreman /]$ foreman-rake console
runuser: may not be used by non-root users

Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work well. Do we have a redmine for this?

@evgeni
Copy link
Member Author

evgeni commented Sep 21, 2023

Seems to work well. Do we have a redmine for this?

I could create one ;-)

Yes

foreman-rake is designed to be run as root (and switch to foreman) or by
foreman directly. any other user can't use it as it is installed in sbin
and the foreman user has no password set, making switching users as non
root impossible, but su will still try it:

    [nobody@foreman /]$ su foreman -s /bin/bash -c id
    Password:
    [nobody@foreman /]$ foreman-rake console
    Password:

runuser is designed to be used in scripts and refuses to work as non
root:

    [nobody@foreman /]$ runuser foreman -s /bin/bash -c id
    runuser: may not be used by non-root users
    [nobody@foreman /]$ foreman-rake console
    runuser: may not be used by non-root users
@evgeni
Copy link
Member Author

evgeni commented Sep 21, 2023

[test unit]

@evgeni evgeni merged commit 3636aec into theforeman:develop Sep 21, 2023
6 checks passed
@evgeni evgeni deleted the runuser branch September 21, 2023 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants