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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
$NetBSD: patch-bg,v 1.2 1999/09/03 21:10:54 tron Exp $
--- wwwoffled.c.orig Tue Aug 24 12:16:05 1999
+++ wwwoffled.c Wed Aug 25 10:06:03 1999
@@ -49,8 +49,8 @@
/*+ The server sockets that we listen on +*/
-int http_fd=-1, /*+ for the HTTP connections. +*/
- wwwoffle_fd=-1; /*+ for the WWWOFFLE connections. +*/
+int *http_fd_list, http_fd, /*+ for the HTTP connections. +*/
+ *wwwoffle_fd_list, wwwoffle_fd; /*+ for the WWWOFFLE connections. +*/
/*+ The online / offline /autodial status. +*/
int online=0;
@@ -154,12 +154,12 @@
if(WWWOFFLE_Gid != -1 || WWWOFFLE_Uid != -1)
PrintMessage(Inform,"Running with uid=%d, gid=%d.",getuid(),getgid());
- http_fd=OpenServerSocket(HTTP_Port);
- if(http_fd==-1)
+ http_fd_list=OpenServerSockets(HTTP_Port);
+ if(!http_fd_list)
PrintMessage(Fatal,"Cannot create HTTP server socket.");
- wwwoffle_fd=OpenServerSocket(WWWOFFLE_Port);
- if(wwwoffle_fd==-1)
+ wwwoffle_fd_list=OpenServerSockets(WWWOFFLE_Port);
+ if(!wwwoffle_fd_list)
PrintMessage(Fatal,"Cannot create WWWOFFLE server socket.");
if(stat(SpoolDir,&buf))
@@ -192,20 +192,29 @@
{
struct timeval tv;
fd_set readfd;
+ int fd, i;
int nfds;
int retval;
- if(http_fd>wwwoffle_fd)
- nfds=http_fd+1;
- else
- nfds=wwwoffle_fd+1;
+ fd = http_fd_list[1];
+ for (i = 1; i <= http_fd_list[0]; i++) {
+ if (!fd || fd < http_fd_list[i])
+ fd = http_fd_list[i];
+ }
+ for (i = 1; i <= wwwoffle_fd_list[0]; i++) {
+ if (!fd || fd < wwwoffle_fd_list[i])
+ fd = wwwoffle_fd_list[i];
+ }
+ nfds=fd+1;
FD_ZERO(&readfd);
- FD_SET(wwwoffle_fd,&readfd);
+ for (i = 1; i <= wwwoffle_fd_list[0]; i++)
+ FD_SET(wwwoffle_fd_list[i],&readfd);
if(n_servers<MaxServers)
- FD_SET(http_fd,&readfd);
+ for (i = 1; i <= http_fd_list[0]; i++)
+ FD_SET(http_fd_list[i],&readfd);
tv.tv_sec=10;
tv.tv_usec=0;
@@ -214,56 +223,62 @@
if(retval!=-1)
{
- if(FD_ISSET(wwwoffle_fd,&readfd))
- {
- char *host,*ip;
- int port,client;
-
- client=AcceptConnect(wwwoffle_fd);
- init_buffer(client);
-
- if(client>=0 && !SocketRemoteName(client,&host,&ip,&port))
- {
- if(IsAllowedConnectHost(host) || IsAllowedConnectHost(ip))
- {
- PrintMessage(Important,"WWWOFFLE Connection from host %s (%s).",host,ip); /* Used in audit-usage.pl */
-
- CommandConnect(client);
-
- if(fetch_fd!=client)
- CloseSocket(client);
- }
- else
- {
- PrintMessage(Warning,"WWWOFFLE Connection rejected from host %s (%s).",host,ip); /* Used in audit-usage.pl */
- CloseSocket(client);
- }
- }
- }
-
- if(FD_ISSET(http_fd,&readfd))
- {
- char *host,*ip;
- int port,client;
-
- client=AcceptConnect(http_fd);
- init_buffer(client);
-
- if(client>=0 && !SocketRemoteName(client,&host,&ip,&port))
- {
- if(IsAllowedConnectHost(host) || IsAllowedConnectHost(ip))
- {
- PrintMessage(Inform,"HTTP Proxy connection from host %s (%s).",host,ip); /* Used in audit-usage.pl */
- ForkServer(client,1);
- }
- else
- PrintMessage(Warning,"HTTP Proxy connection rejected from host %s (%s).",host,ip); /* Used in audit-usage.pl */
-
- CloseSocket(client);
- }
- }
+ for (i = 1; i <= wwwoffle_fd_list[0]; i++) {
+ wwwoffle_fd = wwwoffle_fd_list[i];
+ if(FD_ISSET(wwwoffle_fd,&readfd))
+ {
+ char *host,*ip;
+ int port,client;
+
+ client=AcceptConnect(wwwoffle_fd);
+ init_buffer(client);
+
+ if(client>=0 && !SocketRemoteName(client,&host,&ip,&port))
+ {
+ if(IsAllowedConnectHost(host) || IsAllowedConnectHost(ip))
+ {
+ PrintMessage(Important,"WWWOFFLE Connection from host %s (%s).",host,ip); /* Used in audit-usage.pl */
+
+ CommandConnect(client);
+
+ if(fetch_fd!=client)
+ CloseSocket(client);
+ }
+ else
+ {
+ PrintMessage(Warning,"WWWOFFLE Connection rejected from host %s (%s).",host,ip); /* Used in audit-usage.pl */
+ CloseSocket(client);
+ }
+ }
+ }
+ }
+ for (i = 1; i <= http_fd_list[0]; i++) {
+ http_fd = http_fd_list[i];
+
+ if(FD_ISSET(http_fd,&readfd))
+ {
+ char *host,*ip;
+ int port,client;
+
+ client=AcceptConnect(http_fd);
+ init_buffer(client);
+
+ if(client>=0 && !SocketRemoteName(client,&host,&ip,&port))
+ {
+ if(IsAllowedConnectHost(host) || IsAllowedConnectHost(ip))
+ {
+ PrintMessage(Inform,"HTTP Proxy connection from host %s (%s).",host,ip); /* Used in audit-usage.pl */
+ ForkServer(client,1);
+ }
+ else
+ PrintMessage(Warning,"HTTP Proxy connection rejected from host %s (%s).",host,ip); /* Used in audit-usage.pl */
+
+ CloseSocket(client);
+ }
+ }
+ }
}
-
+
if(readconfig)
{
readconfig=0;
@@ -342,9 +357,11 @@
while(!closedown);
/* Close down and exit. */
+ for (i = 1; i <= wwwoffle_fd_list[0]; i++)
+ CloseSocket(wwwoffle_fd_list[i]);
- CloseSocket(http_fd);
- CloseSocket(wwwoffle_fd);
+ for (i = 1; i <= http_fd_list[0]; i++)
+ CloseSocket(http_fd_list[i]);
if(n_servers)
PrintMessage(Important,"Exit signalled - waiting for children.");
|