2 # vim:set ts=4 sw=4 expandtab:
7 # NodeManager plugin to create special accounts
10 Have NM create/populate accounts/ssh keys for special persons such as root, site_admin, etc.
25 def start(options, conf):
26 logger.log("personkeys plugin starting up...")
28 def GetSlivers(data, conf = None, plc = None):
29 if 'accounts' not in data:
30 logger.log_missing_data("specialaccounts.GetSlivers",'accounts')
33 for account in data['accounts']:
34 name = account['name']
35 new_keys = account['keys']
37 # look up account name, which must exist
38 pw_info = pwd.getpwnam(name)
43 # populate account's .ssh/authorized_keys file
44 dot_ssh = os.path.join(pw_dir,'.ssh')
45 if not os.access(dot_ssh, os.F_OK): os.mkdir(dot_ssh)
46 auth_keys = os.path.join(dot_ssh,'authorized_keys')
48 logger.log("new keys = %s" % auth_keys)
49 fd, fname = tempfile.mkstemp('','authorized_keys',dot_ssh)
56 if os.path.exists(auth_keys): os.unlink(auth_keys)
57 os.rename(fname, auth_keys)
59 # set permissions properly
60 os.chmod(dot_ssh, 0700)
61 os.chown(dot_ssh, uid,gid)
62 os.chmod(auth_keys, 0600)
63 os.chown(auth_keys, uid,gid)
65 logger.log('specialacounts: installed ssh keys for %s' % name)