Always chmod our directories.
authorTim Pepper <timothy.c.pepper@linux.intel.com>
Fri, 28 Sep 2012 00:25:39 +0000 (17:25 -0700)
committerTim Pepper <timothy.c.pepper@linux.intel.com>
Fri, 28 Sep 2012 00:25:39 +0000 (17:25 -0700)
I observed the the modes of corewatcher's directories had changed on one
of my systems.  I don't know what would have caused that, but it led to
cores not being recorded in the filesystem.  To be robust we create the
directories if for some reason they do not exist at start up.  Similarly,
try to always insure they have the correct permissions at start up.

Signed-off-by: Tim Pepper <timothy.c.pepper@linux.intel.com>
src/corewatcher.c

index 983d3c6..457eb1a 100644 (file)
@@ -197,11 +197,11 @@ int main(int argc, char**argv)
        dir = opendir(core_folder);
        if (!dir) {
                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;
        }
+       chmod(core_folder, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);
        closedir(dir);
        dir = opendir(processed_folder);
        if (!dir) {
@@ -211,6 +211,7 @@ int main(int argc, char**argv)
                if (!dir)
                        return 1;
        }
+       chmod(processed_folder, S_IRWXU);
        closedir(dir);
 
        while (1) {