|
|
|
@ -35,16 +35,8 @@ if os.path.exists('/etc/master.passwd'):
|
|
|
|
|
# invoke adduser in lieu of useradd, nor pw in lieu of usermod.
|
|
|
|
|
# That is, this won't work on FreeBSD.
|
|
|
|
|
|
|
|
|
|
def get_bin_path(module, arg):
|
|
|
|
|
if os.path.exists('/usr/sbin/%s' % arg):
|
|
|
|
|
return '/usr/sbin/%s' % arg
|
|
|
|
|
elif os.path.exists('/sbin/%s' % arg):
|
|
|
|
|
return '/sbin/%s' % arg
|
|
|
|
|
else:
|
|
|
|
|
module.fail_json(msg="Cannot find %s" % arg)
|
|
|
|
|
|
|
|
|
|
def user_del(module, user, **kwargs):
|
|
|
|
|
cmd = [get_bin_path(module, 'userdel')]
|
|
|
|
|
cmd = [module.get_bin_path('userdel', True)]
|
|
|
|
|
for key in kwargs:
|
|
|
|
|
if key == 'force' and kwargs[key] == 'yes':
|
|
|
|
|
cmd.append('-f')
|
|
|
|
@ -57,7 +49,7 @@ def user_del(module, user, **kwargs):
|
|
|
|
|
return (rc, out, err)
|
|
|
|
|
|
|
|
|
|
def user_add(module, user, **kwargs):
|
|
|
|
|
cmd = [get_bin_path(module, 'useradd')]
|
|
|
|
|
cmd = [module.get_bin_path('useradd', True)]
|
|
|
|
|
for key in kwargs:
|
|
|
|
|
if key == 'uid' and kwargs[key] is not None:
|
|
|
|
|
cmd.append('-u')
|
|
|
|
@ -104,7 +96,7 @@ Without spwd, we would have to resort to reading /etc/shadow
|
|
|
|
|
to get the encrypted string. For now, punt on idempotent password changes.
|
|
|
|
|
"""
|
|
|
|
|
def user_mod(module, user, **kwargs):
|
|
|
|
|
cmd = [get_bin_path(module, 'usermod')]
|
|
|
|
|
cmd = [module.get_bin_path('usermod', True)]
|
|
|
|
|
info = user_info(user)
|
|
|
|
|
for key in kwargs:
|
|
|
|
|
if key == 'uid':
|
|
|
|
|