mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
Added function for public key to gstfsd
This commit is contained in:
parent
2d1f72a7e1
commit
0408e1d9cd
4 changed files with 73 additions and 10 deletions
|
|
@ -29,13 +29,21 @@ class MyTCPServerHandler(SocketServer.BaseRequestHandler):
|
|||
try:
|
||||
gfs.mount(part, '/')
|
||||
if gfs.is_file('/etc/shadow'):
|
||||
file_shadow = gfs.cat('/etc/shadow')
|
||||
new_root_hash = "root:" + data['passwd'] + ":"
|
||||
file_shadow_new = re.sub('^root:.*?:', new_root_hash, file_shadow)
|
||||
gfs.write("/etc/shadow", file_shadow_new)
|
||||
gfs.chmod(640, '/etc/shadow')
|
||||
gfs.umount(part)
|
||||
self.request.sendall(json.dumps({'return': 'success'}))
|
||||
if data['action'] == 'password':
|
||||
file_shadow = gfs.cat('/etc/shadow')
|
||||
new_root_hash = "root:" + data['passwd'] + ":"
|
||||
file_shadow_new = re.sub('^root:.*?:', new_root_hash, file_shadow)
|
||||
gfs.write('/etc/shadow', file_shadow_new)
|
||||
gfs.chmod(640, '/etc/shadow')
|
||||
self.request.sendall(json.dumps({'return': 'success'}))
|
||||
if data['action'] == 'publickey':
|
||||
if not gfs.is_dir('/root/.ssh'):
|
||||
gfs.mkdir ('/root/.ssh')
|
||||
gfs.chmod(0700, "/root/.ssh")
|
||||
gfs.write('/root/.ssh/authorized_keys', data['key'])
|
||||
gfs.chmod(0600, '/root/.ssh/authorized_keys')
|
||||
self.request.sendall(json.dumps({'return': 'success'}))
|
||||
gfs.umount(part)
|
||||
except RuntimeError:
|
||||
pass
|
||||
gfs.shutdown()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue