2 # vim:set ts=4 sw=4 expandtab:
3 # NodeManager plugin to create special accounts
6 Have NM create/populate accounts/ssh keys for special persons such as root, site_admin, etc.
21 def start(options, conf):
22 logger.log("personkeys plugin starting up...")
24 def GetSlivers(plc, data, conf):
25 if 'accounts' not in data: return
26 for account in data['accounts']:
27 name = account['name']
28 new_keys = account['keys']
30 # look up account name, which must exist
31 pw_info = pwd.getpwnam(name)
36 # populate account's .ssh/authorized_keys file
37 dot_ssh = os.path.join(pw_dir,'.ssh')
38 if not os.access(dot_ssh, os.F_OK): os.mkdir(dot_ssh)
39 auth_keys = os.path.join(dot_ssh,'authorized_keys')
40 logger.log("new keys = %s" % auth_keys)
41 fd, fname = tempfile.mkstemp('','authorized_keys',dot_ssh)
48 if os.path.exists(auth_keys):
50 os.rename(fname,auth_keys)
52 # set permissions properly
53 os.chmod(dot_ssh, 0700)
54 os.chown(dot_ssh, uid,gid)
55 os.chmod(auth_keys, 0600)
56 os.chown(auth_keys, uid,gid)
58 logger.log('specialacounts: installed ssh keys for %s' % name)