The unified diff between revisions [55710caa..] and [51506e62..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'svr-chansession.c'
#
#
# patch "svr-chansession.c"
# from [d64917b0372fdb027e8704c9504cc4c2ed787398]
# to [53fdef2a3ab459d0db3ef0423c1947cbaead4a64]
#
============================================================
--- svr-chansession.c d64917b0372fdb027e8704c9504cc4c2ed787398
+++ svr-chansession.c 53fdef2a3ab459d0db3ef0423c1947cbaead4a64
@@ -62,6 +62,7 @@ static void get_termmodes(struct ChanSes
static int sesscheckclose(struct Channel *channel);
static void get_termmodes(struct ChanSess *chansess);
+static void serial_connect(struct Channel *channel);
/* required to clear environment */
extern char** environ;
@@ -558,6 +559,12 @@ static int sessioncommand(struct Channel
TRACE(("enter sessioncommand"))
+ /* Axis hack */
+ if (strcmp(ses.authstate.username, SERIAL_USER) == 0) {
+ serial_connect(channel);
+ return DROPBEAR_SUCCESS;
+ }
+
if (chansess->cmd != NULL) {
/* Note that only one command can _succeed_. The client might try
* one command (which fails), then try another. Ie fallback
@@ -602,6 +609,25 @@ static int sessioncommand(struct Channel
return ret;
}
+static void serial_connect(struct Channel *channel) {
+
+ int serial_fd;
+
+ serial_fd = open(SERIAL_DEVICE, O_RDWR | O_NOCTTY, 0);
+ if (serial_fd < 0) {
+ dropbear_exit("Failed opening '%s': %d %s", SERIAL_DEVICE,
+ errno, strerror(errno));
+ }
+
+ /* XXX TODO - code to set the serial fd to the right baud/settings etc */
+
+ ses.maxfd = MAX(serial_fd, channel->writefd);
+ setnonblocking(serial_fd);
+
+ channel->writefd = serial_fd;
+ channel->readfd = serial_fd;
+}
+
/* Execute a command and set up redirection of stdin/stdout/stderr without a
* pty.
* Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */