mirror of
https://github.com/ceph/ceph
synced 2025-01-28 05:53:37 +00:00
Merge pull request #3087 from dachary/wip-9785-dmcrypt-keys-permissions
ceph-disk: dmcrypt file permissions Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
commit
d7a9bf7cdb
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user