--- ansh/src/ansh3d.c 2011/10/17 20:14:02 1.2 +++ ansh/src/ansh3d.c 2015/05/19 23:25:30 1.5 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ - * $Id: ansh3d.c,v 1.2 2011/10/17 20:14:02 misho Exp $ + * $Id: ansh3d.c,v 1.5 2015/05/19 23:25:30 misho Exp $ * ************************************************************************* The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 +Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -52,7 +52,7 @@ intptr_t Kill; int Verbose; u_int Crypted = 1; proc_head_t pH; -int bpfLEN, Timeout, Daemon = 1; +int bpfLEN, Timeout = 300, Daemon = 1; char Key[STRSIZ]; static struct tagProc *proc; @@ -70,7 +70,7 @@ Usage() "\t-i \tService ID (default is 42)\n" "\t-U \tRun service with other user\n" "\t-C \tRun service into chroot directory\n" - "\t-t \tTimeout of login if no activity (default is 0 sec)\n" + "\t-t \tTimeout of login if no activity (default is 300 sec)\n" "\t-k \tService cipher key\n" "\t-u\t\tSwitch to unencrypted traffic between hosts\n" "\t-b\t\tRun into batch mode (default is daemon mode)\n" @@ -121,9 +121,7 @@ hook_error(void *root, void *arg) int main(int argc, char **argv) { - struct sockaddr sa = { 0 }; - struct sockaddr_in *sin4 = (struct sockaddr_in*) &sa; - struct sockaddr_in6 *sin6 = (struct sockaddr_in6*) &sa; + sockaddr_t sa; struct hostent *host; struct passwd *pass; int fd, h = 0, uid = 0, gid = 0; @@ -131,6 +129,7 @@ main(int argc, char **argv) char ch, szUser[STRSIZ] = "root", szChroot[STRSIZ] = "/"; struct sigaction sact; + memset(&sa, 0, sizeof sa); strlcpy(Key, DEFAULT_KEY, sizeof Key); while ((ch = getopt(argc, argv, "hvubt:a:i:U:C:k:")) != -1) @@ -172,14 +171,14 @@ main(int argc, char **argv) } switch (host->h_addrtype) { case AF_INET: - sin4->sin_len = sizeof(struct sockaddr_in); - sin4->sin_family = AF_INET; - memcpy(&sin4->sin_addr.s_addr, host->h_addr, host->h_length); + sa.sin.sin_len = sizeof(struct sockaddr_in); + sa.sin.sin_family = AF_INET; + memcpy(&sa.sin.sin_addr.s_addr, host->h_addr, host->h_length); break; case AF_INET6: - sin6->sin6_len = sizeof(struct sockaddr_in6); - sin6->sin6_family = AF_INET6; - memcpy(&sin6->sin6_addr.s6_addr, host->h_addr, host->h_length); + sa.sin6.sin6_len = sizeof(struct sockaddr_in6); + sa.sin6.sin6_family = AF_INET6; + memcpy(&sa.sin6.sin6_addr.s6_addr, host->h_addr, host->h_length); break; default: printf("Error:: Unknown address type %d !!!\n", host->h_addrtype); @@ -204,9 +203,9 @@ main(int argc, char **argv) argv += optind; /* sanity check for openned descriptor */ - if (!sa.sa_family) { - sin4->sin_len = sizeof(struct sockaddr_in); - sin4->sin_family = AF_INET; + if (!sa.sa.sa_family) { + sa.sin.sin_len = sizeof(struct sockaddr_in); + sa.sin.sin_family = AF_INET; } /* catch signals */ @@ -287,7 +286,7 @@ main(int argc, char **argv) setgid(gid); setuid(uid); - if (schedRead(root, icmpRx, (void*) id, h)) { + if (schedRead(root, icmpRx, (void*) id, h, NULL, 0)) { schedRun(root, &Kill); } else ERR("Failed to add reader task #%d - %s\n", sched_GetErrno(), sched_GetError());