From 874fa2815a95293585be6a216c3734719be04007 Mon Sep 17 00:00:00 2001 From: Tim Pepper Date: Tue, 11 Sep 2012 14:23:43 -0700 Subject: [PATCH] Cope with oddities around umask and permission bits For some reason the mask passed to mkdir() isn't (always?) honored, but the directory starts with safe enough perm's and I can subsequently add the ones I'd just asked for and not been given. Signed-off-by: Tim Pepper --- src/corewatcher.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/corewatcher.c b/src/corewatcher.c index e4a7bfc..4f102ae 100644 --- a/src/corewatcher.c +++ b/src/corewatcher.c @@ -110,10 +110,8 @@ int main(int argc, char**argv) /* insure our directories exist */ dir = opendir(core_folder); if (!dir) { - if (!mkdir(core_folder, S_IRWXU | S_IRWXG | S_IRWXO) - && errno != EEXIST) { - return 1; - } + mkdir(core_folder, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX); + chmod(core_folder, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX); dir = opendir(core_folder); if (!dir) return 1; @@ -121,10 +119,8 @@ int main(int argc, char**argv) closedir(dir); dir = opendir(processed_folder); if (!dir) { - if (!mkdir(processed_folder, S_IRWXU) - && errno != EEXIST) { - return 1; - } + mkdir(processed_folder, S_IRWXU); + chmod(processed_folder, S_IRWXU); dir = opendir(processed_folder); if (!dir) return 1; -- 2.7.4