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

Changed how passwords are generated and persisted #543

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pacohope
Copy link

There are a few bugs in the lines that deal with user password. One could argue that the line that calls chpasswd is the primary bug: it always runs, whether we have just generated the password or not. Rather than make a big messy pull request that changes the order of a bunch of things in the file, I just make the initial password determination logic more careful. So we can run the chpasswd command every time the container starts and it will do the right thing.

incorrect behaviours

  1. It writes the whole phrase Password set to: xyz into the file /root/password. Seems like it should write xyz and nothing else.
  2. If the /root/password file exists, the variable USER_PASSWORD is NOT set to the file's contents. So later, when the chpasswd command runs, the password is clobbered

this update

This update makes things a bit clearer on password handling.

  1. If the password comes in from the environment, there's no need to store it in the container. Just use it.
  2. If the password is not the environment, check for /root/password
    • If there's no stored password, make one and store it
    • If there's a stored password use it

A couple other small fixes: I just use $RANDOM a few times for the password. I also used tee in the pipeline to write it to /root/password in one simple motion.

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.

1 participant