patplex: Search for the configuration file if it contains no slashes.
authorFredrik Tolf <fredrik@dolda2000.com>
Sat, 23 Mar 2013 04:13:28 +0000 (05:13 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Sat, 23 Mar 2013 04:13:28 +0000 (05:13 +0100)
doc/patplex.doc
src/patplex.c

index dafe5e2..dff248b 100644 (file)
@@ -40,7 +40,10 @@ directories named by the *PATH* environment variable, appended with
 `../etc/ashd`. For example, then, if *PATH* is
 `/usr/local/bin:/bin:/usr/bin`, the directories `/usr/local/etc/ashd`,
 `/etc/ashd` and `/usr/etc/ashd` are searched for `patplex.rc`, in that
 `../etc/ashd`. For example, then, if *PATH* is
 `/usr/local/bin:/bin:/usr/bin`, the directories `/usr/local/etc/ashd`,
 `/etc/ashd` and `/usr/etc/ashd` are searched for `patplex.rc`, in that
-order. Only the first file found is used, should there exist several.
+order. Only the first file found is used, should there exist
+several. If the given 'CONFIGFILE' contains any slashes, it is opened
+by that exact name. Otherwise, it is searched for in the same manner
+as the global configuration file.
 
 Should the global and the given configuration files conflict, the
 directives from the given file take precedence.
 
 Should the global and the given configuration files conflict, the
 directives from the given file take precedence.
index 13fa062..a0818d2 100644 (file)
@@ -514,7 +514,7 @@ int main(int argc, char **argv)
 {
     int c;
     int nodef;
 {
     int c;
     int nodef;
-    char *gcf;
+    char *gcf, *lcf;
     struct hthead *req;
     int fd;
     
     struct hthead *req;
     int fd;
     
@@ -542,8 +542,14 @@ int main(int argc, char **argv)
            free(gcf);
        }
     }
            free(gcf);
        }
     }
-    if((lconfig = readconfig(argv[optind])) == NULL) {
-       flog(LOG_ERR, "could not read `%s'", argv[optind]);
+    if((strchr(lcf = argv[optind], '/')) == NULL) {
+       if((lcf = findstdconf(sprintf3("ashd/%s", lcf))) == NULL) {
+           flog(LOG_ERR, "could not find requested configuration file `%s'", argv[optind]);
+           exit(1);
+       }
+    }
+    if((lconfig = readconfig(lcf)) == NULL) {
+       flog(LOG_ERR, "could not read `%s'", lcf);
        exit(1);
     }
     signal(SIGCHLD, chldhandler);
        exit(1);
     }
     signal(SIGCHLD, chldhandler);
@@ -551,7 +557,7 @@ int main(int argc, char **argv)
     signal(SIGPIPE, sighandler);
     while(1) {
        if(reload) {
     signal(SIGPIPE, sighandler);
     while(1) {
        if(reload) {
-           reloadconf(argv[optind]);
+           reloadconf(lcf);
            reload = 0;
        }
        if((fd = recvreq(0, &req)) < 0) {
            reload = 0;
        }
        if((fd = recvreq(0, &req)) < 0) {