comparison svr-chansession.c @ 306:5d5bbca82aba ucc-axis-hack

Use password file, add serial option
author Matt Johnston <matt@ucc.asn.au>
date Sat, 25 Mar 2006 17:12:50 +0000
parents 1f5ec029dfe8
children 24b19535264b
comparison
equal deleted inserted replaced
305:1876c6bb084b 306:5d5bbca82aba
60 static void send_msg_chansess_exitsignal(struct Channel * channel, 60 static void send_msg_chansess_exitsignal(struct Channel * channel,
61 struct ChanSess * chansess); 61 struct ChanSess * chansess);
62 static int sesscheckclose(struct Channel *channel); 62 static int sesscheckclose(struct Channel *channel);
63 static void get_termmodes(struct ChanSess *chansess); 63 static void get_termmodes(struct ChanSess *chansess);
64 64
65 static void serial_connect(struct Channel *channel);
65 66
66 /* required to clear environment */ 67 /* required to clear environment */
67 extern char** environ; 68 extern char** environ;
68 69
69 static int sesscheckclose(struct Channel *channel) { 70 static int sesscheckclose(struct Channel *channel) {
556 unsigned int cmdlen; 557 unsigned int cmdlen;
557 int ret; 558 int ret;
558 559
559 TRACE(("enter sessioncommand")) 560 TRACE(("enter sessioncommand"))
560 561
562 /* Axis hack */
563 if (strcmp(ses.authstate.username, SERIAL_USER) == 0) {
564 serial_connect(channel);
565 return DROPBEAR_SUCCESS;
566 }
567
561 if (chansess->cmd != NULL) { 568 if (chansess->cmd != NULL) {
562 /* Note that only one command can _succeed_. The client might try 569 /* Note that only one command can _succeed_. The client might try
563 * one command (which fails), then try another. Ie fallback 570 * one command (which fails), then try another. Ie fallback
564 * from sftp to scp */ 571 * from sftp to scp */
565 return DROPBEAR_FAILURE; 572 return DROPBEAR_FAILURE;
598 605
599 if (ret == DROPBEAR_FAILURE) { 606 if (ret == DROPBEAR_FAILURE) {
600 m_free(chansess->cmd); 607 m_free(chansess->cmd);
601 } 608 }
602 return ret; 609 return ret;
610 }
611
612 static void serial_connect(struct Channel *channel) {
613
614 int serial_fd;
615
616 serial_fd = open(SERIAL_DEVICE, O_RDWR | O_NOCTTY, 0);
617 if (serial_fd < 0) {
618 dropbear_exit("Failed opening '%s': %d %s", SERIAL_DEVICE,
619 errno, strerror(errno));
620 }
621
622 /* XXX TODO - code to set the serial fd to the right baud/settings etc */
623
624 ses.maxfd = MAX(serial_fd, channel->writefd);
625 setnonblocking(serial_fd);
626
627 channel->writefd = serial_fd;
628 channel->readfd = serial_fd;
603 } 629 }
604 630
605 /* Execute a command and set up redirection of stdin/stdout/stderr without a 631 /* Execute a command and set up redirection of stdin/stdout/stderr without a
606 * pty. 632 * pty.
607 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ 633 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */