--- ansh/src/anshd.c 2011/10/13 16:08:52 1.1.1.1.2.4 +++ ansh/src/anshd.c 2011/10/17 20:14:02 1.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ - * $Id: anshd.c,v 1.1.1.1.2.4 2011/10/13 16:08:52 misho Exp $ + * $Id: anshd.c,v 1.2 2011/10/17 20:14:02 misho Exp $ * ************************************************************************* The ELWIX and AITNET software is distributed under the following @@ -53,7 +53,11 @@ int Verbose; u_int Crypted = 1; proc_head_t pH; int bpfLEN, Timeout, Daemon = 1; +char Key[STRSIZ]; +static sched_root_task_t *root = NULL; +static struct tagProc *proc; + extern char compiled[], compiledby[], compilehost[]; static void @@ -65,6 +69,7 @@ Usage() "\t-d \tBind to host interface, like 'em0' (default is first host interface)\n" "\t-U \tRun service with other user\n" "\t-C \tRun service into chroot directory\n" + "\t-k \tService cipher key\n" "\t-t \tTimeout of login if no activity (default is 0 sec)\n" "\t-u\t\tSwitch to unencrypted traffic between hosts\n" "\t-b\t\tRun into batch mode (default is daemon mode)\n" @@ -77,6 +82,7 @@ static void sig(int s) { int state; + pid_t pid; switch (s) { case SIGHUP: @@ -91,7 +97,8 @@ sig(int s) break; case SIGCHLD: VERB(1) LOG("Got SIGCHLD!\n"); - while (waitpid(-1, &state, WNOHANG) > 0); + while ((pid = waitpid(-1, &state, WNOHANG)) > 0) + stopProcess(root, &pH, pid, pktTx); break; } } @@ -117,12 +124,12 @@ main(int argc, char **argv) int fd, h = 0, uid = 0, gid = 0; char ch, szUser[STRSIZ] = "root", szChroot[STRSIZ] = "/", szDev[STRSIZ] = { 0 }; struct sigaction sact; - sched_root_task_t *root = NULL; - struct tagProc *proc; Get1stEth(szDev, STRSIZ); - while ((ch = getopt(argc, argv, "hvubt:d:U:C:")) != -1) + strlcpy(Key, DEFAULT_KEY, sizeof Key); + + while ((ch = getopt(argc, argv, "hvubt:d:U:C:k:")) != -1) switch (ch) { case 'U': pass = getpwnam(optarg); @@ -148,6 +155,9 @@ main(int argc, char **argv) break; case 'd': strlcpy(szDev, optarg, sizeof szDev); + break; + case 'k': + strlcpy(Key, optarg, sizeof Key); break; case 'u': Crypted ^= Crypted;