--- ansh/src/daemon3.c 2011/10/14 12:03:10 1.1.1.1.2.7 +++ ansh/src/daemon3.c 2012/01/23 10:34:13 1.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ - * $Id: daemon3.c,v 1.1.1.1.2.7 2011/10/14 12:03:10 misho Exp $ + * $Id: daemon3.c,v 1.3 2012/01/23 10:34:13 misho Exp $ * ************************************************************************* The ELWIX and AITNET software is distributed under the following @@ -83,7 +83,7 @@ void * icmpRx(sched_task_t *task) { u_char *buf, *str; - struct sockaddr sa; + io_sockaddr_t sa; int rlen, n = 0, salen = sizeof sa; struct tagProc *proc = NULL; char ret; @@ -175,21 +175,6 @@ fdTx(sched_task_t *task) if (proc->proc_flg != ANSH_FLG_CPOUT || !proc->proc_pid) return NULL; - /* - if (waitpid(proc->proc_pid, &wlen, WNOHANG)) { - ioFreePTY(TASK_FD(task), proc->proc_ttyname); - schedCancelby(TASK_ROOT(task), NULL, CRITERIA_FD, (void*) TASK_FD(task), NULL); - - proc->proc_pid = 0; - proc->proc_seq = 0; - proc->proc_flg = ANSH_FLG_EOF; - proc->proc_rlen_[FD2NET] = 0; - - schedWrite(TASK_ROOT(task), icmpTx, proc, proc->proc_sock); - return NULL; - } - */ - /* if Timeout defined, disarm timer */ if (Timeout) schedCancelby(TASK_ROOT(task), &TASK_ROOT(task)->root_timer, CRITERIA_CALL, TOfunc, NULL); @@ -199,18 +184,6 @@ fdTx(sched_task_t *task) case -1: ERR("write2tty #%d - %s", errno, strerror(errno)); /* exit from shell and release tty */ - /* - waitpid(proc->proc_pid, &wlen, 0); - ioFreePTY(TASK_FD(task), proc->proc_ttyname); - schedCancelby(TASK_ROOT(task), NULL, CRITERIA_FD, (void*) TASK_FD(task), NULL); - - proc->proc_pid = 0; - proc->proc_seq = 0; - proc->proc_flg = ANSH_FLG_EOF; - proc->proc_rlen_[FD2NET] = 0; - - schedWrite(TASK_ROOT(task), icmpTx, proc, proc->proc_sock); - */ return NULL; default: proc->proc_flg = ANSH_FLG_OK; @@ -241,21 +214,6 @@ fdRx(sched_task_t *task) if (!proc->proc_pid) return NULL; - /* - if (waitpid(proc->proc_pid, &rlen, WNOHANG)) { - ioFreePTY(TASK_FD(task), proc->proc_ttyname); - schedCancelby(TASK_ROOT(task), NULL, CRITERIA_FD, (void*) TASK_FD(task), NULL); - - proc->proc_pid = 0; - proc->proc_seq = 0; - proc->proc_flg = ANSH_FLG_EOF; - proc->proc_rlen_[FD2NET] = 0; - - schedWrite(TASK_ROOT(task), icmpTx, proc, proc->proc_sock); - return NULL; - } - */ - /* if Timeout defined, disarm timer */ if (Timeout) schedCancelby(TASK_ROOT(task), &TASK_ROOT(task)->root_timer, CRITERIA_CALL, TOfunc, NULL); @@ -268,19 +226,6 @@ fdRx(sched_task_t *task) ERR("readtty #%d - %s", errno, strerror(errno)); case 0: /* exit from shell and release tty */ - /* - waitpid(proc->proc_pid, &rlen, 0); - ioFreePTY(TASK_FD(task), proc->proc_ttyname); - schedCancelby(TASK_ROOT(task), NULL, CRITERIA_FD, (void*) TASK_FD(task), NULL); - VERB(3) LOG("EOF process status %d", rlen); - - proc->proc_pid = 0; - proc->proc_seq = 0; - proc->proc_flg = ANSH_FLG_EOF; - proc->proc_rlen_[FD2NET] = 0; - - schedWrite(TASK_ROOT(task), icmpTx, proc, proc->proc_sock); - */ return NULL; default: proc->proc_flg = ANSH_FLG_OK; @@ -305,8 +250,6 @@ spawnLogin(sched_task_t *task, struct tagProc *proc) int flg; struct timeval tv = { 0 }; char str[STRSIZ] = { 0 }; - struct sockaddr_in *sin; - struct sockaddr_in6 *sin6; FTRACE(3); @@ -321,13 +264,10 @@ spawnLogin(sched_task_t *task, struct tagProc *proc) printf("ansh3d ELWIX remote management system over ICMP (%s)\n\n", proc->proc_ttyname); strlcpy(str, "-hansh3@", sizeof str); - if (proc->proc_cli.sa_family == AF_INET) { - sin = (struct sockaddr_in*) &proc->proc_cli; - inet_ntop(AF_INET, &sin->sin_addr, str + 8, INET_ADDRSTRLEN); - } else if (proc->proc_cli.sa_family == AF_INET6) { - sin6 = (struct sockaddr_in6*) &proc->proc_cli; - inet_ntop(AF_INET6, &sin6->sin6_addr, str + 8, INET6_ADDRSTRLEN); - } + if (proc->proc_cli.sa.sa_family == AF_INET) + inet_ntop(AF_INET, &proc->proc_cli.sin.sin_addr, str + 8, INET_ADDRSTRLEN); + else if (proc->proc_cli.sa.sa_family == AF_INET6) + inet_ntop(AF_INET6, &proc->proc_cli.sin6.sin6_addr, str + 8, INET6_ADDRSTRLEN); execl("/usr/bin/login", "login", str, NULL); /* never reached */ return -1;