X-Git-Url: http://git.onelab.eu/?p=nodemanager.git;a=blobdiff_plain;f=plugins%2Fspecialaccounts.py;h=ff984e6201bdfe823c7c3a774e452980c1ad0671;hp=207eb550d97ee7cbc66aa3dead0aab980c8fb123;hb=48a73b18fd7daed13c645c1adeddb57b560e7a2d;hpb=2306328a4623d578e93bd59982623908eb8742dd diff --git a/plugins/specialaccounts.py b/plugins/specialaccounts.py index 207eb55..ff984e6 100644 --- a/plugins/specialaccounts.py +++ b/plugins/specialaccounts.py @@ -1,8 +1,6 @@ #!/usr/bin/python -tt # vim:set ts=4 sw=4 expandtab: # -# $Id$ -# $URL$ # # NodeManager plugin to create special accounts @@ -25,12 +23,12 @@ import tools # right after conf_files priority = 3 -def start(options, conf): +def start(): logger.log("specialaccounts: plugin starting up...") def GetSlivers(data, conf = None, plc = None): - if 'accounts' not in data: - logger.log_missing_data("specialaccounts.GetSlivers",'accounts') + if 'accounts' not in data: + logger.log_missing_data("specialaccounts.GetSlivers", 'accounts') return for account in data['accounts']: @@ -46,21 +44,21 @@ def GetSlivers(data, conf = None, plc = None): pw_dir = pw_info[5] # populate account's .ssh/authorized_keys file - dot_ssh = os.path.join(pw_dir,'.ssh') + dot_ssh = os.path.join(pw_dir, '.ssh') if not os.access(dot_ssh, os.F_OK): os.mkdir(dot_ssh) - auth_keys = os.path.join(dot_ssh,'authorized_keys') + auth_keys = os.path.join(dot_ssh, 'authorized_keys') # catenate all keys in string, add newlines just in case (looks like keys already have this, but) auth_keys_contents = '\n'.join(new_keys)+'\n' - changes = tools.replace_file_with_string(auth_keys,auth_keys_contents) + changes = tools.replace_file_with_string(auth_keys, auth_keys_contents) if changes: logger.log("specialaccounts: keys file changed: %s" % auth_keys) - + # always set permissions properly - os.chmod(dot_ssh, 0700) - os.chown(dot_ssh, uid,gid) - os.chmod(auth_keys, 0600) - os.chown(auth_keys, uid,gid) + os.chmod(dot_ssh, 0o700) + os.chown(dot_ssh, uid, gid) + os.chmod(auth_keys, 0o600) + os.chown(auth_keys, uid, gid) logger.log('specialaccounts: installed ssh keys for %s' % name)