+
+ # Now we know who we're allowing on the machine, export
+ # the relevant ssh keys
+ if MultipleSSHFiles:
+ tf = tarfile.open(name=os.path.join(GlobalDir, 'ssh-keys-%s.tar.gz' % CurrentHost), mode='w:gz')
+ for f in userlist:
+ if f not in SSHFiles:
+ continue
+ to = tf.gettarinfo(os.path.join(GlobalDir, 'userkeys', f), f)
+ # These will only be used where the username doesn't
+ # exist on the target system for some reason; hence,
+ # in those cases, the safest thing is for the file to
+ # be owned by root.
+ to.uid = 0
+ to.gid = 0
+ # Using the username / groupname fields avoids any need
+ # to give a shit^W^W^Wcare about the UIDoffset stuff.
+ to.uname = f
+ to.gname = "nobody"
+ to.mode = 0600
+ tf.addfile(to, file(os.path.join(GlobalDir, 'userkeys', f)))
+
+ tf.close()
+ os.rename(os.path.join(GlobalDir, 'ssh-keys-%s.tar.gz' % CurrentHost),
+ os.path.join(OutDir, 'ssh-keys.tar.gz'))
+