diff options
author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-09-07 14:58:26 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-09-07 14:58:26 +0200 |
commit | dd1047b0e457c45d45a1b5b83972d4a75968cce2 (patch) | |
tree | bea8fe98f0809d856a243e8485535fe7ac993808 /src/lib/shm_ap_rbuff.c | |
parent | 8ec02f772f3530d5c9023bd1ccf74fea555c69ed (diff) | |
parent | a92a55f2489820f030f461ebc09d621b001a01df (diff) | |
download | ouroboros-dd1047b0e457c45d45a1b5b83972d4a75968cce2.tar.gz ouroboros-dd1047b0e457c45d45a1b5b83972d4a75968cce2.zip |
Merged in dstaesse/ouroboros/be-shm (pull request #248)
lib: Set umask for file creation permissions
Diffstat (limited to 'src/lib/shm_ap_rbuff.c')
-rw-r--r-- | src/lib/shm_ap_rbuff.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/lib/shm_ap_rbuff.c b/src/lib/shm_ap_rbuff.c index e6665362..473894d5 100644 --- a/src/lib/shm_ap_rbuff.c +++ b/src/lib/shm_ap_rbuff.c @@ -75,6 +75,7 @@ static struct shm_ap_rbuff * shm_ap_rbuff_create(bool dir) pthread_mutexattr_t mattr; pthread_condattr_t cattr; char fn[FN_MAX_CHARS]; + mode_t mask; if (dir == SOUTH) sprintf(fn, SHM_AP_RBUFF_PREFIX "south.%d", getpid()); @@ -87,6 +88,8 @@ static struct shm_ap_rbuff * shm_ap_rbuff_create(bool dir) return NULL; } + mask = umask(0); + shm_fd = shm_open(fn, O_CREAT | O_EXCL | O_RDWR, 0666); if (shm_fd == -1) { LOG_DBG("Failed creating ring buffer."); @@ -94,11 +97,7 @@ static struct shm_ap_rbuff * shm_ap_rbuff_create(bool dir) return NULL; } - if (fchmod(shm_fd, 0666)) { - LOG_DBG("Failed to chmod shared memory."); - free(rb); - return NULL; - } + umask(mask); if (ftruncate(shm_fd, SHM_RBUFF_FILE_SIZE - 1) < 0) { LOG_DBG("Failed to extend ringbuffer."); |