]> git.dolda2000.com Git - ashd.git/commitdiff
dirplex: Made it easier to include configuration "modules".
authorFredrik Tolf <fredrik@dolda2000.com>
Mon, 30 Aug 2010 10:45:04 +0000 (12:45 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Mon, 30 Aug 2010 10:45:04 +0000 (12:45 +0200)
lib/cf.c
src/dirplex.c

index f55a620e0022d60808ad80bf21e8a2867b3d7011..719fcad9ba162130119b4c0e3d0d32bdce96982b 100644 (file)
--- a/lib/cf.c
+++ b/lib/cf.c
@@ -232,10 +232,11 @@ char *findstdconf(char *name)
        if((p2 = strrchr(p, '/')) == NULL)
            continue;
        *p2 = 0;
-       if(!access(t = sprintf3("%s/etc/%s", p, name), R_OK)) {
+       if(!access(t = sprintf2("%s/etc/%s", p, name), R_OK)) {
            free(path);
-           return(sstrdup(t));
+           return(t);
        }
+       free(t);
     }
     free(path);
     return(NULL);
index d596df09045d78bd86ec24693a3bffda4076abcd..60f0859ddcb86d41560fcd4b75fdbb9d54472e45 100644 (file)
@@ -640,7 +640,7 @@ int main(int argc, char **argv)
 {
     int c;
     int nodef;
-    char *gcf, *lcf;
+    char *gcf, *lcf, *clcf;
     struct hthead *req;
     int fd;
     
@@ -673,8 +673,18 @@ int main(int argc, char **argv)
        }
     }
     if(lcf != NULL) {
-       if((lconfig = readconfig(lcf)) == NULL)
-           exit(1);
+       if(strchr(lcf, '/') == NULL) {
+           if((clcf = findstdconf(sprintf3("ashd/%s", lcf))) == NULL) {
+               flog(LOG_ERR, "could not find requested configuration `%s'", lcf);
+               exit(1);
+           }
+           if((lconfig = readconfig(clcf)) == NULL)
+               exit(1);
+           free(clcf);
+       } else {
+           if((lconfig = readconfig(lcf)) == NULL)
+               exit(1);
+       }
     }
     if(chdir(argv[optind])) {
        flog(LOG_ERR, "could not change directory to %s: %s", argv[optind], strerror(errno));