| @@ -1,99 +1,100 @@ | | | @@ -1,99 +1,100 @@ |
1 | $NetBSD: patch-ab,v 1.6 2013/09/10 14:15:11 joerg Exp $ | | 1 | $NetBSD: patch-ab,v 1.7 2017/02/17 17:00:03 joerg Exp $ |
2 | | | 2 | |
3 | --- common/ttio.c.orig 1997-02-21 23:06:09.000000000 +0000 | | 3 | --- common/ttio.c.orig 1997-02-21 23:06:09.000000000 +0000 |
4 | +++ common/ttio.c | | 4 | +++ common/ttio.c |
5 | @@ -45,12 +45,20 @@ static char copyright[] = | | 5 | @@ -45,12 +45,21 @@ static char copyright[] = |
6 | #include "osdep.h" | | 6 | #include "osdep.h" |
7 | #include "cdefs.h" | | 7 | #include "cdefs.h" |
8 | #include "global.h" | | 8 | #include "global.h" |
9 | +#include <ctype.h> | | 9 | +#include <ctype.h> |
10 | #include <stdio.h> | | 10 | #include <stdio.h> |
11 | #include <fcntl.h> | | 11 | #include <fcntl.h> |
12 | #include <syslog.h> | | 12 | #include <syslog.h> |
13 | #include "mcap.h" | | 13 | #include "mcap.h" |
14 | #include "ttio.h" | | 14 | #include "ttio.h" |
15 | #include <pwd.h> | | 15 | #include <pwd.h> |
16 | +#include <stdlib.h> | | 16 | +#include <stdlib.h> |
| | | 17 | +#include <sys/stat.h> |
17 | +#include <sys/ioctl.h> | | 18 | +#include <sys/ioctl.h> |
18 | +#ifndef __sun | | 19 | +#ifndef __sun |
19 | +#include <util.h> | | 20 | +#include <util.h> |
20 | +#else | | 21 | +#else |
21 | +#include <sys/file.h> | | 22 | +#include <sys/file.h> |
22 | +#endif | | 23 | +#endif |
23 | | | 24 | |
24 | static void dectl PROTO ((char *, int, char *, int, char *)); | | 25 | static void dectl PROTO ((char *, int, char *, int, char *)); |
25 | | | 26 | |
26 | @@ -73,6 +81,16 @@ int ttsetup (name) | | 27 | @@ -73,6 +82,16 @@ int ttsetup (name) |
27 | { | | 28 | { |
28 | if (chown (nbuf, pw -> pw_uid, pw -> pw_gid) < 0) | | 29 | if (chown (nbuf, pw -> pw_uid, pw -> pw_gid) < 0) |
29 | warn ("Can't set owner on %s: %m", nbuf); | | 30 | warn ("Can't set owner on %s: %m", nbuf); |
30 | +#ifdef __NetBSD__ | | 31 | +#ifdef __NetBSD__ |
31 | + if (chmod (nbuf, 0600) < 0) | | 32 | + if (chmod (nbuf, 0600) < 0) |
32 | + warn ("Can't set mode on %s: %m", nbuf); | | 33 | + warn ("Can't set mode on %s: %m", nbuf); |
33 | + revoke(nbuf); | | 34 | + revoke(nbuf); |
34 | + if (ttyaction(nbuf, "modemd", "root")) | | 35 | + if (ttyaction(nbuf, "modemd", "root")) |
35 | + warn ("Can't ttyaction %s: %m", nbuf); | | 36 | + warn ("Can't ttyaction %s: %m", nbuf); |
36 | + | | 37 | + |
37 | + /* delay open so DTR stays down long enough to be detected */ | | 38 | + /* delay open so DTR stays down long enough to be detected */ |
38 | + usleep(100); | | 39 | + usleep(100); |
39 | +#endif | | 40 | +#endif |
40 | } | | 41 | } |
41 | | | 42 | |
42 | /* Open the terminal device. */ | | 43 | /* Open the terminal device. */ |
43 | @@ -131,20 +149,19 @@ int ttsetup (name) | | 44 | @@ -131,20 +150,19 @@ int ttsetup (name) |
44 | return fd; | | 45 | return fd; |
45 | } | | 46 | } |
46 | | | 47 | |
47 | -void ttnormal (fd) | | 48 | -void ttnormal (fd) |
48 | +void ttnormal (int fd) | | 49 | +void ttnormal (int fd) |
49 | { | | 50 | { |
50 | NORMAL_TTY (ts); | | 51 | NORMAL_TTY (ts); |
51 | PUT_TTY_STATE (fd, ts); | | 52 | PUT_TTY_STATE (fd, ts); |
52 | } | | 53 | } |
53 | | | 54 | |
54 | -void tthupcl (fd) | | 55 | -void tthupcl (fd) |
55 | +void tthupcl (int fd) | | 56 | +void tthupcl (int fd) |
56 | { | | 57 | { |
57 | HUPCL_TTY (ts); | | 58 | HUPCL_TTY (ts); |
58 | PUT_TTY_STATE (fd, ts); | | 59 | PUT_TTY_STATE (fd, ts); |
59 | } | | 60 | } |
60 | | | 61 | |
61 | -void redirect_std (fd) | | 62 | -void redirect_std (fd) |
62 | - int fd; | | 63 | - int fd; |
63 | +void redirect_std (int fd) | | 64 | +void redirect_std (int fd) |
64 | { | | 65 | { |
65 | int i; | | 66 | int i; |
66 | | | 67 | |
67 | @@ -203,10 +220,8 @@ static int tteof = 0; | | 68 | @@ -203,10 +221,8 @@ static int tteof = 0; |
68 | | | 69 | |
69 | /* Match the specified string with input from the specified tty. | | 70 | /* Match the specified string with input from the specified tty. |
70 | Return nonzero if input matches, zero if not. */ | | 71 | Return nonzero if input matches, zero if not. */ |
71 | -ttmatch (ANSI_DECL (int) tty, ANSI_DECL (int) timeout, VA_DOTDOTDOT) | | 72 | -ttmatch (ANSI_DECL (int) tty, ANSI_DECL (int) timeout, VA_DOTDOTDOT) |
72 | - KandR (int tty;) | | 73 | - KandR (int tty;) |
73 | - KandR (int timeout;) | | 74 | - KandR (int timeout;) |
74 | - va_dcl | | 75 | - va_dcl |
75 | +int | | 76 | +int |
76 | +ttmatch (int tty, int timeout, ...) | | 77 | +ttmatch (int tty, int timeout, ...) |
77 | { | | 78 | { |
78 | TIME entry, now, to; | | 79 | TIME entry, now, to; |
79 | int cur, curmatch, next; | | 80 | int cur, curmatch, next; |
80 | @@ -230,7 +245,7 @@ ttmatch (ANSI_DECL (int) tty, ANSI_DECL | | 81 | @@ -230,7 +246,7 @@ ttmatch (ANSI_DECL (int) tty, ANSI_DECL |
81 | match, try reading some more data from the tty... */ | | 82 | match, try reading some more data from the tty... */ |
82 | matchID = 1; | | 83 | matchID = 1; |
83 | VA_start (list, timeout); | | 84 | VA_start (list, timeout); |
84 | - while (string = va_arg (list, char *)) | | 85 | - while (string = va_arg (list, char *)) |
85 | + while ((string = va_arg (list, char *))) | | 86 | + while ((string = va_arg (list, char *))) |
86 | { | | 87 | { |
87 | syslog (LOG_DEBUG, "Matching against %s", string); | | 88 | syslog (LOG_DEBUG, "Matching against %s", string); |
88 | for (cur = ttstart; cur != ttend; cur = NEXT (cur)) | | 89 | for (cur = ttstart; cur != ttend; cur = NEXT (cur)) |
89 | @@ -316,9 +331,7 @@ ttmatch (ANSI_DECL (int) tty, ANSI_DECL | | 90 | @@ -316,9 +332,7 @@ ttmatch (ANSI_DECL (int) tty, ANSI_DECL |
90 | } | | 91 | } |
91 | | | 92 | |
92 | /* Read a connect speed from standard in... */ | | 93 | /* Read a connect speed from standard in... */ |
93 | -ttread_connect_speed (tty, timeout) | | 94 | -ttread_connect_speed (tty, timeout) |
94 | - int tty; | | 95 | - int tty; |
95 | - int timeout; | | 96 | - int timeout; |
96 | +int ttread_connect_speed (int tty, int timeout) | | 97 | +int ttread_connect_speed (int tty, int timeout) |
97 | { | | 98 | { |
98 | TIME entry, now, to; | | 99 | TIME entry, now, to; |
99 | int status; | | 100 | int status; |