diff options
Diffstat (limited to 'other/openssh-reverse/next-posix.c')
| -rw-r--r-- | other/openssh-reverse/next-posix.c | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/other/openssh-reverse/next-posix.c b/other/openssh-reverse/next-posix.c new file mode 100644 index 0000000..0ca241f --- /dev/null +++ b/other/openssh-reverse/next-posix.c | |||
| @@ -0,0 +1,104 @@ | |||
| 1 | #include "config.h" | ||
| 2 | |||
| 3 | #ifdef HAVE_NEXT | ||
| 4 | #include <stdio.h> | ||
| 5 | #include <stdlib.h> | ||
| 6 | #include <string.h> | ||
| 7 | #include <errno.h> | ||
| 8 | #include <unistd.h> | ||
| 9 | |||
| 10 | #include <sys/types.h> | ||
| 11 | #include <sys/stat.h> | ||
| 12 | #include <fcntl.h> | ||
| 13 | |||
| 14 | #include <sys/fcntl.h> | ||
| 15 | #include <sys/ioctl.h> | ||
| 16 | #include <sys/time.h> | ||
| 17 | #include <sys/file.h> | ||
| 18 | #include <errno.h> | ||
| 19 | #include <termios.h> | ||
| 20 | #include <sys/wait.h> | ||
| 21 | |||
| 22 | #include "xmalloc.h" | ||
| 23 | #include "ssh.h" | ||
| 24 | #include "next-posix.h" | ||
| 25 | |||
| 26 | int | ||
| 27 | waitpid(int pid, int *stat_loc, int options) | ||
| 28 | { | ||
| 29 | if (pid <= 0) { | ||
| 30 | if (pid != -1) { | ||
| 31 | errno = EINVAL; | ||
| 32 | return -1; | ||
| 33 | } | ||
| 34 | pid = 0; /* wait4() expects pid=0 for indiscriminate wait. */ | ||
| 35 | } | ||
| 36 | return wait4(pid, (union wait *)stat_loc, options, NULL); | ||
| 37 | } | ||
| 38 | |||
| 39 | pid_t setsid(void) | ||
| 40 | { | ||
| 41 | return setpgrp(0, getpid()); | ||
| 42 | } | ||
| 43 | |||
| 44 | int | ||
| 45 | tcgetattr(int fd, struct termios *t) | ||
| 46 | { | ||
| 47 | return (ioctl(fd, TIOCGETA, t)); | ||
| 48 | } | ||
| 49 | |||
| 50 | int | ||
| 51 | tcsetattr(int fd, int opt, const struct termios *t) | ||
| 52 | { | ||
| 53 | struct termios localterm; | ||
| 54 | |||
| 55 | if (opt & TCSASOFT) { | ||
| 56 | localterm = *t; | ||
| 57 | localterm.c_cflag |= CIGNORE; | ||
| 58 | t = &localterm; | ||
| 59 | } | ||
| 60 | switch (opt & ~TCSASOFT) { | ||
| 61 | case TCSANOW: | ||
| 62 | return (ioctl(fd, TIOCSETA, t)); | ||
| 63 | case TCSADRAIN: | ||
| 64 | return (ioctl(fd, TIOCSETAW, t)); | ||
| 65 | case TCSAFLUSH: | ||
| 66 | return (ioctl(fd, TIOCSETAF, t)); | ||
| 67 | default: | ||
| 68 | errno = EINVAL; | ||
| 69 | return (-1); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | int tcsetpgrp(int fd, pid_t pgrp) | ||
| 74 | { | ||
| 75 | int s; | ||
| 76 | |||
| 77 | s = pgrp; | ||
| 78 | return (ioctl(fd, TIOCSPGRP, &s)); | ||
| 79 | } | ||
| 80 | |||
| 81 | speed_t cfgetospeed(const struct termios *t) | ||
| 82 | { | ||
| 83 | return (t->c_ospeed); | ||
| 84 | } | ||
| 85 | |||
| 86 | speed_t cfgetispeed(const struct termios *t) | ||
| 87 | { | ||
| 88 | return (t->c_ispeed); | ||
| 89 | } | ||
| 90 | |||
| 91 | int | ||
| 92 | cfsetospeed(struct termios *t,int speed) | ||
| 93 | { | ||
| 94 | t->c_ospeed = speed; | ||
| 95 | return (0); | ||
| 96 | } | ||
| 97 | |||
| 98 | int | ||
| 99 | cfsetispeed(struct termios *t, int speed) | ||
| 100 | { | ||
| 101 | t->c_ispeed = speed; | ||
| 102 | return (0); | ||
| 103 | } | ||
| 104 | #endif /* HAVE_NEXT */ | ||
