-
Notifications
You must be signed in to change notification settings - Fork 58
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
Change adduser to useradd #61
base: master
Are you sure you want to change the base?
Conversation
…256000 Signed-off-by: Kjeld Flarup <[email protected]>
Signed-off-by: Kjeld Flarup <[email protected]>
thanks for your work -> great idea with just installing those utils (it didn't occure to me 😄) I need to look into it and test it before I can merge it (to many users to risk it) but looks really nice! thanks and kind regards Marvin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kjeldflarup, you missed addgroup
on L113.
-addgroup "$ACCOUNT_NAME" "$GRP"
+usermod -aG "$GRP" "$ACCOUNT_NAME"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I just pushed a commit with that change, but I did not test it :-)
But according to my man page, this addgroup command also seems to be incorrect, or at least not portable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not test it :-)
I tested it on Ubutu and Alipine Linux, it works as expected. 😉
But according to my man page, this addgroup command also seems to be incorrect, or at least not portable.
The old adduser
command works on Alpine Linux, where it is installed as part of Busybox which is quite limited and uses different options from its other implementations.
Signed-off-by: Kjeld Flarup <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kjeldflarup, I have found a few issues still. 😉
Here is a table with the options used by adduser
in this repository with corresponding useradd
options.
adduser |
useradd |
Description from adduser |
---|---|---|
-H | -M | Don't create home directory |
-D | n/a | Don't assign a password |
-s SHELL | -s SHELL | Login shell |
-u UID | -u UID | User id |
As for -D
from adduser
, for useradd
it is not required, as this is the default in useradd
. Excerpt from man useradd
on -p, --password PASSWORD
:
Without this option, the new account will be locked and with no password defined, i.e. a single exclamation mark in the respective field of /etc/shadow. This is a state where the user won't be able to access the account or to define a password himself.
@@ -87,10 +87,10 @@ if [ ! -f "$INITALIZED" ]; then | |||
if [ "$ACCOUNT_UID" -gt 0 ] 2>/dev/null | |||
then | |||
echo ">> ACCOUNT: adding account: $ACCOUNT_NAME with UID: $ACCOUNT_UID" | |||
adduser -D -H -u "$ACCOUNT_UID" -s /bin/false "$ACCOUNT_NAME" | |||
useradd -u "$ACCOUNT_UID" -s /bin/false "$ACCOUNT_NAME" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are missing -M
(Do not create the user's home directory, even if the system wide setting from /etc/login.defs (CREATE_HOME) is set to yes.
).
useradd -u "$ACCOUNT_UID" -s /bin/false "$ACCOUNT_NAME" | |
useradd -Mu "$ACCOUNT_UID" -s /bin/false "$ACCOUNT_NAME" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we probably want to add -N
to not create user group. 🤔
@@ -14,12 +14,12 @@ echo | |||
|
|||
if [ "$PASSWORD_1" == "$PASSWORD_2" ] && [ "$PASSWORD_1" != "" ] && [ "$USERNAME" != "" ] | |||
then | |||
adduser -D -H -s /bin/false "$USERNAME" 2> /dev/null >/dev/null | |||
useradd -u "$ACCOUNT_UID" -s /bin/false "$ACCOUNT_NAME" 2> /dev/null >/dev/null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you have a mistake: ACCOUNT_UID
is not defined in this file. And you are missing -M
.
useradd -u "$ACCOUNT_UID" -s /bin/false "$ACCOUNT_NAME" 2> /dev/null >/dev/null | |
useradd -Ms /bin/false "$ACCOUNT_NAME" 2> /dev/null >/dev/null |
else | ||
echo ">> ACCOUNT: adding account: $ACCOUNT_NAME" | ||
adduser -D -H -s /bin/false "$ACCOUNT_NAME" | ||
useradd -s /bin/false "$ACCOUNT_NAME" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useradd -s /bin/false "$ACCOUNT_NAME" | |
useradd -Ms /bin/false "$ACCOUNT_NAME" |
I get my UID from an AD which uses very large number.
adduser and addgroup commands does not accept these large numbers (at least not in this alpine version)
When creating users and groups change to useradd and groupadd
Signed-off-by: Kjeld Flarup [email protected]