Dekleted password option for website users
This commit is contained in:
parent
f08b057cd1
commit
5621dd6c34
1 changed files with 21 additions and 6 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from modules.pastafari2.libraries.task import Task
|
||||
from modules.pastafari2.models.pastafari2 import ServerDbTask
|
||||
import os
|
||||
from subprocess import call
|
||||
|
||||
class ServerTask(Task):
|
||||
|
||||
|
|
@ -31,23 +32,37 @@ class ServerTask(Task):
|
|||
f.write(self.data['ssh_pub_key'])
|
||||
ssh_pub_key_file='./modules/webservers/scripts/files/id_rsa.pub'
|
||||
self.files.append([ssh_pub_key_file, 0o600])
|
||||
|
||||
# ssh-keygen -l -f id_rsa.pub
|
||||
|
||||
if call("ssh-keygen -l -f {}".format(ssh_pub_key_file), shell=True) > 0:
|
||||
self.logtask.insert({'status':1, 'progress': 100, 'error': 1, 'task_id': self.id, 'server': self.server, 'message': 'INVALID PUB KEY %s' % "{}".format(ssh_pub_key_file)})
|
||||
#os.unlink(ssh_pub_key_file)
|
||||
return False
|
||||
|
||||
else:
|
||||
self.logtask.insert({'status':1, 'progress': 100, 'error': 1, 'task_id': self.task_id, 'server': self.server, 'message': 'No exists ssh pub key'})
|
||||
return False
|
||||
|
||||
final_ssh_pub='--ssh_pub_key_file="'+ssh_pub_key_file+'"'
|
||||
|
||||
"""
|
||||
final_password=''
|
||||
|
||||
if self.data['password']!='':
|
||||
final_password='--password=%s' % self.data['password']
|
||||
"""
|
||||
|
||||
self.commands_to_execute.append(['modules/pastafari2/scripts/system/change_password.py', '--user=%s %s %s' % (self.data['user'], final_password, final_ssh_pub), 'sudo'])
|
||||
self.commands_to_execute.append(['modules/pastafari2/scripts/system/change_password.py', '--user=%s %s' % (self.data['user'], final_ssh_pub), 'sudo'])
|
||||
|
||||
return True
|
||||
|
||||
"""
|
||||
|
||||
def post_task(self):
|
||||
|
||||
if os.path.isfile('./modules/webservers/scripts/files/id_rsa.pub'):
|
||||
|
||||
ssh_pub_key_file='./modules/webservers/scripts/files/id_rsa.pub'
|
||||
|
||||
if os.path.isfile(ssh_pub_key_file):
|
||||
os.unlink(ssh_pub_key_file)
|
||||
|
||||
return True
|
||||
"""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue