From: Tim Pepper Date: Tue, 11 Sep 2012 21:23:43 +0000 (-0700) Subject: Cope with oddities around umask and permission bits X-Git-Tag: 2.1b_release~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=874fa2815a95293585be6a216c3734719be04007;p=external%2Fcorewatcher.git 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 --- 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;