[Checkins] SVN: zc.zopeorgkeyupload/branches/dev/src/zc/zopeorgkeyupload/__init__.py Make key files readable only by the application process user prior to

Jim Fulton jim at zope.com
Fri May 2 13:44:59 EDT 2008


Log message for revision 86112:
  Make key files readable only by the application process user prior to
  writing data to them.
  

Changed:
  U   zc.zopeorgkeyupload/branches/dev/src/zc/zopeorgkeyupload/__init__.py

-=-
Modified: zc.zopeorgkeyupload/branches/dev/src/zc/zopeorgkeyupload/__init__.py
===================================================================
--- zc.zopeorgkeyupload/branches/dev/src/zc/zopeorgkeyupload/__init__.py	2008-05-02 17:42:33 UTC (rev 86111)
+++ zc.zopeorgkeyupload/branches/dev/src/zc/zopeorgkeyupload/__init__.py	2008-05-02 17:44:59 UTC (rev 86112)
@@ -85,11 +85,11 @@
             
 
         if v1keys:
-            open(self.tmp, 'w').write(''.join(v1keys))
+            writef(self.tmp, ''.join(v1keys))
             os.path.rename(self.tmp, os.path.join(self.keydir, login+'-1'))
 
         if v2keys:
-            open(self.tmp, 'w').write(''.join(v2keys))
+            writef(self.tmp, ''.join(v2keys))
             os.rename(self.tmp, os.path.join(self.keydir, login+'-2'))
             
         return ("Your keys have been uploaded.\n"
@@ -106,8 +106,13 @@
     
     def getDefaultTraversal(self, request, ob):
         return self, ()
-                                                                                                
 
+def writef(path, data):
+    fd = os.open(path, os.O_WRONLY | os.O_CREAT, 0600)
+    os.write(fd, data)
+    os.close(fd)
+
+
 key_form = """
 <html>
   <head>



More information about the Checkins mailing list