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

initContainer: Only remove password when needed #533

Closed

Conversation

HarryMichal
Copy link
Member

@HarryMichal HarryMichal commented Aug 20, 2020

When a newly created container has already the current user created
inside of it then the user initialization section of command
'init-container' is not triggered. The user init section currently takes
care of:

  1. symlinking /home to /var/home if called with option --home-link

  2. creating user set by --user, --uid, --home and --shell

  3. adds the user to the sudoers group (either sudo or wheel)

  4. removes password of user and of root

This commit does the following:

  • moves 1) before the user init section and makes calling it
    conditional depending on /home being a symlink or not
  • moves 4) after the user init section and depending on the output of
    'passwd --status' (that is expected to be NP; more in 'man
    passwd(1)') calls the said sections

Partially fixes #523

HarryMichal added a commit to HarryMichal/toolbox that referenced this pull request Aug 20, 2020
When a newly created container has already the current user created
inside of it then the user initialization section of command
'init-container' is not triggered. The user init section currently takes
care of:

  1) symlinking /home to /var/home if called with option --home-link
  2a) creating user set by --user, --uid, --home and --shell
  2b) adds the user to the sudoers group (either sudo or wheel)
  3) removes password of user and of root

This commit does the following:

  - moves 1) before the user init section and makes calling it
    conditional depending on /home being a symlink or not
  - moves 3) after the user init section and depending on the output of
    'passwd --status' (that is expected to be NP; more in 'man
    passwd(1)') calls the said sections

containers#533
@HarryMichal HarryMichal force-pushed the restructure-user-init branch from a335eff to f14771a Compare August 20, 2020 14:21
@HarryMichal HarryMichal added 3. Bugfix Fixes a bug 6. Minor Change Should not cause breakage labels Aug 20, 2020
@HarryMichal HarryMichal added this to the Release 0.1.0 milestone Aug 20, 2020
@softwarefactory-project-zuul
Copy link

Build failed.

Copy link
Member

@debarshiray debarshiray left a comment

Choose a reason for hiding this comment

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

Oops! Sorry, I failed to notice this PR. :(

Is it still relevant after #547 ?

@HarryMichal
Copy link
Member Author

Oops! Sorry, I failed to notice this PR. :(

Is it still relevant after #547 ?

I'll have to adjust it but I'd say "yes". This PR does not touch useradd or usermod. I should also split it into several commits because now I see I tried to achieve several different things with this.

@HarryMichal HarryMichal changed the title initContainer: Restructure user initialiation initContainer: Only remove password when needed Sep 22, 2020
@HarryMichal
Copy link
Member Author

In the end, I only took one part from the original PR: making password removal conditional to prevent log cluttering. What do you think about it, @debarshiray?

@softwarefactory-project-zuul
Copy link

Build failed.

When looking into logs of toolboxes using 'podman logs', one can notice
that every "startup" log mentions removing the password for the user and
root. These lines could be considered as bloat because what they're
saying is actually not happening because appart from the first run the
password are usually already gone.

This makes the removal of password for the user and root conditional
based on the output of 'passwd --status <username>' where value "NP"
(meaning "no password") will be considered the only value that does not
trigger the removal. Any other value will trigger the removal.
@softwarefactory-project-zuul
Copy link

Build failed.

Copy link
Member

@debarshiray debarshiray left a comment

Choose a reason for hiding this comment

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

Umm... I am a bit torn about this.

Only deleting the password when some spurious password is set seems like a reasonable thing to do, but it happens only once at container start-up so we don't actually save much. Moreover, the fork and exec to run the passwd process, which is relatively costly, still happens and in the worst case will happen twice.

So, not sure. Seems like more lines of code for no real benefit. :)

@HarryMichal
Copy link
Member Author

Fair enough. Let's close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. Bugfix Fixes a bug 6. Minor Change Should not cause breakage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sudo(8) inside toolbox containers asks for a password with Podman 2.0.5
2 participants