|
|
@ -25,9 +25,13 @@ import os
|
|
|
|
import pwd
|
|
|
|
import pwd
|
|
|
|
import grp
|
|
|
|
import grp
|
|
|
|
import shlex
|
|
|
|
import shlex
|
|
|
|
import spwd
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
import spwd
|
|
|
|
|
|
|
|
HAVE_SPWD=True
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
HAVE_SPWD=False
|
|
|
|
|
|
|
|
|
|
|
|
USERADD = "/usr/sbin/useradd"
|
|
|
|
USERADD = "/usr/sbin/useradd"
|
|
|
|
USERMOD = "/usr/sbin/usermod"
|
|
|
|
USERMOD = "/usr/sbin/usermod"
|
|
|
@ -119,6 +123,10 @@ def user_add(user, **kwargs):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
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(user, **kwargs):
|
|
|
|
def user_mod(user, **kwargs):
|
|
|
|
cmd = [USERMOD]
|
|
|
|
cmd = [USERMOD]
|
|
|
|
info = user_info(user)
|
|
|
|
info = user_info(user)
|
|
|
@ -227,9 +235,11 @@ def user_info(user):
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
info = get_pwd_info(user)
|
|
|
|
info = get_pwd_info(user)
|
|
|
|
|
|
|
|
if HAVE_SPWD:
|
|
|
|
sinfo = spwd.getspnam(user)
|
|
|
|
sinfo = spwd.getspnam(user)
|
|
|
|
except KeyError:
|
|
|
|
except KeyError:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
if HAVE_SPWD:
|
|
|
|
info[1] = sinfo[1]
|
|
|
|
info[1] = sinfo[1]
|
|
|
|
return info
|
|
|
|
return info
|
|
|
|
|
|
|
|
|
|
|
|