22 |
#include <utmp.h> /* updwtmp() */ |
#include <utmp.h> /* updwtmp() */ |
23 |
#endif |
#endif |
24 |
|
|
25 |
|
#ifndef IUCLC |
26 |
|
# define IUCLC 0 |
27 |
|
#endif |
28 |
|
|
29 |
/* |
/* |
30 |
* Some heuristics to find out what environment we are in: if it is not |
* Some heuristics to find out what environment we are in: if it is not |
31 |
* System V, assume it is SunOS 4. |
* System V, assume it is SunOS 4. |
32 |
*/ |
*/ |
33 |
#ifdef LOGIN_PROCESS /* defined in System V utmp.h */ |
#ifdef LOGIN_PROCESS /* defined in System V utmp.h */ |
34 |
#include <sys/utsname.h> |
#include <sys/utsname.h> |
|
#include <time.h> |
|
35 |
#else /* if !sysV style, wtmp/utmp code is off */ |
#else /* if !sysV style, wtmp/utmp code is off */ |
36 |
#undef ENABLE_FEATURE_UTMP |
#undef ENABLE_FEATURE_UTMP |
37 |
#undef ENABLE_FEATURE_WTMP |
#undef ENABLE_FEATURE_WTMP |
167 |
debug("entered parse_speeds\n"); |
debug("entered parse_speeds\n"); |
168 |
while ((cp = strsep(&arg, ",")) != NULL) { |
while ((cp = strsep(&arg, ",")) != NULL) { |
169 |
op->speeds[op->numspeed] = bcode(cp); |
op->speeds[op->numspeed] = bcode(cp); |
170 |
if (op->speeds[op->numspeed] <= 0) |
if (op->speeds[op->numspeed] < 0) |
171 |
bb_error_msg_and_die("bad speed: %s", cp); |
bb_error_msg_and_die("bad speed: %s", cp); |
172 |
|
/* note: arg "0" turns into speed B0 */ |
173 |
op->numspeed++; |
op->numspeed++; |
174 |
if (op->numspeed > MAX_SPEED) |
if (op->numspeed > MAX_SPEED) |
175 |
bb_error_msg_and_die("too many alternate speeds"); |
bb_error_msg_and_die("too many alternate speeds"); |
239 |
// cur_dir_fd = xopen(".", O_DIRECTORY | O_NONBLOCK); |
// cur_dir_fd = xopen(".", O_DIRECTORY | O_NONBLOCK); |
240 |
// xchdir("/dev"); |
// xchdir("/dev"); |
241 |
// xstat(tty, &st); |
// xstat(tty, &st); |
242 |
// if ((st.st_mode & S_IFMT) != S_IFCHR) |
// if (!S_ISCHR(st.st_mode)) |
243 |
// bb_error_msg_and_die("%s: not a character device", tty); |
// bb_error_msg_and_die("%s: not a character device", tty); |
244 |
|
|
245 |
if (tty[0] != '/') |
if (tty[0] != '/') |
275 |
/* termios_init - initialize termios settings */ |
/* termios_init - initialize termios settings */ |
276 |
static void termios_init(struct termios *tp, int speed, struct options *op) |
static void termios_init(struct termios *tp, int speed, struct options *op) |
277 |
{ |
{ |
278 |
|
speed_t ispeed, ospeed; |
279 |
/* |
/* |
280 |
* Initial termios settings: 8-bit characters, raw-mode, blocking i/o. |
* Initial termios settings: 8-bit characters, raw-mode, blocking i/o. |
281 |
* Special characters are set after we have read the login name; all |
* Special characters are set after we have read the login name; all |
286 |
/* flush input and output queues, important for modems! */ |
/* flush input and output queues, important for modems! */ |
287 |
ioctl(0, TCFLSH, TCIOFLUSH); /* tcflush(0, TCIOFLUSH)? - same */ |
ioctl(0, TCFLSH, TCIOFLUSH); /* tcflush(0, TCIOFLUSH)? - same */ |
288 |
#endif |
#endif |
289 |
|
ispeed = ospeed = speed; |
290 |
tp->c_cflag = CS8 | HUPCL | CREAD | speed; |
if (speed == B0) { |
291 |
|
/* Speed was specified as "0" on command line. |
292 |
|
* Just leave it unchanged */ |
293 |
|
ispeed = cfgetispeed(tp); |
294 |
|
ospeed = cfgetospeed(tp); |
295 |
|
} |
296 |
|
tp->c_cflag = CS8 | HUPCL | CREAD; |
297 |
if (op->flags & F_LOCAL) |
if (op->flags & F_LOCAL) |
298 |
tp->c_cflag |= CLOCAL; |
tp->c_cflag |= CLOCAL; |
299 |
|
cfsetispeed(tp, ispeed); |
300 |
|
cfsetospeed(tp, ospeed); |
301 |
|
|
302 |
tp->c_iflag = tp->c_lflag = tp->c_line = 0; |
tp->c_iflag = tp->c_lflag = tp->c_line = 0; |
303 |
tp->c_oflag = OPOST | ONLCR; |
tp->c_oflag = OPOST | ONLCR; |
487 |
case CTL('D'): |
case CTL('D'): |
488 |
exit(EXIT_SUCCESS); |
exit(EXIT_SUCCESS); |
489 |
default: |
default: |
490 |
if (!isascii(ascval) || !isprint(ascval)) { |
if (ascval < ' ') { |
491 |
/* ignore garbage characters */ |
/* ignore garbage characters */ |
492 |
} else if ((int)(bp - logname) >= size_logname - 1) { |
} else if ((int)(bp - logname) >= size_logname - 1) { |
493 |
bb_error_msg_and_die("%s: input overrun", op->tty); |
bb_error_msg_and_die("%s: input overrun", op->tty); |
583 |
} |
} |
584 |
|
|
585 |
/* update_utmp - update our utmp entry */ |
/* update_utmp - update our utmp entry */ |
586 |
static void update_utmp(const char *line, char *fakehost) |
static NOINLINE void update_utmp(const char *line, char *fakehost) |
587 |
{ |
{ |
588 |
struct utmp ut; |
struct utmp ut; |
589 |
struct utmp *utp; |
struct utmp *utp; |
727 |
/* Write the modem init string and DON'T flush the buffers */ |
/* Write the modem init string and DON'T flush the buffers */ |
728 |
if (options.flags & F_INITSTRING) { |
if (options.flags & F_INITSTRING) { |
729 |
debug("writing init string\n"); |
debug("writing init string\n"); |
730 |
|
/* todo: use xwrite_str? */ |
731 |
full_write(STDOUT_FILENO, options.initstring, strlen(options.initstring)); |
full_write(STDOUT_FILENO, options.initstring, strlen(options.initstring)); |
732 |
} |
} |
733 |
|
|
767 |
break; |
break; |
768 |
/* we are here only if options.numspeed > 1 */ |
/* we are here only if options.numspeed > 1 */ |
769 |
baud_index = (baud_index + 1) % options.numspeed; |
baud_index = (baud_index + 1) % options.numspeed; |
770 |
termios.c_cflag &= ~CBAUD; |
cfsetispeed(&termios, options.speeds[baud_index]); |
771 |
termios.c_cflag |= options.speeds[baud_index]; |
cfsetospeed(&termios, options.speeds[baud_index]); |
772 |
tcsetattr_stdin_TCSANOW(&termios); |
tcsetattr_stdin_TCSANOW(&termios); |
773 |
} |
} |
774 |
} |
} |