Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | /* |
2 | * Copyright (c) 1983,1991 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by the University of | |
16 | * California, Berkeley and its contributors. | |
17 | * 4. Neither the name of the University nor the names of its contributors | |
18 | * may be used to endorse or promote products derived from this software | |
19 | * without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | |
32 | */ | |
33 | ||
34 | #ifndef lint | |
35 | char copyright[] = | |
36 | "@(#) Copyright (c) 1983 Regents of the University of California.\n\ | |
37 | All rights reserved.\n"; | |
38 | #endif /* not lint */ | |
39 | ||
40 | #ifndef lint | |
b41acc45 | 41 | /*static char sccsid[] = "from: @(#)inetd.c 5.30 (Berkeley) 6/3/91";*/ |
159f9a1c | 42 | static char rcsid[] = "$Id: inetd.c,v 1.3 1993/10/11 21:47:50 jkh Exp $"; |
15637ed4 RG |
43 | #endif /* not lint */ |
44 | ||
45 | /* | |
46 | * Inetd - Internet super-server | |
47 | * | |
48 | * This program invokes all internet services as needed. | |
49 | * connection-oriented services are invoked each time a | |
50 | * connection is made, by creating a process. This process | |
51 | * is passed the connection as file descriptor 0 and is | |
52 | * expected to do a getpeername to find out the source host | |
53 | * and port. | |
54 | * | |
55 | * Datagram oriented services are invoked when a datagram | |
56 | * arrives; a process is created and passed a pending message | |
57 | * on file descriptor 0. Datagram servers may either connect | |
58 | * to their peer, freeing up the original socket for inetd | |
59 | * to receive further messages on, or ``take over the socket'', | |
60 | * processing all arriving datagrams and, eventually, timing | |
61 | * out. The first type of server is said to be ``multi-threaded''; | |
62 | * the second type of server ``single-threaded''. | |
63 | * | |
64 | * Inetd uses a configuration file which is read at startup | |
65 | * and, possibly, at some later time in response to a hangup signal. | |
66 | * The configuration file is ``free format'' with fields given in the | |
159f9a1c | 67 | * order shown below. Continuation lines for an entry must begin with |
15637ed4 RG |
68 | * a space or tab. All fields must be present in each entry. |
69 | * | |
70 | * service name must be in /etc/services | |
71 | * socket type stream/dgram/raw/rdm/seqpacket | |
72 | * protocol must be in /etc/protocols | |
73 | * wait/nowait single-threaded/multi-threaded | |
74 | * user user to run daemon as | |
75 | * server program full path name | |
76 | * server program arguments maximum of MAXARGS (20) | |
77 | * | |
b41acc45 C |
78 | * For RPC services |
79 | * service name/version must be in /etc/rpc | |
80 | * socket type stream/dgram/raw/rdm/seqpacket | |
81 | * protocol must be in /etc/protocols | |
82 | * wait/nowait single-threaded/multi-threaded | |
83 | * user user to run daemon as | |
84 | * server program full path name | |
85 | * server program arguments maximum of MAXARGS (20) | |
86 | * | |
15637ed4 RG |
87 | * Comment lines are indicated by a `#' in column 1. |
88 | */ | |
89 | #include <sys/param.h> | |
90 | #include <sys/stat.h> | |
91 | #include <sys/ioctl.h> | |
92 | #include <sys/socket.h> | |
93 | #include <sys/file.h> | |
94 | #include <sys/wait.h> | |
95 | #include <sys/time.h> | |
96 | #include <sys/resource.h> | |
97 | ||
98 | #include <netinet/in.h> | |
99 | #include <arpa/inet.h> | |
100 | ||
101 | #include <errno.h> | |
102 | #include <signal.h> | |
103 | #include <netdb.h> | |
104 | #include <syslog.h> | |
105 | #include <pwd.h> | |
106 | #include <stdio.h> | |
159f9a1c RG |
107 | #include <stdlib.h> |
108 | #include <unistd.h> | |
15637ed4 | 109 | #include <string.h> |
b41acc45 | 110 | #include <rpc/rpc.h> |
15637ed4 RG |
111 | #include "pathnames.h" |
112 | ||
113 | #define TOOMANY 40 /* don't start more than TOOMANY */ | |
114 | #define CNT_INTVL 60 /* servers in CNT_INTVL sec. */ | |
115 | #define RETRYTIME (60*10) /* retry after bind or server fail */ | |
116 | ||
117 | #define SIGBLOCK (sigmask(SIGCHLD)|sigmask(SIGHUP)|sigmask(SIGALRM)) | |
118 | ||
15637ed4 | 119 | int debug = 0; |
159f9a1c | 120 | int log = 0; |
15637ed4 RG |
121 | int nsock, maxsock; |
122 | fd_set allsock; | |
123 | int options; | |
124 | int timingout; | |
125 | struct servent *sp; | |
b41acc45 | 126 | struct rpcent *rpc; |
15637ed4 RG |
127 | |
128 | struct servtab { | |
129 | char *se_service; /* name of service */ | |
130 | int se_socktype; /* type of socket to use */ | |
131 | char *se_proto; /* protocol used */ | |
132 | short se_wait; /* single threaded server */ | |
133 | short se_checked; /* looked at during merge */ | |
134 | char *se_user; /* user name to run as */ | |
135 | struct biltin *se_bi; /* if built-in, description */ | |
136 | char *se_server; /* server program */ | |
137 | #define MAXARGV 20 | |
138 | char *se_argv[MAXARGV+1]; /* program arguments */ | |
139 | int se_fd; /* open descriptor */ | |
140 | struct sockaddr_in se_ctrladdr;/* bound address */ | |
b41acc45 C |
141 | int se_rpc; /* ==1 if this is an RPC service */ |
142 | int se_rpc_prog; /* RPC program number */ | |
143 | u_int se_rpc_lowvers; /* RPC low version */ | |
144 | u_int se_rpc_highvers; /* RPC high version */ | |
15637ed4 RG |
145 | int se_count; /* number started since se_time */ |
146 | struct timeval se_time; /* start of se_count */ | |
147 | struct servtab *se_next; | |
148 | } *servtab; | |
149 | ||
159f9a1c RG |
150 | /* Externals */ |
151 | ||
152 | /* should be in <rpc/rpc.h> ?? */ | |
153 | int pmap_unset(u_long prognum,u_long versnum); | |
154 | int pmap_set(u_long prognum,u_long versnum,int protocol,u_short port); | |
155 | ||
156 | /* comes from -lutil ?? */ | |
157 | void daemon(); | |
158 | ||
159 | /* Prototypes */ | |
160 | void reapchild(); | |
161 | void config(); | |
162 | void unregisterrpc(struct servtab *sep); | |
163 | void retry(); | |
164 | void setup(struct servtab *sep); | |
165 | struct servtab * enter(struct servtab *cp); | |
166 | int setconfig(); | |
167 | void endconfig(); | |
168 | struct servtab * getconfigent(); | |
169 | void freeconfig(struct servtab *cp); | |
170 | char * skip(char **cpp); | |
171 | char * nextline(FILE *fd); | |
172 | char * newstr(char *cp); | |
173 | void setproctitle(char *a, int s); | |
174 | void echo_stream(int s,struct servtab *sep); | |
175 | void echo_dg(int s,struct servtab *sep); | |
176 | void discard_stream(int s,struct servtab *sep); | |
177 | void discard_dg(int s,struct servtab *sep); | |
178 | void initring(); | |
179 | void chargen_stream(int s,struct servtab *sep); | |
180 | void chargen_dg(int s,struct servtab *sep); | |
181 | long machtime(); | |
182 | void machtime_stream(int s,struct servtab *sep); | |
183 | void machtime_dg(int s,struct servtab *sep); | |
184 | void daytime_stream(int s,struct servtab *sep); | |
185 | void daytime_dg(int s,struct servtab *sep); | |
186 | void print_service(char *action, struct servtab *sep); | |
15637ed4 RG |
187 | |
188 | struct biltin { | |
189 | char *bi_service; /* internally provided service name */ | |
190 | int bi_socktype; /* type of socket supported */ | |
191 | short bi_fork; /* 1 if should fork before call */ | |
192 | short bi_wait; /* 1 if should wait for child */ | |
159f9a1c | 193 | void (*bi_fn)(); /* function which performs it */ |
15637ed4 RG |
194 | } biltins[] = { |
195 | /* Echo received data */ | |
159f9a1c RG |
196 | { "echo", SOCK_STREAM, 1, 0, echo_stream }, |
197 | { "echo", SOCK_DGRAM, 0, 0, echo_dg }, | |
15637ed4 RG |
198 | |
199 | /* Internet /dev/null */ | |
159f9a1c RG |
200 | { "discard", SOCK_STREAM, 1, 0, discard_stream }, |
201 | { "discard", SOCK_DGRAM, 0, 0, discard_dg }, | |
15637ed4 RG |
202 | |
203 | /* Return 32 bit time since 1970 */ | |
159f9a1c RG |
204 | { "time", SOCK_STREAM, 0, 0, machtime_stream }, |
205 | { "time", SOCK_DGRAM, 0, 0, machtime_dg }, | |
15637ed4 RG |
206 | |
207 | /* Return human-readable time */ | |
159f9a1c RG |
208 | { "daytime", SOCK_STREAM, 0, 0, daytime_stream }, |
209 | { "daytime", SOCK_DGRAM, 0, 0, daytime_dg }, | |
15637ed4 RG |
210 | |
211 | /* Familiar character generator */ | |
159f9a1c RG |
212 | { "chargen", SOCK_STREAM, 1, 0, chargen_stream }, |
213 | { "chargen", SOCK_DGRAM, 0, 0, chargen_dg }, | |
214 | { 0 } | |
15637ed4 RG |
215 | }; |
216 | ||
217 | #define NUMINT (sizeof(intab) / sizeof(struct inent)) | |
218 | char *CONFIG = _PATH_INETDCONF; | |
219 | char **Argv; | |
220 | char *LastArg; | |
221 | ||
159f9a1c RG |
222 | int |
223 | main(int argc, char **argv, char **envp) | |
15637ed4 | 224 | { |
159f9a1c RG |
225 | struct servtab *sep; |
226 | struct passwd *pwd; | |
227 | int tmpint; | |
15637ed4 RG |
228 | struct sigvec sv; |
229 | int ch, pid, dofork; | |
230 | char buf[50]; | |
159f9a1c RG |
231 | struct sockaddr_in peer; |
232 | int i; | |
15637ed4 RG |
233 | |
234 | Argv = argv; | |
235 | if (envp == 0 || *envp == 0) | |
236 | envp = argv; | |
237 | while (*envp) | |
238 | envp++; | |
239 | LastArg = envp[-1] + strlen(envp[-1]); | |
240 | ||
159f9a1c | 241 | while ((ch = getopt(argc, argv, "dl")) != EOF) |
15637ed4 RG |
242 | switch(ch) { |
243 | case 'd': | |
244 | debug = 1; | |
245 | options |= SO_DEBUG; | |
246 | break; | |
159f9a1c RG |
247 | case 'l': |
248 | log = 1; | |
249 | break; | |
15637ed4 RG |
250 | case '?': |
251 | default: | |
252 | fprintf(stderr, "usage: inetd [-d]"); | |
253 | exit(1); | |
254 | } | |
255 | argc -= optind; | |
256 | argv += optind; | |
257 | ||
258 | if (argc > 0) | |
259 | CONFIG = argv[0]; | |
260 | if (debug == 0) | |
261 | daemon(0, 0); | |
262 | openlog("inetd", LOG_PID | LOG_NOWAIT, LOG_DAEMON); | |
263 | bzero((char *)&sv, sizeof(sv)); | |
264 | sv.sv_mask = SIGBLOCK; | |
265 | sv.sv_handler = retry; | |
266 | sigvec(SIGALRM, &sv, (struct sigvec *)0); | |
267 | config(); | |
268 | sv.sv_handler = config; | |
269 | sigvec(SIGHUP, &sv, (struct sigvec *)0); | |
270 | sv.sv_handler = reapchild; | |
271 | sigvec(SIGCHLD, &sv, (struct sigvec *)0); | |
272 | ||
273 | { | |
274 | /* space for daemons to overwrite environment for ps */ | |
275 | #define DUMMYSIZE 100 | |
276 | char dummy[DUMMYSIZE]; | |
277 | ||
278 | (void)memset(dummy, 'x', sizeof(DUMMYSIZE) - 1); | |
279 | dummy[DUMMYSIZE - 1] = '\0'; | |
280 | (void)setenv("inetd_dummy", dummy, 1); | |
281 | } | |
282 | ||
283 | for (;;) { | |
284 | int n, ctrl; | |
285 | fd_set readable; | |
286 | ||
287 | if (nsock == 0) { | |
288 | (void) sigblock(SIGBLOCK); | |
289 | while (nsock == 0) | |
290 | sigpause(0L); | |
291 | (void) sigsetmask(0L); | |
292 | } | |
293 | readable = allsock; | |
294 | if ((n = select(maxsock + 1, &readable, (fd_set *)0, | |
295 | (fd_set *)0, (struct timeval *)0)) <= 0) { | |
296 | if (n < 0 && errno != EINTR) | |
297 | syslog(LOG_WARNING, "select: %m\n"); | |
298 | sleep(1); | |
299 | continue; | |
300 | } | |
301 | for (sep = servtab; n && sep; sep = sep->se_next) | |
302 | if (sep->se_fd != -1 && FD_ISSET(sep->se_fd, &readable)) { | |
303 | n--; | |
304 | if (debug) | |
305 | fprintf(stderr, "someone wants %s\n", | |
306 | sep->se_service); | |
307 | if (sep->se_socktype == SOCK_STREAM) { | |
308 | ctrl = accept(sep->se_fd, (struct sockaddr *)0, | |
309 | (int *)0); | |
310 | if (debug) | |
311 | fprintf(stderr, "accept, ctrl %d\n", ctrl); | |
312 | if (ctrl < 0) { | |
313 | if (errno == EINTR) | |
314 | continue; | |
315 | syslog(LOG_WARNING, "accept (for %s): %m", | |
316 | sep->se_service); | |
317 | continue; | |
318 | } | |
159f9a1c RG |
319 | if(log) { |
320 | i = sizeof peer; | |
321 | if(getpeername(ctrl,(struct sockaddr *)&peer,&i)) { | |
322 | syslog(LOG_WARNING, | |
323 | "getpeername(for %s): %m", | |
324 | sep->se_service); | |
325 | continue; | |
326 | } | |
327 | syslog(LOG_INFO,"%s from %s", | |
328 | sep->se_service, | |
329 | inet_ntoa(peer.sin_addr)); | |
330 | ||
331 | } | |
15637ed4 RG |
332 | } else |
333 | ctrl = sep->se_fd; | |
334 | (void) sigblock(SIGBLOCK); | |
335 | pid = 0; | |
336 | dofork = (sep->se_bi == 0 || sep->se_bi->bi_fork); | |
337 | if (dofork) { | |
338 | if (sep->se_count++ == 0) | |
339 | (void)gettimeofday(&sep->se_time, | |
340 | (struct timezone *)0); | |
341 | else if (sep->se_count >= TOOMANY) { | |
342 | struct timeval now; | |
343 | ||
344 | (void)gettimeofday(&now, (struct timezone *)0); | |
345 | if (now.tv_sec - sep->se_time.tv_sec > | |
346 | CNT_INTVL) { | |
347 | sep->se_time = now; | |
348 | sep->se_count = 1; | |
349 | } else { | |
350 | syslog(LOG_ERR, | |
351 | "%s/%s server failing (looping), service terminated\n", | |
352 | sep->se_service, sep->se_proto); | |
353 | FD_CLR(sep->se_fd, &allsock); | |
354 | (void) close(sep->se_fd); | |
355 | sep->se_fd = -1; | |
356 | sep->se_count = 0; | |
357 | nsock--; | |
358 | if (!timingout) { | |
359 | timingout = 1; | |
360 | alarm(RETRYTIME); | |
361 | } | |
362 | } | |
363 | } | |
364 | pid = fork(); | |
365 | } | |
366 | if (pid < 0) { | |
367 | syslog(LOG_ERR, "fork: %m"); | |
368 | if (sep->se_socktype == SOCK_STREAM) | |
369 | close(ctrl); | |
370 | sigsetmask(0L); | |
371 | sleep(1); | |
372 | continue; | |
373 | } | |
374 | if (pid && sep->se_wait) { | |
375 | sep->se_wait = pid; | |
376 | if (sep->se_fd >= 0) { | |
377 | FD_CLR(sep->se_fd, &allsock); | |
378 | nsock--; | |
379 | } | |
380 | } | |
381 | sigsetmask(0L); | |
382 | if (pid == 0) { | |
383 | if (debug && dofork) | |
384 | setsid(); | |
385 | if (dofork) | |
386 | for (tmpint = maxsock; --tmpint > 2; ) | |
387 | if (tmpint != ctrl) | |
388 | close(tmpint); | |
389 | if (sep->se_bi) | |
390 | (*sep->se_bi->bi_fn)(ctrl, sep); | |
391 | else { | |
392 | if (debug) | |
393 | fprintf(stderr, "%d execl %s\n", | |
394 | getpid(), sep->se_server); | |
395 | dup2(ctrl, 0); | |
396 | close(ctrl); | |
397 | dup2(0, 1); | |
398 | dup2(0, 2); | |
399 | if ((pwd = getpwnam(sep->se_user)) == NULL) { | |
400 | syslog(LOG_ERR, | |
401 | "getpwnam: %s: No such user", | |
402 | sep->se_user); | |
403 | if (sep->se_socktype != SOCK_STREAM) | |
404 | recv(0, buf, sizeof (buf), 0); | |
405 | _exit(1); | |
406 | } | |
407 | if (pwd->pw_uid) { | |
408 | (void) setgid((gid_t)pwd->pw_gid); | |
409 | initgroups(pwd->pw_name, pwd->pw_gid); | |
410 | (void) setuid((uid_t)pwd->pw_uid); | |
411 | } | |
412 | execv(sep->se_server, sep->se_argv); | |
413 | if (sep->se_socktype != SOCK_STREAM) | |
414 | recv(0, buf, sizeof (buf), 0); | |
415 | syslog(LOG_ERR, "execv %s: %m", sep->se_server); | |
416 | _exit(1); | |
417 | } | |
418 | } | |
419 | if (sep->se_socktype == SOCK_STREAM) | |
420 | close(ctrl); | |
421 | } | |
422 | } | |
423 | } | |
424 | ||
425 | void | |
426 | reapchild() | |
427 | { | |
428 | int status; | |
429 | int pid; | |
159f9a1c | 430 | struct servtab *sep; |
15637ed4 RG |
431 | |
432 | for (;;) { | |
433 | pid = wait3(&status, WNOHANG, (struct rusage *)0); | |
434 | if (pid <= 0) | |
435 | break; | |
436 | if (debug) | |
437 | fprintf(stderr, "%d reaped\n", pid); | |
438 | for (sep = servtab; sep; sep = sep->se_next) | |
439 | if (sep->se_wait == pid) { | |
440 | if (status) | |
441 | syslog(LOG_WARNING, | |
442 | "%s: exit status 0x%x", | |
443 | sep->se_server, status); | |
444 | if (debug) | |
445 | fprintf(stderr, "restored %s, fd %d\n", | |
446 | sep->se_service, sep->se_fd); | |
447 | FD_SET(sep->se_fd, &allsock); | |
448 | nsock++; | |
449 | sep->se_wait = 1; | |
450 | } | |
451 | } | |
452 | } | |
453 | ||
454 | void | |
455 | config() | |
456 | { | |
159f9a1c | 457 | struct servtab *sep, *cp, **sepp; |
15637ed4 RG |
458 | long omask; |
459 | ||
460 | if (!setconfig()) { | |
461 | syslog(LOG_ERR, "%s: %m", CONFIG); | |
462 | return; | |
463 | } | |
464 | for (sep = servtab; sep; sep = sep->se_next) | |
465 | sep->se_checked = 0; | |
159f9a1c | 466 | while ((cp = getconfigent())) { |
15637ed4 RG |
467 | for (sep = servtab; sep; sep = sep->se_next) |
468 | if (strcmp(sep->se_service, cp->se_service) == 0 && | |
469 | strcmp(sep->se_proto, cp->se_proto) == 0) | |
470 | break; | |
471 | if (sep != 0) { | |
472 | int i; | |
473 | ||
474 | omask = sigblock(SIGBLOCK); | |
475 | /* | |
476 | * sep->se_wait may be holding the pid of a daemon | |
477 | * that we're waiting for. If so, don't overwrite | |
478 | * it unless the config file explicitly says don't | |
479 | * wait. | |
480 | */ | |
481 | if (cp->se_bi == 0 && | |
482 | (sep->se_wait == 1 || cp->se_wait == 0)) | |
483 | sep->se_wait = cp->se_wait; | |
484 | #define SWAP(a, b) { char *c = a; a = b; b = c; } | |
485 | if (cp->se_user) | |
486 | SWAP(sep->se_user, cp->se_user); | |
487 | if (cp->se_server) | |
488 | SWAP(sep->se_server, cp->se_server); | |
489 | for (i = 0; i < MAXARGV; i++) | |
490 | SWAP(sep->se_argv[i], cp->se_argv[i]); | |
491 | sigsetmask(omask); | |
492 | freeconfig(cp); | |
493 | if (debug) | |
494 | print_service("REDO", sep); | |
495 | } else { | |
496 | sep = enter(cp); | |
497 | if (debug) | |
498 | print_service("ADD ", sep); | |
499 | } | |
500 | sep->se_checked = 1; | |
b41acc45 C |
501 | if (!sep->se_rpc) { |
502 | sp = getservbyname(sep->se_service, sep->se_proto); | |
503 | if (sp == 0) { | |
504 | syslog(LOG_ERR, "%s/%s: unknown service", | |
505 | sep->se_service, sep->se_proto); | |
506 | if (sep->se_fd != -1) | |
507 | (void) close(sep->se_fd); | |
508 | sep->se_fd = -1; | |
509 | continue; | |
510 | } | |
511 | if (sp->s_port != sep->se_ctrladdr.sin_port) { | |
512 | sep->se_ctrladdr.sin_port = sp->s_port; | |
513 | if (sep->se_fd != -1) | |
514 | (void) close(sep->se_fd); | |
515 | sep->se_fd = -1; | |
516 | } | |
15637ed4 | 517 | } |
b41acc45 C |
518 | else { |
519 | rpc = getrpcbyname(sep->se_service); | |
520 | if (rpc == 0) { | |
521 | syslog(LOG_ERR, "%s/%s unknown RPC service.", | |
522 | sep->se_service, sep->se_proto); | |
523 | if (sep->se_fd != -1) | |
524 | (void) close(sep->se_fd); | |
525 | sep->se_fd = -1; | |
526 | continue; | |
527 | } | |
528 | if (rpc->r_number != sep->se_rpc_prog) { | |
529 | if (sep->se_rpc_prog) | |
530 | unregisterrpc(sep); | |
531 | sep->se_rpc_prog = rpc->r_number; | |
532 | if (sep->se_fd != -1) | |
533 | (void) close(sep->se_fd); | |
534 | sep->se_fd = -1; | |
535 | } | |
536 | } | |
537 | ||
15637ed4 RG |
538 | if (sep->se_fd == -1) |
539 | setup(sep); | |
540 | } | |
541 | endconfig(); | |
542 | /* | |
543 | * Purge anything not looked at above. | |
544 | */ | |
545 | omask = sigblock(SIGBLOCK); | |
546 | sepp = &servtab; | |
159f9a1c | 547 | while ((sep = *sepp)) { |
15637ed4 RG |
548 | if (sep->se_checked) { |
549 | sepp = &sep->se_next; | |
550 | continue; | |
551 | } | |
552 | *sepp = sep->se_next; | |
553 | if (sep->se_fd != -1) { | |
554 | FD_CLR(sep->se_fd, &allsock); | |
555 | nsock--; | |
556 | (void) close(sep->se_fd); | |
557 | } | |
558 | if (debug) | |
559 | print_service("FREE", sep); | |
b41acc45 C |
560 | if (sep->se_rpc && sep->se_rpc_prog > 0) |
561 | unregisterrpc(sep); | |
15637ed4 RG |
562 | freeconfig(sep); |
563 | free((char *)sep); | |
564 | } | |
565 | (void) sigsetmask(omask); | |
566 | } | |
567 | ||
b41acc45 | 568 | void |
159f9a1c | 569 | unregisterrpc(struct servtab *sep) |
b41acc45 C |
570 | { |
571 | int i; | |
572 | struct servtab *sepp; | |
573 | long omask; | |
574 | ||
575 | omask = sigblock(SIGBLOCK); | |
576 | for (sepp = servtab; sepp; sepp = sepp->se_next) { | |
577 | if (sepp == sep) | |
578 | continue; | |
579 | if (sep->se_checked == 0 || | |
580 | !sepp->se_rpc || | |
581 | sep->se_rpc_prog != sepp->se_rpc_prog) | |
582 | continue; | |
583 | return; | |
584 | } | |
585 | if (debug) | |
586 | print_service("UNREG", sep); | |
587 | for (i = sep->se_rpc_lowvers; i <= sep->se_rpc_highvers; i++) | |
588 | pmap_unset(sep->se_rpc_prog, i); | |
589 | if (sep->se_fd != -1) | |
590 | (void) close(sep->se_fd); | |
591 | sep->se_fd = -1; | |
592 | (void) sigsetmask(omask); | |
593 | } | |
594 | ||
15637ed4 RG |
595 | void |
596 | retry() | |
597 | { | |
159f9a1c | 598 | struct servtab *sep; |
15637ed4 RG |
599 | |
600 | timingout = 0; | |
601 | for (sep = servtab; sep; sep = sep->se_next) | |
602 | if (sep->se_fd == -1) | |
603 | setup(sep); | |
604 | } | |
605 | ||
159f9a1c RG |
606 | void |
607 | setup(struct servtab *sep) | |
15637ed4 RG |
608 | { |
609 | int on = 1; | |
610 | ||
611 | if ((sep->se_fd = socket(AF_INET, sep->se_socktype, 0)) < 0) { | |
612 | syslog(LOG_ERR, "%s/%s: socket: %m", | |
613 | sep->se_service, sep->se_proto); | |
614 | return; | |
615 | } | |
616 | #define turnon(fd, opt) \ | |
617 | setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on)) | |
618 | if (strcmp(sep->se_proto, "tcp") == 0 && (options & SO_DEBUG) && | |
619 | turnon(sep->se_fd, SO_DEBUG) < 0) | |
620 | syslog(LOG_ERR, "setsockopt (SO_DEBUG): %m"); | |
621 | if (turnon(sep->se_fd, SO_REUSEADDR) < 0) | |
622 | syslog(LOG_ERR, "setsockopt (SO_REUSEADDR): %m"); | |
623 | #undef turnon | |
624 | if (bind(sep->se_fd, (struct sockaddr *)&sep->se_ctrladdr, | |
625 | sizeof (sep->se_ctrladdr)) < 0) { | |
626 | syslog(LOG_ERR, "%s/%s: bind: %m", | |
627 | sep->se_service, sep->se_proto); | |
628 | (void) close(sep->se_fd); | |
629 | sep->se_fd = -1; | |
630 | if (!timingout) { | |
631 | timingout = 1; | |
632 | alarm(RETRYTIME); | |
633 | } | |
634 | return; | |
635 | } | |
b41acc45 C |
636 | if (sep->se_rpc) { |
637 | int i, len; | |
638 | if (getsockname(sep->se_fd, (struct sockaddr *)&sep->se_ctrladdr, | |
639 | &len) < 0) { | |
640 | syslog(LOG_ERR, "%s/%s: getsockname: %m", | |
641 | sep->se_service, sep->se_proto); | |
642 | (void) close(sep->se_fd); | |
643 | sep->se_fd = -1; | |
644 | return; | |
645 | } | |
646 | if (debug) | |
647 | print_service("REG ", sep); | |
648 | for (i = sep->se_rpc_lowvers; i <= sep->se_rpc_highvers; i++) { | |
649 | pmap_unset(sep->se_rpc_prog, i); | |
650 | pmap_set(sep->se_rpc_prog, i, | |
651 | (sep->se_socktype == SOCK_DGRAM) | |
652 | ? IPPROTO_UDP : IPPROTO_TCP, | |
653 | ntohs(sep->se_ctrladdr.sin_port)); | |
654 | } | |
655 | ||
656 | } | |
15637ed4 RG |
657 | if (sep->se_socktype == SOCK_STREAM) |
658 | listen(sep->se_fd, 10); | |
659 | FD_SET(sep->se_fd, &allsock); | |
660 | nsock++; | |
661 | if (sep->se_fd > maxsock) | |
662 | maxsock = sep->se_fd; | |
663 | } | |
664 | ||
665 | struct servtab * | |
159f9a1c | 666 | enter(struct servtab *cp) |
15637ed4 | 667 | { |
159f9a1c | 668 | struct servtab *sep; |
15637ed4 RG |
669 | long omask; |
670 | ||
671 | sep = (struct servtab *)malloc(sizeof (*sep)); | |
672 | if (sep == (struct servtab *)0) { | |
673 | syslog(LOG_ERR, "Out of memory."); | |
674 | exit(-1); | |
675 | } | |
676 | *sep = *cp; | |
677 | sep->se_fd = -1; | |
678 | omask = sigblock(SIGBLOCK); | |
679 | sep->se_next = servtab; | |
680 | servtab = sep; | |
681 | sigsetmask(omask); | |
682 | return (sep); | |
683 | } | |
684 | ||
685 | FILE *fconfig = NULL; | |
686 | struct servtab serv; | |
687 | char line[256]; | |
15637ed4 | 688 | |
159f9a1c | 689 | int |
15637ed4 RG |
690 | setconfig() |
691 | { | |
692 | ||
693 | if (fconfig != NULL) { | |
694 | fseek(fconfig, 0L, L_SET); | |
695 | return (1); | |
696 | } | |
697 | fconfig = fopen(CONFIG, "r"); | |
698 | return (fconfig != NULL); | |
699 | } | |
700 | ||
159f9a1c | 701 | void |
15637ed4 RG |
702 | endconfig() |
703 | { | |
704 | if (fconfig) { | |
705 | (void) fclose(fconfig); | |
706 | fconfig = NULL; | |
707 | } | |
708 | } | |
709 | ||
710 | struct servtab * | |
711 | getconfigent() | |
712 | { | |
159f9a1c | 713 | struct servtab *sep = &serv; |
15637ed4 | 714 | int argc; |
159f9a1c | 715 | char *cp, *arg; |
b41acc45 C |
716 | char *versp; |
717 | ||
15637ed4 RG |
718 | more: |
719 | while ((cp = nextline(fconfig)) && *cp == '#') | |
720 | ; | |
721 | if (cp == NULL) | |
722 | return ((struct servtab *)0); | |
868cfe61 JH |
723 | arg = skip(&cp); |
724 | if (arg == NULL) | |
725 | goto more; | |
726 | sep->se_service = newstr(arg); | |
15637ed4 RG |
727 | arg = skip(&cp); |
728 | if (strcmp(arg, "stream") == 0) | |
729 | sep->se_socktype = SOCK_STREAM; | |
730 | else if (strcmp(arg, "dgram") == 0) | |
731 | sep->se_socktype = SOCK_DGRAM; | |
732 | else if (strcmp(arg, "rdm") == 0) | |
733 | sep->se_socktype = SOCK_RDM; | |
734 | else if (strcmp(arg, "seqpacket") == 0) | |
735 | sep->se_socktype = SOCK_SEQPACKET; | |
736 | else if (strcmp(arg, "raw") == 0) | |
737 | sep->se_socktype = SOCK_RAW; | |
738 | else | |
739 | sep->se_socktype = -1; | |
740 | sep->se_proto = newstr(skip(&cp)); | |
b41acc45 C |
741 | sep->se_rpc = 0; |
742 | if (strncmp(sep->se_proto, "rpc/", 4) == 0) { | |
743 | sep->se_proto += 4; | |
744 | sep->se_rpc = 1; | |
745 | sep->se_rpc_prog = sep->se_rpc_lowvers = sep->se_rpc_lowvers = 0; | |
746 | sep->se_ctrladdr.sin_family = AF_INET; | |
747 | sep->se_ctrladdr.sin_port = 0; | |
748 | sep->se_ctrladdr.sin_addr.s_addr = htonl(INADDR_ANY); | |
159f9a1c | 749 | if ((versp = rindex(sep->se_service, '/'))) { |
b41acc45 C |
750 | *versp++ = '\0'; |
751 | switch (sscanf(versp, "%d-%d", | |
752 | &sep->se_rpc_lowvers, | |
753 | &sep->se_rpc_highvers)) { | |
754 | case 2: | |
755 | break; | |
756 | case 1: | |
757 | sep->se_rpc_highvers = | |
758 | sep->se_rpc_lowvers; | |
759 | break; | |
760 | default: | |
761 | syslog(LOG_ERR, "bad RPC version specifier; %s\n", sep->se_service); | |
762 | freeconfig(sep); | |
763 | goto more; | |
764 | } | |
765 | } | |
766 | else { | |
767 | sep->se_rpc_lowvers = | |
768 | sep->se_rpc_highvers = 1; | |
769 | } | |
770 | } | |
15637ed4 RG |
771 | arg = skip(&cp); |
772 | sep->se_wait = strcmp(arg, "wait") == 0; | |
773 | sep->se_user = newstr(skip(&cp)); | |
774 | sep->se_server = newstr(skip(&cp)); | |
775 | if (strcmp(sep->se_server, "internal") == 0) { | |
159f9a1c | 776 | struct biltin *bi; |
15637ed4 RG |
777 | |
778 | for (bi = biltins; bi->bi_service; bi++) | |
779 | if (bi->bi_socktype == sep->se_socktype && | |
780 | strcmp(bi->bi_service, sep->se_service) == 0) | |
781 | break; | |
782 | if (bi->bi_service == 0) { | |
783 | syslog(LOG_ERR, "internal service %s unknown\n", | |
784 | sep->se_service); | |
785 | goto more; | |
786 | } | |
787 | sep->se_bi = bi; | |
788 | sep->se_wait = bi->bi_wait; | |
789 | } else | |
790 | sep->se_bi = NULL; | |
791 | argc = 0; | |
792 | for (arg = skip(&cp); cp; arg = skip(&cp)) | |
793 | if (argc < MAXARGV) | |
794 | sep->se_argv[argc++] = newstr(arg); | |
795 | while (argc <= MAXARGV) | |
796 | sep->se_argv[argc++] = NULL; | |
797 | return (sep); | |
798 | } | |
799 | ||
159f9a1c RG |
800 | void |
801 | freeconfig(struct servtab *cp) | |
15637ed4 RG |
802 | { |
803 | int i; | |
804 | ||
805 | if (cp->se_service) | |
806 | free(cp->se_service); | |
807 | if (cp->se_proto) | |
808 | free(cp->se_proto); | |
809 | if (cp->se_user) | |
810 | free(cp->se_user); | |
811 | if (cp->se_server) | |
812 | free(cp->se_server); | |
813 | for (i = 0; i < MAXARGV; i++) | |
814 | if (cp->se_argv[i]) | |
815 | free(cp->se_argv[i]); | |
816 | } | |
817 | ||
818 | char * | |
159f9a1c | 819 | skip(char **cpp) |
15637ed4 | 820 | { |
159f9a1c | 821 | char *cp = *cpp; |
15637ed4 RG |
822 | char *start; |
823 | ||
824 | again: | |
825 | while (*cp == ' ' || *cp == '\t') | |
826 | cp++; | |
827 | if (*cp == '\0') { | |
828 | int c; | |
829 | ||
830 | c = getc(fconfig); | |
831 | (void) ungetc(c, fconfig); | |
832 | if (c == ' ' || c == '\t') | |
159f9a1c | 833 | if ((cp = nextline(fconfig))) |
15637ed4 RG |
834 | goto again; |
835 | *cpp = (char *)0; | |
836 | return ((char *)0); | |
837 | } | |
838 | start = cp; | |
839 | while (*cp && *cp != ' ' && *cp != '\t') | |
840 | cp++; | |
841 | if (*cp != '\0') | |
842 | *cp++ = '\0'; | |
843 | *cpp = cp; | |
844 | return (start); | |
845 | } | |
846 | ||
847 | char * | |
159f9a1c | 848 | nextline(FILE *fd) |
15637ed4 RG |
849 | { |
850 | char *cp; | |
851 | ||
852 | if (fgets(line, sizeof (line), fd) == NULL) | |
853 | return ((char *)0); | |
854 | cp = index(line, '\n'); | |
855 | if (cp) | |
856 | *cp = '\0'; | |
857 | return (line); | |
858 | } | |
859 | ||
860 | char * | |
159f9a1c | 861 | newstr(char *cp) |
15637ed4 | 862 | { |
159f9a1c | 863 | if ((cp = strdup(cp ? cp : ""))) |
15637ed4 RG |
864 | return(cp); |
865 | syslog(LOG_ERR, "strdup: %m"); | |
866 | exit(-1); | |
867 | } | |
868 | ||
159f9a1c RG |
869 | void |
870 | setproctitle(char *a, int s) | |
15637ed4 RG |
871 | { |
872 | int size; | |
159f9a1c | 873 | char *cp; |
15637ed4 RG |
874 | struct sockaddr_in sin; |
875 | char buf[80]; | |
876 | ||
877 | cp = Argv[0]; | |
878 | size = sizeof(sin); | |
879 | if (getpeername(s, (struct sockaddr *)&sin, &size) == 0) | |
880 | (void) sprintf(buf, "-%s [%s]", a, inet_ntoa(sin.sin_addr)); | |
881 | else | |
882 | (void) sprintf(buf, "-%s", a); | |
883 | strncpy(cp, buf, LastArg - cp); | |
884 | cp += strlen(cp); | |
885 | while (cp < LastArg) | |
886 | *cp++ = ' '; | |
887 | } | |
888 | ||
889 | /* | |
890 | * Internet services provided internally by inetd: | |
891 | */ | |
892 | #define BUFSIZE 8192 | |
893 | ||
894 | /* ARGSUSED */ | |
159f9a1c RG |
895 | void |
896 | echo_stream(int s,struct servtab *sep) /* Echo service -- echo data back */ | |
15637ed4 RG |
897 | { |
898 | char buffer[BUFSIZE]; | |
899 | int i; | |
900 | ||
901 | setproctitle(sep->se_service, s); | |
902 | while ((i = read(s, buffer, sizeof(buffer))) > 0 && | |
159f9a1c | 903 | write(s, buffer, i) == i) |
15637ed4 RG |
904 | ; |
905 | exit(0); | |
906 | } | |
907 | ||
908 | /* ARGSUSED */ | |
159f9a1c RG |
909 | void |
910 | echo_dg(int s,struct servtab *sep) /* Echo service -- echo data back */ | |
15637ed4 RG |
911 | { |
912 | char buffer[BUFSIZE]; | |
913 | int i, size; | |
914 | struct sockaddr sa; | |
915 | ||
916 | size = sizeof(sa); | |
917 | if ((i = recvfrom(s, buffer, sizeof(buffer), 0, &sa, &size)) < 0) | |
918 | return; | |
919 | (void) sendto(s, buffer, i, 0, &sa, sizeof(sa)); | |
920 | } | |
921 | ||
922 | /* ARGSUSED */ | |
159f9a1c RG |
923 | void |
924 | discard_stream(int s,struct servtab *sep) /* Discard service -- ignore data */ | |
15637ed4 RG |
925 | { |
926 | int ret; | |
927 | char buffer[BUFSIZE]; | |
928 | ||
929 | setproctitle(sep->se_service, s); | |
930 | while (1) { | |
931 | while ((ret = read(s, buffer, sizeof(buffer))) > 0) | |
932 | ; | |
933 | if (ret == 0 || errno != EINTR) | |
934 | break; | |
935 | } | |
936 | exit(0); | |
937 | } | |
938 | ||
939 | /* ARGSUSED */ | |
159f9a1c RG |
940 | void |
941 | discard_dg(int s,struct servtab *sep) /* Discard service -- ignore data */ | |
15637ed4 RG |
942 | { |
943 | char buffer[BUFSIZE]; | |
944 | ||
945 | (void) read(s, buffer, sizeof(buffer)); | |
946 | } | |
947 | ||
948 | #include <ctype.h> | |
949 | #define LINESIZ 72 | |
950 | char ring[128]; | |
951 | char *endring; | |
952 | ||
159f9a1c | 953 | void |
15637ed4 RG |
954 | initring() |
955 | { | |
159f9a1c | 956 | int i; |
15637ed4 RG |
957 | |
958 | endring = ring; | |
959 | ||
960 | for (i = 0; i <= 128; ++i) | |
961 | if (isprint(i)) | |
962 | *endring++ = i; | |
963 | } | |
964 | ||
965 | /* ARGSUSED */ | |
159f9a1c RG |
966 | void |
967 | chargen_stream(int s,struct servtab *sep) /* Character generator */ | |
15637ed4 | 968 | { |
159f9a1c | 969 | char *rs; |
15637ed4 RG |
970 | int len; |
971 | char text[LINESIZ+2]; | |
972 | ||
973 | setproctitle(sep->se_service, s); | |
974 | ||
975 | if (!endring) { | |
976 | initring(); | |
977 | rs = ring; | |
978 | } | |
979 | ||
980 | text[LINESIZ] = '\r'; | |
981 | text[LINESIZ + 1] = '\n'; | |
982 | for (rs = ring;;) { | |
983 | if ((len = endring - rs) >= LINESIZ) | |
984 | bcopy(rs, text, LINESIZ); | |
985 | else { | |
986 | bcopy(rs, text, len); | |
987 | bcopy(ring, text + len, LINESIZ - len); | |
988 | } | |
989 | if (++rs == endring) | |
990 | rs = ring; | |
991 | if (write(s, text, sizeof(text)) != sizeof(text)) | |
992 | break; | |
993 | } | |
994 | exit(0); | |
995 | } | |
996 | ||
997 | /* ARGSUSED */ | |
159f9a1c RG |
998 | void |
999 | chargen_dg(int s,struct servtab *sep) /* Character generator */ | |
15637ed4 RG |
1000 | { |
1001 | struct sockaddr sa; | |
1002 | static char *rs; | |
1003 | int len, size; | |
1004 | char text[LINESIZ+2]; | |
1005 | ||
1006 | if (endring == 0) { | |
1007 | initring(); | |
1008 | rs = ring; | |
1009 | } | |
1010 | ||
1011 | size = sizeof(sa); | |
1012 | if (recvfrom(s, text, sizeof(text), 0, &sa, &size) < 0) | |
1013 | return; | |
1014 | ||
1015 | if ((len = endring - rs) >= LINESIZ) | |
1016 | bcopy(rs, text, LINESIZ); | |
1017 | else { | |
1018 | bcopy(rs, text, len); | |
1019 | bcopy(ring, text + len, LINESIZ - len); | |
1020 | } | |
1021 | if (++rs == endring) | |
1022 | rs = ring; | |
1023 | text[LINESIZ] = '\r'; | |
1024 | text[LINESIZ + 1] = '\n'; | |
1025 | (void) sendto(s, text, sizeof(text), 0, &sa, sizeof(sa)); | |
1026 | } | |
1027 | ||
1028 | /* | |
1029 | * Return a machine readable date and time, in the form of the | |
1030 | * number of seconds since midnight, Jan 1, 1900. Since gettimeofday | |
1031 | * returns the number of seconds since midnight, Jan 1, 1970, | |
1032 | * we must add 2208988800 seconds to this figure to make up for | |
1033 | * some seventy years Bell Labs was asleep. | |
1034 | */ | |
1035 | ||
1036 | long | |
1037 | machtime() | |
1038 | { | |
1039 | struct timeval tv; | |
1040 | ||
1041 | if (gettimeofday(&tv, (struct timezone *)0) < 0) { | |
1042 | fprintf(stderr, "Unable to get time of day\n"); | |
1043 | return (0L); | |
1044 | } | |
159f9a1c | 1045 | return (htonl((long)tv.tv_sec + 2208988800U)); |
15637ed4 RG |
1046 | } |
1047 | ||
1048 | /* ARGSUSED */ | |
159f9a1c RG |
1049 | void |
1050 | machtime_stream(int s,struct servtab *sep) | |
15637ed4 RG |
1051 | { |
1052 | long result; | |
1053 | ||
1054 | result = machtime(); | |
1055 | (void) write(s, (char *) &result, sizeof(result)); | |
1056 | } | |
1057 | ||
1058 | /* ARGSUSED */ | |
159f9a1c RG |
1059 | void |
1060 | machtime_dg(int s,struct servtab *sep) | |
15637ed4 RG |
1061 | { |
1062 | long result; | |
1063 | struct sockaddr sa; | |
1064 | int size; | |
1065 | ||
1066 | size = sizeof(sa); | |
1067 | if (recvfrom(s, (char *)&result, sizeof(result), 0, &sa, &size) < 0) | |
1068 | return; | |
1069 | result = machtime(); | |
1070 | (void) sendto(s, (char *) &result, sizeof(result), 0, &sa, sizeof(sa)); | |
1071 | } | |
1072 | ||
1073 | /* ARGSUSED */ | |
159f9a1c RG |
1074 | void |
1075 | daytime_stream(int s,struct servtab *sep) /* Return human-readable time of day */ | |
15637ed4 RG |
1076 | { |
1077 | char buffer[256]; | |
159f9a1c | 1078 | time_t clock; |
15637ed4 RG |
1079 | |
1080 | clock = time((time_t *) 0); | |
1081 | ||
1082 | (void) sprintf(buffer, "%.24s\r\n", ctime(&clock)); | |
1083 | (void) write(s, buffer, strlen(buffer)); | |
1084 | } | |
1085 | ||
1086 | /* ARGSUSED */ | |
159f9a1c RG |
1087 | void |
1088 | daytime_dg(int s,struct servtab *sep) /* Return human-readable time of day */ | |
15637ed4 RG |
1089 | { |
1090 | char buffer[256]; | |
159f9a1c | 1091 | time_t clock; |
15637ed4 RG |
1092 | struct sockaddr sa; |
1093 | int size; | |
15637ed4 RG |
1094 | |
1095 | clock = time((time_t *) 0); | |
1096 | ||
1097 | size = sizeof(sa); | |
1098 | if (recvfrom(s, buffer, sizeof(buffer), 0, &sa, &size) < 0) | |
1099 | return; | |
1100 | (void) sprintf(buffer, "%.24s\r\n", ctime(&clock)); | |
1101 | (void) sendto(s, buffer, strlen(buffer), 0, &sa, sizeof(sa)); | |
1102 | } | |
1103 | ||
1104 | /* | |
1105 | * print_service: | |
1106 | * Dump relevant information to stderr | |
1107 | */ | |
159f9a1c RG |
1108 | void |
1109 | print_service(char *action, struct servtab *sep) | |
15637ed4 | 1110 | { |
b41acc45 C |
1111 | if (sep->se_rpc) |
1112 | fprintf(stderr, | |
1113 | "%s: %s rpcnum=%d, rpcvers=%d/%d, wait=%d, user=%s builtin=%x server=%s\n", | |
1114 | action, sep->se_service, | |
1115 | sep->se_rpc_prog, sep->se_rpc_lowvers, sep->se_rpc_highvers, | |
1116 | sep->se_wait, sep->se_user, (int)sep->se_bi, sep->se_server); | |
1117 | else | |
1118 | fprintf(stderr, | |
1119 | "%s: %s proto=%s, wait=%d, user=%s builtin=%x server=%s\n", | |
1120 | action, sep->se_service, sep->se_proto, | |
1121 | sep->se_wait, sep->se_user, (int)sep->se_bi, sep->se_server); | |
15637ed4 | 1122 | } |