X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=lib%2Fcf.c;h=f5defd7e37b10a02e1daea4aec0256befadcec81;hb=4dc7f716a7b4be064ecf86f6e1444b7b39dfdfe7;hp=86658f87ccb424f1bfec1776045d58788c143ca0;hpb=fc35a3ef51b6f8a2735001b667dac63ae9154ed9;p=ashd.git diff --git a/lib/cf.c b/lib/cf.c index 86658f8..f5defd7 100644 --- a/lib/cf.c +++ b/lib/cf.c @@ -233,22 +233,27 @@ void freecfparser(struct cfstate *s) char *findstdconf(char *name) { - char *path, *p, *p2, *t; + char *home, *path, *p, *p2, *t; - if((path = getenv("PATH")) == NULL) - return(NULL); - path = sstrdup(path); - for(p = strtok(path, ":"); p != NULL; p = strtok(NULL, ":")) { - if((p2 = strrchr(p, '/')) == NULL) - continue; - *p2 = 0; - if(!access(t = sprintf2("%s/etc/%s", p, name), R_OK)) { - free(path); + if((home = getenv("HOME")) != NULL) { + if(!access(t = sprintf2("%s/.ashd/etc/%s", home, name), R_OK)) return(t); - } free(t); } - free(path); + if((path = getenv("PATH")) != NULL) { + path = sstrdup(path); + for(p = strtok(path, ":"); p != NULL; p = strtok(NULL, ":")) { + if((p2 = strrchr(p, '/')) == NULL) + continue; + *p2 = 0; + if(!access(t = sprintf2("%s/etc/%s", p, name), R_OK)) { + free(path); + return(t); + } + free(t); + } + free(path); + } return(NULL); } @@ -306,20 +311,22 @@ static struct chandler stdhandler = { static int stdhandle(struct child *ch, struct hthead *req, int fd, void (*chinit)(void *), void *idata) { struct stdchild *i = ch->pdata; + int serr; if(i->type == CH_SOCKET) { if(i->fd < 0) i->fd = stdmkchild(i->argv, chinit, idata); if(sendreq2(i->fd, req, fd, MSG_NOSIGNAL | MSG_DONTWAIT)) { - if((errno == EPIPE) || (errno == ECONNRESET)) { + serr = errno; + if((serr == EPIPE) || (serr == ECONNRESET)) { /* Assume that the child has crashed and restart it. */ close(i->fd); i->fd = stdmkchild(i->argv, chinit, idata); if(!sendreq2(i->fd, req, fd, MSG_NOSIGNAL | MSG_DONTWAIT)) return(0); } - flog(LOG_ERR, "could not pass on request to child %s: %s", ch->name, strerror(errno)); - if(errno != EAGAIN) { + flog(LOG_ERR, "could not pass on request to child %s: %s", ch->name, strerror(serr)); + if(serr != EAGAIN) { close(i->fd); i->fd = -1; }