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(data, conf = None, plc = None):
25 if 'accounts' not in data:
26 logger.log("specialaccounts: No account information found. DISABLED!")
29 for account in data['accounts']:
30 name = account['name']
31 new_keys = account['keys']
33 # look up account name, which must exist
34 pw_info = pwd.getpwnam(name)
39 # populate account's .ssh/authorized_keys file
40 dot_ssh = os.path.join(pw_dir,'.ssh')
41 if not os.access(dot_ssh, os.F_OK): os.mkdir(dot_ssh)
42 auth_keys = os.path.join(dot_ssh,'authorized_keys')
44 logger.log("new keys = %s" % auth_keys)
45 fd, fname = tempfile.mkstemp('','authorized_keys',dot_ssh)
52 if os.path.exists(auth_keys): os.unlink(auth_keys)
53 os.rename(fname, auth_keys)
55 # set permissions properly
56 os.chmod(dot_ssh, 0700)
57 os.chown(dot_ssh, uid,gid)
58 os.chmod(auth_keys, 0600)
59 os.chown(auth_keys, uid,gid)
61 logger.log('specialacounts: installed ssh keys for %s' % name)