diff options
-rw-r--r-- | src/irmd/main.c | 1 | ||||
-rw-r--r-- | src/lib/lockfile.c | 9 | ||||
-rw-r--r-- | src/lib/shm_ap_rbuff.c | 9 | ||||
-rw-r--r-- | src/lib/shm_rdrbuff.c | 10 |
4 files changed, 12 insertions, 17 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c index 8a05017a..cc9160bf 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -2159,7 +2159,6 @@ int main(int argc, char ** argv) } } - if (!use_stdout && (log_dir = opendir(INSTALL_PREFIX LOG_DIR)) != NULL) { while ((ent = readdir(log_dir)) != NULL) { diff --git a/src/lib/lockfile.c b/src/lib/lockfile.c index 75ee2085..81bed687 100644 --- a/src/lib/lockfile.c +++ b/src/lib/lockfile.c @@ -43,10 +43,13 @@ struct lockfile { }; struct lockfile * lockfile_create() { + mode_t mask; struct lockfile * lf = malloc(sizeof(*lf)); if (lf == NULL) return NULL; + mask = umask(0); + lf->fd = shm_open(LOCKFILE_NAME, O_CREAT | O_EXCL | O_RDWR, 0666); if (lf->fd == -1) { LOG_DBGF("Could not create lock file."); @@ -54,11 +57,7 @@ struct lockfile * lockfile_create() { return NULL; } - if (fchmod(lf->fd, 0666)) { - LOG_DBGF("Failed to chmod lockfile."); - free(lf); - return NULL; - } + umask(mask); if (ftruncate(lf->fd, LF_SIZE - 1) < 0) { LOG_DBGF("Failed to extend lockfile."); 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."); 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."); |