X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fuserplex.c;h=cfd313cbb9ed650f8996f319ee815adddebd3aec;hb=fd735432ca61308348e1f1eb1b79a42e357aa0b7;hp=592c1b2f62c0bfc409a8dc12dd34d3335596e31f;hpb=b9e7ec7a81ea631891cae27448069784a2768490;p=ashd.git diff --git a/src/userplex.c b/src/userplex.c index 592c1b2..cfd313c 100644 --- a/src/userplex.c +++ b/src/userplex.c @@ -43,7 +43,7 @@ struct user { static int ignore = 0; static char *mgroup = NULL; -static char *dirname = "htpub"; +static char *dirname = NULL; static char **childspec; static uid_t minuid = 0; static struct user *users = NULL; @@ -80,12 +80,12 @@ static void login(struct passwd *pwd) /* There's whole load of other stuff one could want to do here -- * getting Kerberos credentials, running PAM session modules, and * who knows what. I'll add them along as I find them useful. */ - if(((fd = open(".ashd/output", O_APPEND)) >= 0) || + if(((fd = open(".ashd/output", O_WRONLY | O_APPEND)) >= 0) || ((fd = open("/dev/null", 0)) >= 0)) { dup2(fd, 1); close(fd); } - if(((fd = open(".ashd/error", O_APPEND)) >= 0) || + if(((fd = open(".ashd/error", O_WRONLY | O_APPEND)) >= 0) || ((fd = open("/dev/null", 0)) >= 0)) { dup2(fd, 2); close(fd); @@ -230,6 +230,10 @@ out: free(usrnm); } +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"); @@ -242,7 +246,7 @@ 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, "+hIg:m:d:")) >= 0) { switch(c) { case 'I': ignore = 1; @@ -269,8 +273,9 @@ int main(int argc, char **argv) } if(optind < argc) { childspec = argv + optind; - dirname = NULL; } else { + if(dirname == NULL) + dirname = "htpub"; bufinit(csbuf); bufadd(csbuf, "dirplex"); bufadd(csbuf, dirname); @@ -278,6 +283,7 @@ int main(int argc, char **argv) childspec = csbuf.b; } signal(SIGCHLD, SIG_IGN); + signal(SIGPIPE, sighandler); while(1) { if((fd = recvreq(0, &req)) < 0) { if(errno != 0)