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.libraries.task import Task
|
||||||
from modules.pastafari2.models.pastafari2 import ServerDbTask
|
from modules.pastafari2.models.pastafari2 import ServerDbTask
|
||||||
import os
|
import os
|
||||||
|
from subprocess import call
|
||||||
|
|
||||||
class ServerTask(Task):
|
class ServerTask(Task):
|
||||||
|
|
||||||
|
|
@ -32,22 +33,36 @@ class ServerTask(Task):
|
||||||
ssh_pub_key_file='./modules/webservers/scripts/files/id_rsa.pub'
|
ssh_pub_key_file='./modules/webservers/scripts/files/id_rsa.pub'
|
||||||
self.files.append([ssh_pub_key_file, 0o600])
|
self.files.append([ssh_pub_key_file, 0o600])
|
||||||
|
|
||||||
final_ssh_pub='--ssh_pub_key_file="'+ssh_pub_key_file+'"'
|
# 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=''
|
final_password=''
|
||||||
|
|
||||||
if self.data['password']!='':
|
if self.data['password']!='':
|
||||||
final_password='--password=%s' % 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
|
return True
|
||||||
|
|
||||||
"""
|
|
||||||
def post_task(self):
|
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
|
return True
|
||||||
"""
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue