mirror of https://github.com/jumpserver/jumpserver
[Bugfix] 修改创建系统用户的bug
parent
45f6a62989
commit
114289edaf
|
@ -308,7 +308,7 @@ class SystemUserForm(PasswordAndKeyAuthForm):
|
|||
auto_generate_key = self.cleaned_data.get('auto_generate_key', False)
|
||||
private_key, public_key = super().gen_keys()
|
||||
|
||||
if not self.instance and auto_generate_key:
|
||||
if auto_generate_key:
|
||||
logger.info('Auto generate key and set system user auth')
|
||||
system_user.auto_gen_auth()
|
||||
else:
|
||||
|
|
|
@ -314,8 +314,10 @@ def get_push_system_user_tasks(system_user):
|
|||
if system_user.username == "root":
|
||||
return []
|
||||
|
||||
tasks = [
|
||||
{
|
||||
tasks = []
|
||||
|
||||
if system_user.password:
|
||||
tasks.append({
|
||||
'name': 'Add user {}'.format(system_user.username),
|
||||
'action': {
|
||||
'module': 'user',
|
||||
|
@ -324,8 +326,9 @@ def get_push_system_user_tasks(system_user):
|
|||
encrypt_password(system_user.password, salt="K3mIlKK"),
|
||||
),
|
||||
}
|
||||
},
|
||||
{
|
||||
})
|
||||
if system_user.public_key:
|
||||
tasks.append({
|
||||
'name': 'Set {} authorized key'.format(system_user.username),
|
||||
'action': {
|
||||
'module': 'authorized_key',
|
||||
|
@ -333,8 +336,9 @@ def get_push_system_user_tasks(system_user):
|
|||
system_user.username, system_user.public_key
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
})
|
||||
if system_user.sudo:
|
||||
tasks.append({
|
||||
'name': 'Set {} sudo setting'.format(system_user.username),
|
||||
'action': {
|
||||
'module': 'lineinfile',
|
||||
|
@ -345,8 +349,7 @@ def get_push_system_user_tasks(system_user):
|
|||
system_user.sudo,
|
||||
)
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
return tasks
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue