]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
Change umask when creating keyrings
authorAlfredo Deza <adeza@redhat.com>
Fri, 10 Apr 2015 17:06:09 +0000 (13:06 -0400)
committerTravis Rhoden <trhoden@redhat.com>
Thu, 16 Apr 2015 16:35:50 +0000 (12:35 -0400)
So that they aren't world readable by default

Unable to cherry-pick due to multiple changes in single commit
Original commit: 3cdc6cb5

Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 5404647b76460ec83e43a570afcef4c87b8cb662)

ceph_deploy/new.py

index 902e87d9cccb4f3dc32aaad52ed430e7b3f1d0b4..a4dfb5765c75745f29e60d552e33a8904f98f3cd 100644 (file)
@@ -211,18 +211,21 @@ def new_mon_keyring(args):
     keypath = '{name}.mon.keyring'.format(
         name=args.cluster,
         )
-
+    oldmask = os.umask(077)
     LOG.debug('Writing monitor keyring to %s...', keypath)
-    tmp = '%s.tmp' % keypath
-    with file(tmp, 'w') as f:
-        f.write(mon_keyring)
     try:
-        os.rename(tmp, keypath)
-    except OSError as e:
-        if e.errno == errno.EEXIST:
-            raise exc.ClusterExistsError(keypath)
-        else:
-            raise
+        tmp = '%s.tmp' % keypath
+        with file(tmp, 'w') as f:
+            f.write(mon_keyring)
+        try:
+            os.rename(tmp, keypath)
+        except OSError as e:
+            if e.errno == errno.EEXIST:
+                raise exc.ClusterExistsError(keypath)
+            else:
+                raise
+    finally:
+        os.umask(oldmask)
 
 
 @priority(10)