diff options
author | dimitri staessens <[email protected]> | 2016-09-07 14:53:19 +0200 |
---|---|---|
committer | dimitri staessens <[email protected]> | 2016-09-07 14:53:19 +0200 |
commit | a92a55f2489820f030f461ebc09d621b001a01df (patch) | |
tree | bea8fe98f0809d856a243e8485535fe7ac993808 /src/lib/shm_rdrbuff.c | |
parent | 8ec02f772f3530d5c9023bd1ccf74fea555c69ed (diff) | |
download | ouroboros-a92a55f2489820f030f461ebc09d621b001a01df.tar.gz ouroboros-a92a55f2489820f030f461ebc09d621b001a01df.zip |
lib: Set umask for file creation permissions
Permissions are now set correctly upon creation, removing the need to
call fchmod.
Diffstat (limited to 'src/lib/shm_rdrbuff.c')
-rw-r--r-- | src/lib/shm_rdrbuff.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/lib/shm_rdrbuff.c b/src/lib/shm_rdrbuff.c index 2f0f15be..3eae8f97 100644 --- a/src/lib/shm_rdrbuff.c +++ b/src/lib/shm_rdrbuff.c @@ -154,6 +154,7 @@ static char * rdrb_filename(enum qos_cube qos) struct shm_rdrbuff * shm_rdrbuff_create() { struct shm_rdrbuff * rdrb; + mode_t mask; int shm_fd; uint8_t * shm_base; pthread_mutexattr_t mattr; @@ -171,6 +172,8 @@ struct shm_rdrbuff * shm_rdrbuff_create() return NULL; } + mask = umask(0); + shm_fd = shm_open(shm_rdrb_fn, O_CREAT | O_EXCL | O_RDWR, 0666); if (shm_fd == -1) { LOG_DBGF("Failed creating shared memory map."); @@ -179,12 +182,7 @@ struct shm_rdrbuff * shm_rdrbuff_create() return NULL; } - if (fchmod(shm_fd, 0666)) { - LOG_DBGF("Failed to chmod shared memory map."); - free(shm_rdrb_fn); - free(rdrb); - return NULL; - } + umask(mask); if (ftruncate(shm_fd, SHM_FILE_SIZE - 1) < 0) { LOG_DBGF("Failed to extend shared memory map."); |