X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fuserplex.c;h=3a2da874512f4760bcfbdc69bcc3f0291955ced9;hb=349b25644067aa6754197a991c3ba00143d60a19;hp=cfd313cbb9ed650f8996f319ee815adddebd3aec;hpb=fd735432ca61308348e1f1eb1b79a42e357aa0b7;p=ashd.git diff --git a/src/userplex.c b/src/userplex.c index cfd313c..3a2da87 100644 --- a/src/userplex.c +++ b/src/userplex.c @@ -46,6 +46,7 @@ static char *mgroup = NULL; static char *dirname = NULL; static char **childspec; static uid_t minuid = 0; +static int usesyslog = 0; static struct user *users = NULL; static void login(struct passwd *pwd) @@ -73,6 +74,10 @@ static void login(struct passwd *pwd) flog(LOG_ERR, "could not change to home directory for %s: %s", pwd->pw_name, strerror(errno)); exit(1); } + if(usesyslog) + putenv("ASHD_USESYSLOG=1"); + else + unsetenv("ASHD_USESYSLOG"); putenv(sprintf2("HOME=%s", pwd->pw_dir)); putenv(sprintf2("SHELL=%s", pwd->pw_shell)); putenv(sprintf2("USER=%s", pwd->pw_name)); @@ -140,7 +145,7 @@ static void serve2(struct user *usr, struct hthead *req, int fd) if(usr->fd < 0) usr->fd = forkchild(usr->name); if(sendreq(usr->fd, req, fd)) { - if(errno == EPIPE) { + if((errno == EPIPE) || (errno == ECONNRESET)) { /* Assume that the child has crashed and restart it. */ close(usr->fd); usr->fd = forkchild(usr->name); @@ -236,7 +241,7 @@ static void sighandler(int sig) static void usage(FILE *out) { - fprintf(out, "usage: userplex [-hI] [-g GROUP] [-m MIN-UID] [-d PUB-DIR] [PROGRAM ARGS...]\n"); + fprintf(out, "usage: userplex [-hIs] [-g GROUP] [-m MIN-UID] [-d PUB-DIR] [PROGRAM ARGS...]\n"); } int main(int argc, char **argv) @@ -246,11 +251,14 @@ int main(int argc, char **argv) int fd; struct charvbuf csbuf; - while((c = getopt(argc, argv, "+hIg:m:d:")) >= 0) { + while((c = getopt(argc, argv, "+hIsg:m:d:")) >= 0) { switch(c) { case 'I': ignore = 1; break; + case 's': + usesyslog = 1; + break; case 'm': if((minuid = atoi(optarg)) < 1) { fprintf(stderr, "userplex: argument to -m must be greater than 0\n");