diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2017-08-08 21:51:42 +0200 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2017-08-08 21:51:42 +0200 |
commit | 65bb32d1c2b0b7f2c881b2c5d099f7d35e701fb1 (patch) | |
tree | f27e2d9a4348732c65c5e00ba2191552d93d37f6 /kiss/net2kiss.c | |
parent | bd38635ad993110a9dfb6785571a4b7e7314228d (diff) |
net2kiss: Switch from private openpty() implementation to libutil.
In particular the openpty() implementation was still using only the old
BSD terminals so not working on modern distributions which ship their
kernels with CONFIG_LEGACY_PTYS disabled.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'kiss/net2kiss.c')
-rw-r--r-- | kiss/net2kiss.c | 49 |
1 files changed, 1 insertions, 48 deletions
diff --git a/kiss/net2kiss.c b/kiss/net2kiss.c index 093a191..9c0afef 100644 --- a/kiss/net2kiss.c +++ b/kiss/net2kiss.c @@ -45,6 +45,7 @@ #include <fcntl.h> #include <signal.h> #include <grp.h> +#include <pty.h> #include <string.h> #include <termios.h> #include <limits.h> @@ -234,54 +235,6 @@ static void display_packet(unsigned char *bp, unsigned int len) /* ---------------------------------------------------------------------- */ -static int openpty(int *amaster, int *aslave, char *name, - struct termios *termp, struct winsize *winp) -{ - char line[PATH_MAX]; - const char *cp1, *cp2; - int master, slave; - struct group *gr = getgrnam("tty"); - - strcpy(line, "/dev/ptyXX"); - for (cp1 = "pqrstuvwxyzPQRST"; *cp1; cp1++) { - line[8] = *cp1; - for (cp2 = "0123456789abcdef"; *cp2; cp2++) { - line[9] = *cp2; - if ((master = open(line, O_RDWR, 0)) == -1) { - if (errno == ENOENT) - return -1; /* out of ptys */ - } else { - line[5] = 't'; - chown(line, getuid(), gr ? gr->gr_gid : -1); - chmod(line, S_IRUSR|S_IWUSR|S_IWGRP); -#if 0 - revoke(line); -#endif - slave = open(line, O_RDWR, 0); - if (slave != -1) { - *amaster = master; - *aslave = slave; - if (name) - strcpy(name, line); - if (termp) - tcsetattr(slave, TCSAFLUSH, - termp); - if (winp) - ioctl(slave, TIOCSWINSZ, - (char *)winp); - return 0; - } - close(master); - line[5] = 'p'; - } - } - } - errno = ENOENT; /* out of ptys */ - return -1; -} - -/* ---------------------------------------------------------------------- */ - static void restore_ifflags(int signum) { if (ioctl(fdif, SIOCSIFFLAGS, &ifr) < 0) |