summaryrefslogtreecommitdiff
path: root/src/lib/lockfile.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-09-07 14:58:26 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-09-07 14:58:26 +0200
commitdd1047b0e457c45d45a1b5b83972d4a75968cce2 (patch)
treebea8fe98f0809d856a243e8485535fe7ac993808 /src/lib/lockfile.c
parent8ec02f772f3530d5c9023bd1ccf74fea555c69ed (diff)
parenta92a55f2489820f030f461ebc09d621b001a01df (diff)
downloadouroboros-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/lockfile.c')
-rw-r--r--src/lib/lockfile.c9
1 files changed, 4 insertions, 5 deletions
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.");