- for I in x[1]["sshRSAAuthKey"]:
- User = GetAttr(x,"uid");
- Line = "%s: %s" %(User,I);
- Line = Sanitize(Line) + "\n";
- F.write(Line);
- # Oops, something unspeakable happened.
- except:
- Die(File,F,None);
- raise;
- Done(File,F,None);
+ User = GetAttr(x,"uid");
+ F = None;
+
+ try:
+ if MultipleSSHFiles:
+ OldMask = os.umask(0077);
+ File = os.path.join(GlobalDir, 'userkeys', User)
+ F = open(File + ".tmp","w",0600);
+ os.umask(OldMask);
+
+ for I in x[1]["sshRSAAuthKey"]:
+ if MultipleSSHFiles:
+ MultipleLine = "%s" % I
+ MultipleLine = Sanitize(MultipleLine) + "\n"
+ F.write(MultipleLine)
+ if SingleSSHFile:
+ SingleLine = "%s: %s" % (User, I)
+ SingleLine = Sanitize(SingleLine) + "\n"
+ masterFile.write(SingleLine)
+
+ if MultipleSSHFiles:
+ Done(File,F,None);
+ userfiles.append(os.path.basename(File))
+
+ # Oops, something unspeakable happened.
+ except IOError:
+ Die(File,F,None)
+ Die(masterFileName,masterFile,None)
+ raise;
+
+ if SingleSSHFile:
+ Done(masterFileName,masterFile,None)
+ singlefile = os.path.basename(masterFileName)
+
+ return singlefile, userfiles