git://git.onelab.eu
/
nodemanager.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7a13fd6
)
use a temp file to write the keys
author
Marc Fiuczynski
<mef@cs.princeton.edu>
Fri, 17 Jul 2009 04:05:35 +0000
(
04:05
+0000)
committer
Marc Fiuczynski
<mef@cs.princeton.edu>
Fri, 17 Jul 2009 04:05:35 +0000
(
04:05
+0000)
plugins/specialaccounts.py
patch
|
blob
|
history
diff --git
a/plugins/specialaccounts.py
b/plugins/specialaccounts.py
index
ad4c2cf
..
a6c07b0
100644
(file)
--- a/
plugins/specialaccounts.py
+++ b/
plugins/specialaccounts.py
@@
-38,16
+38,21
@@
def GetSlivers(plc, data, conf):
if not os.access(dot_ssh, os.F_OK): os.mkdir(dot_ssh)
auth_keys = dot_ssh + '/authorized_keys'
logger.log("new keys = %s" % auth_keys)
if not os.access(dot_ssh, os.F_OK): os.mkdir(dot_ssh)
auth_keys = dot_ssh + '/authorized_keys'
logger.log("new keys = %s" % auth_keys)
- auth_file = file(auth_keys,"w")
+
+ fd, fname = tempfile.mkstemp('','authorized_keys',dot_ssh)
for key in new_keys:
for key in new_keys:
- auth_file.write(key)
- auth_file.write("\n")
- auth_file.close()
+ os.write(fd,key)
+ os.write(fd,'\n')
+
+ os.close(fd)
+ if os.path.exists(auth_keys):
+ os.unlink(auth_keys)
+ os.rename(fname,auth_keys)
# set permissions properly
os.chmod(dot_ssh, 0700)
# set permissions properly
os.chmod(dot_ssh, 0700)
- os.chmod(auth_keys, 0600)
os.chown(dot_ssh, uid,gid)
os.chown(dot_ssh, uid,gid)
+ os.chmod(auth_keys, 0600)
os.chown(auth_keys, uid,gid)
logger.log('specialacounts: installed ssh keys for %s' % name)
os.chown(auth_keys, uid,gid)
logger.log('specialacounts: installed ssh keys for %s' % name)