]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: dmcrypt file permissions 3087/head
authorLoic Dachary <ldachary@redhat.com>
Thu, 4 Dec 2014 21:21:32 +0000 (22:21 +0100)
committerLoic Dachary <ldachary@redhat.com>
Fri, 5 Dec 2014 10:06:20 +0000 (11:06 +0100)
The directory in which key files are stored for dmcrypt must be 700 and
the file 600.

http://tracker.ceph.com/issues/9785 Fixes: #9785

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/ceph-disk

index 6072c7a38501fc0482c4f187608839be776f1e47..cf809f5e7a1352d0863b0bac67fa630d10ca2f05 100755 (executable)
@@ -792,11 +792,13 @@ def get_or_create_dmcrypt_key(
     # make a new key
     try:
         if not os.path.exists(key_dir):
-            os.makedirs(key_dir)
+            os.makedirs(key_dir, stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR)
         with file('/dev/urandom', 'rb') as i:
             key = i.read(256)
-            with file(path, 'wb') as key_file:
-                key_file.write(key)
+            fd = os.open(path, os.O_WRONLY|os.O_CREAT,
+                         stat.S_IRUSR|stat.S_IWUSR)
+            assert os.write(fd, key) == len(key)
+            os.close(fd)
         return path
     except:
         raise Error('unable to read or create dm-crypt key', path)