Cope with oddities around umask and permission bits
authorTim Pepper <timothy.c.pepper@linux.intel.com>
Tue, 11 Sep 2012 21:23:43 +0000 (14:23 -0700)
committerTim Pepper <timothy.c.pepper@linux.intel.com>
Tue, 11 Sep 2012 21:23:43 +0000 (14:23 -0700)
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 <timothy.c.pepper@linux.intel.com>
src/corewatcher.c

index e4a7bfc..4f102ae 100644 (file)
@@ -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;