31 |
#include <string.h> |
#include <string.h> |
32 |
#include <utmp.h> |
#include <utmp.h> |
33 |
#include <sys/ioctl.h> |
#include <sys/ioctl.h> |
34 |
|
#include <termios.h> |
35 |
|
|
36 |
/* XXX */ |
/* XXX */ |
37 |
extern char *localhost (); |
extern char *localhost (); |
38 |
|
|
39 |
#define _PATH_LOGIN "/bin/login" |
#define _PATH_LOGIN "/bin/login" |
40 |
|
|
41 |
|
/* Parse the terminal speed. */ |
42 |
|
static void |
43 |
|
set_speed (int tty, char *speedstr) |
44 |
|
{ |
45 |
|
error_t err; |
46 |
|
struct termios ttystat; |
47 |
|
speed_t speed; |
48 |
|
char *tail; |
49 |
|
|
50 |
|
errno = 0; |
51 |
|
speed = strtoul (speedstr, &tail, 0); |
52 |
|
if (errno || *tail) |
53 |
|
return; |
54 |
|
|
55 |
|
err = tcgetattr (tty, &ttystat); |
56 |
|
if (!err && !cfsetspeed (&ttystat, speed)) |
57 |
|
tcsetattr (tty, TCSAFLUSH, &ttystat); |
58 |
|
} |
59 |
|
|
60 |
|
|
61 |
/* Print a suitable welcome banner */ |
/* Print a suitable welcome banner */ |
62 |
static void |
static void |
63 |
print_banner (int fd, char *ttyname) |
print_banner (int fd, char *ttyname) |
94 |
} |
} |
95 |
|
|
96 |
/* Don't do anything with this for now. */ |
/* Don't do anything with this for now. */ |
97 |
linespec = argv[2]; |
linespec = argv[1]; |
98 |
|
|
99 |
tt = getttynam (argv[2]); |
tt = getttynam (argv[2]); |
100 |
asprintf (&ttyname, "%s/%s", _PATH_DEV, argv[2]); |
asprintf (&ttyname, "%s/%s", _PATH_DEV, argv[2]); |
116 |
} |
} |
117 |
while (tty == -1); |
while (tty == -1); |
118 |
|
|
119 |
|
set_speed (tty, linespec); |
120 |
|
|
121 |
print_banner (tty, ttyname); |
print_banner (tty, ttyname); |
122 |
|
|
123 |
if (login_tty (tty) == -1) |
if (login_tty (tty) == -1) |