~ubuntu-branches/ubuntu/natty/openbsd-inetd/natty

« back to all changes in this revision

Viewing changes to debian/patches/libwrap

  • Committer: Bazaar Package Importer
  • Author(s): Marco d'Itri
  • Date: 2008-12-15 02:00:52 UTC
  • mfrom: (4.1.1 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081215020052-gwpkva043fq6nb1s
Tags: 0.20080125-2
* Added dh_md5sums to debian/rules, since apparently people nowadays
  believe again that it is a good idea. (Closes: #484483)
* Fixed the init script to povide "openbsd-inetd" instead of "inetd".
  (Closes: #507119)
* Updated patches misc_portability and setproctitle with some missing
  prototypes.
* Updated patch misc_portability with missing arguments to two syslog(3)
  calls.
* Updated patch libwrap to fix a possibly uninitialized variable.
  The last three fixes are courtesy of Denis Zaitsev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--- a/inetd.c
 
2
+++ b/inetd.c
 
3
@@ -175,6 +175,11 @@ size_t strlcpy(char *, const char *, siz
 
4
 #define        CNT_INTVL       60              /* servers in CNT_INTVL sec. */
 
5
 #define        RETRYTIME       (60*10)         /* retry after bind or server fail */
 
6
 
 
7
+#ifdef LIBWRAP
 
8
+# include <tcpd.h>
 
9
+int lflag = 0;
 
10
+#endif
 
11
+
 
12
 int     debug = 0;
 
13
 int     nsock, maxsock;
 
14
 fd_set *allsockp;
 
15
@@ -347,7 +352,7 @@ main(int argc, char *argv[], char *envp[
 
16
 
 
17
        initsetproctitle(argc, argv, envp);
 
18
 
 
19
-       while ((ch = getopt(argc, argv, "dER:")) != -1)
 
20
+       while ((ch = getopt(argc, argv, "dElR:")) != -1)
 
21
                switch (ch) {
 
22
                case 'd':
 
23
                        debug = 1;
 
24
@@ -355,6 +360,15 @@ main(int argc, char *argv[], char *envp[
 
25
                case 'E':
 
26
                        keepenv = 1;
 
27
                        break;
 
28
+               case 'l':
 
29
+#ifdef LIBWRAP
 
30
+                       lflag = 1;
 
31
+                       break;
 
32
+#else
 
33
+                       fprintf(stderr, "%s: libwrap support not enabled",
 
34
+                           progname);
 
35
+                       exit(1);
 
36
+#endif
 
37
                case 'R': {     /* invocation rate */
 
38
                        char *p;
 
39
                        int val;
 
40
@@ -372,7 +386,7 @@ main(int argc, char *argv[], char *envp[
 
41
                case '?':
 
42
                default:
 
43
                        fprintf(stderr,
 
44
-                           "usage: %s [-dE] [-R rate] [configuration file]\n",
 
45
+                           "usage: %s [-dEl] [-R rate] [configuration file]\n",
 
46
                            progname);
 
47
                        exit(1);
 
48
                }
 
49
@@ -1970,6 +1984,47 @@ spawn(struct servtab *sep, int ctrl)
 
50
        }
 
51
        sigprocmask(SIG_SETMASK, &emptymask, NULL);
 
52
        if (pid == 0) {
 
53
+#ifdef LIBWRAP
 
54
+               if (lflag && !sep->se_wait && sep->se_socktype == SOCK_STREAM) {
 
55
+                       struct request_info req;
 
56
+                       char *service;
 
57
+
 
58
+                       /* do not execute tcpd if it is in the config */
 
59
+                       if (strcmp(sep->se_server, "/usr/sbin/tcpd") == 0) {
 
60
+                               char *p, *name;
 
61
+
 
62
+                               free(sep->se_server);
 
63
+                               name = sep->se_server = sep->se_argv[0];
 
64
+                               for (p = name; *p; p++)
 
65
+                                       if (*p == '/')
 
66
+                                               name = p + 1;
 
67
+                               sep->se_argv[0] = newstr(name);
 
68
+                       }
 
69
+
 
70
+                       request_init(&req, RQ_DAEMON, sep->se_argv[0],
 
71
+                           RQ_FILE, ctrl, NULL);
 
72
+                       fromhost(&req);
 
73
+                       if (getnameinfo(&sep->se_ctrladdr,
 
74
+                           sizeof(sep->se_ctrladdr), NULL, 0, buf,
 
75
+                           sizeof(buf), 0) != 0) {
 
76
+                               /* shouldn't happen */
 
77
+                               snprintf(buf, sizeof buf, "%d",
 
78
+                                   ntohs(sep->se_ctrladdr_in.sin_port));
 
79
+                       }
 
80
+                       service = buf;
 
81
+                       if (!hosts_access(&req)) {
 
82
+                               syslog(deny_severity, "refused connection"
 
83
+                                   " from %.500s, service %s (%s)",
 
84
+                                   eval_client(&req), service, sep->se_proto);
 
85
+                               if (sep->se_socktype != SOCK_STREAM)
 
86
+                                       recv(0, buf, sizeof (buf), 0);
 
87
+                               exit(1);
 
88
+                       }
 
89
+                       syslog(allow_severity,
 
90
+                           "connection from %.500s, service %s (%s)",
 
91
+                           eval_client(&req), service, sep->se_proto);
 
92
+               }
 
93
+#endif
 
94
                if (sep->se_bi)
 
95
                        (*sep->se_bi->bi_fn)(ctrl, sep);
 
96
                else {
 
97
--- a/inetd.8
 
98
+++ b/inetd.8
 
99
@@ -39,6 +39,7 @@
 
100
 .Nm inetd
 
101
 .Op Fl d
 
102
 .Op Fl E
 
103
+.Op Fl l
 
104
 .Op Fl R Ar rate
 
105
 .Op Ar configuration file
 
106
 .Sh DESCRIPTION
 
107
@@ -70,6 +71,13 @@ from laundering the environment.  Withou
 
108
 potentially harmful environent variables, including
 
109
 .Pa PATH ,
 
110
 will be removed and not inherited by services.
 
111
+.It Fl l
 
112
+Turns on libwrap connection logging and access control.
 
113
+Internal services cannot be wrapped.  When enabled,
 
114
+.Pa /usr/sbin/tcpd
 
115
+is silently not executed even if present in
 
116
+.Pa /etc/inetd.conf
 
117
+and instead libwrap is called directly by inetd.
 
118
 .It Fl R Ar rate
 
119
 Specify the maximum number of times a service can be invoked
 
120
 in one minute; the default is 256.
 
121
@@ -353,6 +361,23 @@ is reread.
 
122
 creates a file
 
123
 .Em /var/run/inetd.pid
 
124
 that contains its process identifier.
 
125
+.Ss libwrap
 
126
+Support for
 
127
+.Tn TCP
 
128
+wrappers is included with
 
129
+.Nm
 
130
+to provide built-in tcpd-like access control functionality.
 
131
+An external tcpd program is not needed.
 
132
+You do not need to change the
 
133
+.Pa /etc/inetd.conf
 
134
+server-program entry to enable this capability.
 
135
+.Nm
 
136
+uses
 
137
+.Pa /etc/hosts.allow
 
138
+and
 
139
+.Pa /etc/hosts.deny
 
140
+for access control facility configurations, as described in
 
141
+.Xr hosts_access 5 .
 
142
 .Ss IPv6 TCP/UDP behavior
 
143
 If you wish to run a server for IPv4 and IPv6 traffic,
 
144
 you'll need to run two separate processes for the same server program,