[System] Can't add groups to a user
dshoreman opened this issue · comments
After creating a new regular user in System > Users, attempts to add the sudo
group to that user will fail.
It's this chunk of code that's throwing, reporting "exit code 2":
Lines 123 to 128 in ddee8af
Moving the full command to a variable (so it could be dumped in the exception) shows the generated command as being sudo usermod -G "sudo" -m newuser
. It looks fine at first glance, but running that command in a shell reveals the error:
usermod: -m flag is only allowed with the -d flag
According to the options, -m
in usermod is an alias of --move-home
, which is likely not what we want! Where is that coming from?
It would also be worth capturing (or redirecting to stdout
) the stderr
output and logging it somewhere when there errors happen so we have a bit more info to go by in future.
Looks like the frontend is always (or perhaps only when a dir is set) sending move_home: true
with the request, which causes -m
to be added via setMoveHome()
in System\User
:
Lines 100 to 108 in ddee8af
setHomeDirectory()
will ensure the home directory has changed before adding the -d
option, but this check is not applied in setMoveHome()
which is why we end up with a bad command.