From: Loic Dachary Date: Thu, 4 Dec 2014 21:21:32 +0000 (+0100) Subject: ceph-disk: dmcrypt file permissions X-Git-Tag: v0.90~4^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F3087%2Fhead;p=ceph.git ceph-disk: dmcrypt file permissions 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 --- diff --git a/src/ceph-disk b/src/ceph-disk index 6072c7a38501..cf809f5e7a13 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -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)