Don't start if radius_dir is globally writable
authoraland <aland>
Fri, 9 Feb 2007 13:03:18 +0000 (13:03 +0000)
committeraland <aland>
Fri, 9 Feb 2007 13:03:18 +0000 (13:03 +0000)
Relax the checks on readability

src/main/conffile.c
src/main/mainconfig.c

index 4d2f812..c6a80be 100644 (file)
@@ -1213,7 +1213,7 @@ int cf_file_include(const char *file, CONF_SECTION *cs)
                        return -1;
                }
 
-               if ((statbuf.st_mode & S_IROTH) != 0) {
+               if (0 && (statbuf.st_mode & S_IROTH) != 0) {
                        radlog(L_ERR|L_CONS, "Configuration file %s is globally readable.  Refusing to start due to insecure configuration.",
                               file);
                        return -1;
index be6b1da..85ad1c4 100644 (file)
@@ -874,6 +874,26 @@ int read_mainconfig(int reload)
        char buffer[1024];
        CONF_SECTION *cs, *oldcs;
        rad_listen_t *listener;
+       struct stat statbuf;
+
+       if (stat(radius_dir, &statbuf) < 0) {
+               radlog(L_ERR|L_CONS, "Errors reading %s: %s",
+                      radius_dir, strerror(errno));
+               return -1;
+       }
+
+       if ((statbuf.st_mode & S_IWOTH) != 0) {
+               radlog(L_ERR|L_CONS, "Configuration directory %s is globally writable.  Refusing to start due to insecure configuration.",
+                      radius_dir);
+         return -1;
+       }
+
+
+       if (0 && (statbuf.st_mode & S_IROTH) != 0) {
+               radlog(L_ERR|L_CONS, "Configuration directory %s is globally readable.  Refusing to start due to insecure configuration.",
+                      radius_dir);
+               return -1;
+       }
 
        /* Read the configuration file */
        snprintf(buffer, sizeof(buffer), "%.200s/%.50s",