When linux_user modifies a user to set it's homedir, if that homedir exists, it tries to create it, fails, and fails the run.
It looks like this is from passing -m always
14.13.11
Ubuntu 18.04
setup a user. change it's homedir to something that exists.
---- Begin output of ["usermod", "-d", "/var/lib/openvpn/chroot", "-m", "nm-openvpn"]
----
STDOUT:
STDERR: usermod: directory /var/lib/openvpn/chroot exists
---- End output of ["usermod", "-d", "/var/lib/openvpn/chroot", "-m", "nm-openvpn"] -
---
Ran ["usermod", "-d", "/var/lib/openvpn/chroot", "-m", "nm-openvpn"] returned 12
Based on what I know about the "usermod" command, that message is purely informational and should not be evaluating the "
Chef is not actually attempting to re-create the directory, it is simply reading the resulting message as an error when the directory already exists.
[root@dev ~]# useradd test_user
[root@dev ~]# mkdir /home/test_user
mkdir: cannot create directory ‘/home/test_user’: File exists
[root@dev ~]# mkdir /home/new_test_user_dir
[root@dev ~]# usermod -d /home/new_test_user_dir -m test_user
usermod: directory /home/new_test_user_dir exists
[root@dev ~]# echo $?
12
Yeah, it's def usermod. But the question is can we handle this better. The man page doesn't list the exit codes, but if 12 is unique to this, then we could set the allowed exit codes to [0,12].
Yeah I agree. I haven't actively contributed to this project before, but I'll take a crack at it.
For reference, the entry reference in usermod that corresponds to code 12: https://github.com/shadow-maint/shadow/blob/b49712ed328ded0cd8161542ca13cf5d4cf55e5f/src/usermod.c#L92
"/* unable to complete home dir move */"
Created branch on my fork
https://github.com/skippyj/chef/commit/768d0f18a091622902e7eefcb6b2f68bc17d3145
Most helpful comment
For reference, the entry reference in usermod that corresponds to code 12: https://github.com/shadow-maint/shadow/blob/b49712ed328ded0cd8161542ca13cf5d4cf55e5f/src/usermod.c#L92
"/* unable to complete home dir move */"