summaryrefslogtreecommitdiff
path: root/comms/modemd/patches/patch-ab
blob: 451fd2e3b78a3a65c55b66ef99fbdbd81586f65f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
$NetBSD: patch-ab,v 1.7 2017/02/17 17:00:03 joerg Exp $

--- common/ttio.c.orig	1997-02-21 23:06:09.000000000 +0000
+++ common/ttio.c
@@ -45,12 +45,21 @@ static char copyright[] =
 #include "osdep.h"
 #include "cdefs.h"
 #include "global.h"
+#include <ctype.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <syslog.h>
 #include "mcap.h"
 #include "ttio.h"
 #include <pwd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#ifndef __sun
+#include <util.h>
+#else
+#include <sys/file.h>
+#endif
 
 static void dectl PROTO ((char *, int, char *, int, char *));
 
@@ -73,6 +82,16 @@ int ttsetup (name)
     {
       if (chown (nbuf, pw -> pw_uid, pw -> pw_gid) < 0)
 	warn ("Can't set owner on %s: %m", nbuf);
+#ifdef __NetBSD__
+      if (chmod (nbuf, 0600) < 0)
+        warn ("Can't set mode on %s: %m", nbuf);
+      revoke(nbuf);
+      if (ttyaction(nbuf, "modemd", "root"))
+        warn ("Can't ttyaction %s: %m", nbuf);
+
+      /* delay open so DTR stays down long enough to be detected */
+      usleep(100);
+#endif
     }
 
   /* Open the terminal device. */
@@ -131,20 +150,19 @@ int ttsetup (name)
   return fd;
 }
 
-void ttnormal (fd)
+void ttnormal (int fd)
 {
   NORMAL_TTY (ts);
   PUT_TTY_STATE (fd, ts);
 }
 
-void tthupcl (fd)
+void tthupcl (int fd)
 {
   HUPCL_TTY (ts);
   PUT_TTY_STATE (fd, ts);
 }
 
-void redirect_std (fd)
-     int fd;
+void redirect_std (int fd)
 {
   int i;
 
@@ -203,10 +221,8 @@ static int tteof = 0;
 
 /* Match the specified string with input from the specified tty.
    Return nonzero if input matches, zero if not. */
-ttmatch (ANSI_DECL (int) tty, ANSI_DECL (int) timeout, VA_DOTDOTDOT)
-     KandR (int tty;)
-     KandR (int timeout;)
-     va_dcl
+int
+ttmatch (int tty, int timeout, ...)
 {
   TIME entry, now, to;
   int cur, curmatch, next;
@@ -230,7 +246,7 @@ ttmatch (ANSI_DECL (int) tty, ANSI_DECL 
 	 match, try reading some more data from the tty... */
       matchID = 1;
       VA_start (list, timeout);
-      while (string = va_arg (list, char *))
+      while ((string = va_arg (list, char *)))
 	{
 	  syslog (LOG_DEBUG, "Matching against %s", string);
 	  for (cur = ttstart; cur != ttend; cur = NEXT (cur))
@@ -316,9 +332,7 @@ ttmatch (ANSI_DECL (int) tty, ANSI_DECL 
 }
 
 /* Read a connect speed from standard in... */
-ttread_connect_speed (tty, timeout)
-     int tty;
-     int timeout;
+int ttread_connect_speed (int tty, int timeout)
 {
   TIME entry, now, to;
   int status;