|
|
@ -508,20 +508,24 @@ class FreeBsdUser(User):
|
|
|
|
SHADOWFILE = '/etc/master.passwd'
|
|
|
|
SHADOWFILE = '/etc/master.passwd'
|
|
|
|
|
|
|
|
|
|
|
|
def remove_user(self):
|
|
|
|
def remove_user(self):
|
|
|
|
cmd = [self.module.get_bin_path('pw', True),
|
|
|
|
cmd = [
|
|
|
|
'userdel',
|
|
|
|
self.module.get_bin_path('pw', True),
|
|
|
|
'-n',
|
|
|
|
'userdel',
|
|
|
|
self.name ]
|
|
|
|
'-n',
|
|
|
|
|
|
|
|
self.name
|
|
|
|
|
|
|
|
]
|
|
|
|
if self.remove:
|
|
|
|
if self.remove:
|
|
|
|
cmd.append('-r')
|
|
|
|
cmd.append('-r')
|
|
|
|
|
|
|
|
|
|
|
|
return self.execute_command(cmd)
|
|
|
|
return self.execute_command(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
def create_user(self):
|
|
|
|
def create_user(self):
|
|
|
|
cmd = [self.module.get_bin_path('pw', True),
|
|
|
|
cmd = [
|
|
|
|
'useradd',
|
|
|
|
self.module.get_bin_path('pw', True),
|
|
|
|
'-n',
|
|
|
|
'useradd',
|
|
|
|
self.name ]
|
|
|
|
'-n',
|
|
|
|
|
|
|
|
self.name
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
if self.uid is not None:
|
|
|
|
if self.uid is not None:
|
|
|
|
cmd.append('-u')
|
|
|
|
cmd.append('-u')
|
|
|
@ -563,19 +567,23 @@ class FreeBsdUser(User):
|
|
|
|
|
|
|
|
|
|
|
|
# we have to set the password in a second command
|
|
|
|
# we have to set the password in a second command
|
|
|
|
if self.password is not None:
|
|
|
|
if self.password is not None:
|
|
|
|
cmd = [self.module.get_bin_path('chpass', True),
|
|
|
|
cmd = [
|
|
|
|
'-p',
|
|
|
|
self.module.get_bin_path('chpass', True),
|
|
|
|
self.password,
|
|
|
|
'-p',
|
|
|
|
self.name ]
|
|
|
|
self.password,
|
|
|
|
|
|
|
|
self.name
|
|
|
|
|
|
|
|
]
|
|
|
|
return self.execute_command(cmd)
|
|
|
|
return self.execute_command(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
return (rc, out, err)
|
|
|
|
return (rc, out, err)
|
|
|
|
|
|
|
|
|
|
|
|
def modify_user(self):
|
|
|
|
def modify_user(self):
|
|
|
|
cmd = [self.module.get_bin_path('pw', True),
|
|
|
|
cmd = [
|
|
|
|
'usermod',
|
|
|
|
self.module.get_bin_path('pw', True),
|
|
|
|
'-n',
|
|
|
|
'usermod',
|
|
|
|
self.name ]
|
|
|
|
'-n',
|
|
|
|
|
|
|
|
self.name
|
|
|
|
|
|
|
|
]
|
|
|
|
cmd_len = len(cmd)
|
|
|
|
cmd_len = len(cmd)
|
|
|
|
info = self.user_info()
|
|
|
|
info = self.user_info()
|
|
|
|
|
|
|
|
|
|
|
@ -639,10 +647,12 @@ class FreeBsdUser(User):
|
|
|
|
|
|
|
|
|
|
|
|
# we have to set the password in a second command
|
|
|
|
# we have to set the password in a second command
|
|
|
|
if self.password is not None and info[1] != self.password:
|
|
|
|
if self.password is not None and info[1] != self.password:
|
|
|
|
cmd = [self.module.get_bin_path('chpass', True),
|
|
|
|
cmd = [
|
|
|
|
'-p',
|
|
|
|
self.module.get_bin_path('chpass', True),
|
|
|
|
self.password,
|
|
|
|
'-p',
|
|
|
|
self.name ]
|
|
|
|
self.password,
|
|
|
|
|
|
|
|
self.name
|
|
|
|
|
|
|
|
]
|
|
|
|
return self.execute_command(cmd)
|
|
|
|
return self.execute_command(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
return (rc, out, err)
|
|
|
|
return (rc, out, err)
|
|
|
|