]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: dmcrypt file permissions 3096/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 17:32:06 +0000 (18:32 +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>
(cherry picked from commit 58682d1776ab1fd4daddd887d921ca9cc312bf50)

src/ceph-disk

index 2eabb82d8039481936eda8d7872a6ec6f8208dc0..6bd02201bd8b7efa71d1158ed325a09721f2402c 100755 (executable)
@@ -791,11 +791,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)