X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fuserplex.c;h=d6c978c0dec3d40cf347092bf9ba2fd166346e14;hb=d341283f757e188a52aedae7d715e201f2a430c2;hp=565884d0d0632a31506a3d5f2935e7e7ee2613d9;hpb=42384d2a2870e2cc119fdaa4db42de9865c6cea1;p=ashd.git diff --git a/src/userplex.c b/src/userplex.c index 565884d..d6c978c 100644 --- a/src/userplex.c +++ b/src/userplex.c @@ -43,9 +43,10 @@ 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 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)); @@ -80,12 +85,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,9 +235,13 @@ 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"); + fprintf(out, "usage: userplex [-hIs] [-g GROUP] [-m MIN-UID] [-d PUB-DIR] [PROGRAM ARGS...]\n"); } int main(int argc, char **argv) @@ -242,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"); @@ -269,8 +281,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 +291,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)