3 @@ -240,6 +240,26 @@ struct request_info *request;
7 +/* hostfile_match - look up host patterns from file */
9 +static int hostfile_match(path, host)
11 +struct hosts_info *host;
17 + if ((fp = fopen(path, "r")) != 0) {
18 + while (fscanf(fp, "%s", tok) == 1 && !(match = host_match(tok, host)))
21 + } else if (errno != ENOENT) {
22 + tcpd_warn("open %s: %m", path);
27 /* host_match - match host name and/or address against pattern */
29 static int host_match(tok, host)
30 @@ -267,6 +287,8 @@ struct host_info *host;
31 tcpd_warn("netgroup support is disabled"); /* not tcpd_jump() */
34 + } else if (tok[0] == '/') { /* /file hack */
35 + return (hostfile_match(tok, host));
36 } else if (STR_EQ(tok, "KNOWN")) { /* check address and name */
37 char *name = eval_hostname(host);
38 return (STR_NE(eval_hostaddr(host), unknown) && HOSTNAME_KNOWN(name));
42 * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
45 +#ifndef _TCPWRAPPERS_TCPD_H
46 +#define _TCPWRAPPERS_TCPD_H
48 +/* someone else may have defined this */
51 +/* use prototypes if we have an ANSI C compiler or are using C++ */
52 +#if defined(__STDC__) || defined(__cplusplus)
53 +#define __P(args) args
58 +/* Need definitions of struct sockaddr_in and FILE. */
59 +#include <netinet/in.h>
66 /* Structure to describe one communications endpoint. */
68 #define STRING_LENGTH 128 /* hosts, users, processes */
69 @@ -25,10 +46,10 @@ struct request_info {
70 char pid[10]; /* access via eval_pid(request) */
71 struct host_info client[1]; /* client endpoint info */
72 struct host_info server[1]; /* server endpoint info */
73 - void (*sink) (); /* datagram sink function or 0 */
74 - void (*hostname) (); /* address to printable hostname */
75 - void (*hostaddr) (); /* address to printable address */
76 - void (*cleanup) (); /* cleanup function or 0 */
77 + void (*sink) __P((int)); /* datagram sink function or 0 */
78 + void (*hostname) __P((struct host_info *)); /* address to printable hostname */
79 + void (*hostaddr) __P((struct host_info *)); /* address to printable address */
80 + void (*cleanup) __P((struct request_info *)); /* cleanup function or 0 */
81 struct netconfig *config; /* netdir handle */
84 @@ -61,25 +82,30 @@ extern char paranoid[];
85 /* Global functions. */
87 #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
88 -extern void fromhost(); /* get/validate client host info */
89 +extern void fromhost __P((struct request_info *)); /* get/validate client host info */
91 #define fromhost sock_host /* no TLI support needed */
94 -extern int hosts_access(); /* access control */
95 -extern void shell_cmd(); /* execute shell command */
96 -extern char *percent_x(); /* do %<char> expansion */
97 -extern void rfc931(); /* client name from RFC 931 daemon */
98 -extern void clean_exit(); /* clean up and exit */
99 -extern void refuse(); /* clean up and exit */
100 -extern char *xgets(); /* fgets() on steroids */
101 -extern char *split_at(); /* strchr() and split */
102 -extern unsigned long dot_quad_addr(); /* restricted inet_addr() */
103 +extern void shell_cmd __P((char *)); /* execute shell command */
104 +extern char *percent_x __P((char *, int, char *, struct request_info *)); /* do %<char> expansion */
105 +extern void rfc931 __P((struct sockaddr_in *, struct sockaddr_in *, char *)); /* client name from RFC 931 daemon */
106 +extern void clean_exit __P((struct request_info *)); /* clean up and exit */
107 +extern void refuse __P((struct request_info *)); /* clean up and exit */
108 +extern char *xgets __P((char *, int, FILE *)); /* fgets() on steroids */
109 +extern char *split_at __P((char *, int)); /* strchr() and split */
110 +extern unsigned long dot_quad_addr __P((char *)); /* restricted inet_addr() */
112 /* Global variables. */
114 +#ifdef HAVE_WEAKSYMS
115 +extern int allow_severity __attribute__ ((weak)); /* for connection logging */
116 +extern int deny_severity __attribute__ ((weak)); /* for connection logging */
118 extern int allow_severity; /* for connection logging */
119 extern int deny_severity; /* for connection logging */
122 extern char *hosts_allow_table; /* for verification mode redirection */
123 extern char *hosts_deny_table; /* for verification mode redirection */
124 extern int hosts_access_verbose; /* for verbose matching mode */
125 @@ -92,9 +118,14 @@ extern int resident; /* > 0 if resident process */
129 +extern int hosts_access(struct request_info *request);
130 +extern int hosts_ctl(char *daemon, char *client_name, char *client_addr,
131 + char *client_user);
132 extern struct request_info *request_init(struct request_info *,...);
133 extern struct request_info *request_set(struct request_info *,...);
135 +extern int hosts_access();
136 +extern int hosts_ctl();
137 extern struct request_info *request_init(); /* initialize request */
138 extern struct request_info *request_set(); /* update request structure */
140 @@ -117,27 +148,31 @@ extern struct request_info *request_set(); /* update request structure */
141 * host_info structures serve as caches for the lookup results.
144 -extern char *eval_user(); /* client user */
145 -extern char *eval_hostname(); /* printable hostname */
146 -extern char *eval_hostaddr(); /* printable host address */
147 -extern char *eval_hostinfo(); /* host name or address */
148 -extern char *eval_client(); /* whatever is available */
149 -extern char *eval_server(); /* whatever is available */
150 +extern char *eval_user __P((struct request_info *)); /* client user */
151 +extern char *eval_hostname __P((struct host_info *)); /* printable hostname */
152 +extern char *eval_hostaddr __P((struct host_info *)); /* printable host address */
153 +extern char *eval_hostinfo __P((struct host_info *)); /* host name or address */
154 +extern char *eval_client __P((struct request_info *)); /* whatever is available */
155 +extern char *eval_server __P((struct request_info *)); /* whatever is available */
156 #define eval_daemon(r) ((r)->daemon) /* daemon process name */
157 #define eval_pid(r) ((r)->pid) /* process id */
159 /* Socket-specific methods, including DNS hostname lookups. */
161 -extern void sock_host(); /* look up endpoint addresses */
162 -extern void sock_hostname(); /* translate address to hostname */
163 -extern void sock_hostaddr(); /* address to printable address */
164 +/* look up endpoint addresses */
165 +extern void sock_host __P((struct request_info *));
166 +/* translate address to hostname */
167 +extern void sock_hostname __P((struct host_info *));
168 +/* address to printable address */
169 +extern void sock_hostaddr __P((struct host_info *));
171 #define sock_methods(r) \
172 { (r)->hostname = sock_hostname; (r)->hostaddr = sock_hostaddr; }
174 /* The System V Transport-Level Interface (TLI) interface. */
176 #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
177 -extern void tli_host(); /* look up endpoint addresses etc. */
178 +extern void tli_host __P((struct request_info *)); /* look up endpoint addresses etc. */
182 @@ -178,7 +213,7 @@ extern struct tcpd_context tcpd_context;
186 -extern void process_options(); /* execute options */
187 +extern void process_options __P((char *, struct request_info *)); /* execute options */
188 extern int dry_run; /* verification flag */
190 /* Bug workarounds. */
191 @@ -217,3 +252,9 @@ extern char *fix_strtok();
192 #define strtok my_strtok
193 extern char *my_strtok();
204 +GLIBC=$(shell grep -s -c __GLIBC__ /usr/include/features.h)
206 # @(#) Makefile 1.23 97/03/21 19:27:20
208 +# unset the HOSTNAME environment variable
213 @echo "Usage: edit the REAL_DAEMON_DIR definition in the Makefile then:"
214 @@ -19,7 +24,7 @@ what:
215 @echo " generic (most bsd-ish systems with sys5 compatibility)"
216 @echo " 386bsd aix alpha apollo bsdos convex-ultranet dell-gcc dgux dgux543"
217 @echo " dynix epix esix freebsd hpux irix4 irix5 irix6 isc iunix"
218 - @echo " linux machten mips(untested) ncrsvr4 netbsd next osf power_unix_211"
219 + @echo " linux gnu machten mips(untested) ncrsvr4 netbsd next osf power_unix_211"
220 @echo " ptx-2.x ptx-generic pyramid sco sco-nis sco-od2 sco-os5 sinix sunos4"
221 @echo " sunos40 sunos5 sysv4 tandem ultrix unicos7 unicos8 unixware1 unixware2"
223 @@ -43,8 +48,8 @@ what:
224 # Ultrix 4.x SunOS 4.x ConvexOS 10.x Dynix/ptx
225 #REAL_DAEMON_DIR=/usr/etc
227 -# SysV.4 Solaris 2.x OSF AIX
228 -#REAL_DAEMON_DIR=/usr/sbin
229 +# SysV.4 Solaris 2.x OSF AIX Linux
230 +REAL_DAEMON_DIR=/usr/sbin
233 #REAL_DAEMON_DIR=/usr/libexec
234 @@ -141,10 +146,21 @@ freebsd:
235 LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ= NETGROUP= TLI= \
236 EXTRA_CFLAGS=-DSYS_ERRLIST_DEFINED VSYSLOG= all
243 @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
244 - LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ=setenv.o \
245 - NETGROUP= TLI= EXTRA_CFLAGS="-DBROKEN_SO_LINGER" all
246 + LIBS=$(MYLIB) RANLIB=ranlib ARFLAGS=rv AUX_OBJ=weak_symbols.o \
247 + NETGROUP=-DNETGROUP TLI= VSYSLOG= BUGS= all \
248 + EXTRA_CFLAGS="-DSYS_ERRLIST_DEFINED -DHAVE_WEAKSYMS -D_REENTRANT"
251 + @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
252 + LIBS=$(MYLIB) RANLIB=ranlib ARFLAGS=rv AUX_OBJ=weak_symbols.o \
253 + NETGROUP=-DNETGROUP TLI= VSYSLOG= BUGS= all \
254 + EXTRA_CFLAGS="-DHAVE_STRERROR -DHAVE_WEAKSYMS -D_REENTRANT"
256 # This is good for many SYSV+BSD hybrids with NIS, probably also for HP-UX 7.x.
257 hpux hpux8 hpux9 hpux10:
258 @@ -391,7 +407,7 @@ AR = ar
259 # the ones provided with this source distribution. The environ.c module
260 # implements setenv(), getenv(), and putenv().
265 #AUX_OBJ= environ.o strcasecmp.o
267 @@ -454,7 +470,8 @@ AUX_OBJ= setenv.o
268 # host name aliases. Compile with -DSOLARIS_24_GETHOSTBYNAME_BUG to work
269 # around this. The workaround does no harm on other Solaris versions.
271 -BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DLIBC_CALLS_STRTOK
273 +#BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DLIBC_CALLS_STRTOK
274 #BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DINET_ADDR_BUG
275 #BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DSOLARIS_24_GETHOSTBYNAME_BUG
277 @@ -464,7 +481,7 @@ BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS
278 # If your system supports NIS or YP-style netgroups, enable the following
279 # macro definition. Netgroups are used only for host access control.
281 -#NETGROUP= -DNETGROUP
282 +NETGROUP= -DNETGROUP
284 ###############################################################
285 # System dependencies: whether or not your system has vsyslog()
286 @@ -491,7 +508,7 @@ VSYSLOG = -Dvsyslog=myvsyslog
287 # Uncomment the next definition to turn on the language extensions
288 # (examples: allow, deny, banners, twist and spawn).
290 -#STYLE = -DPROCESS_OPTIONS # Enable language extensions.
291 +STYLE = -DPROCESS_OPTIONS # Enable language extensions.
293 ################################################################
294 # Optional: Changing the default disposition of logfile records
295 @@ -514,7 +531,7 @@ VSYSLOG = -Dvsyslog=myvsyslog
297 # The LOG_XXX names below are taken from the /usr/include/syslog.h file.
299 -FACILITY= LOG_MAIL # LOG_MAIL is what most sendmail daemons use
300 +FACILITY= LOG_DAEMON # LOG_MAIL is what most sendmail daemons use
302 # The syslog priority at which successful connections are logged.
304 @@ -610,7 +627,7 @@ TABLES = -DHOSTS_DENY=\"/etc/hosts.deny\
305 # Paranoid mode implies hostname lookup. In order to disable hostname
306 # lookups altogether, see the next section.
308 -PARANOID= -DPARANOID
309 +#PARANOID= -DPARANOID
311 ########################################
312 # Optional: turning off hostname lookups
313 @@ -623,7 +640,7 @@ PARANOID= -DPARANOID
314 # In order to perform selective hostname lookups, disable paranoid
315 # mode (see previous section) and comment out the following definition.
317 -HOSTNAME= -DALWAYS_HOSTNAME
318 +#HOSTNAME= -DALWAYS_HOSTNAME
320 #############################################
321 # Optional: Turning on host ADDRESS checking
322 @@ -649,28 +666,46 @@ HOSTNAME= -DALWAYS_HOSTNAME
323 # source-routed traffic in the kernel. Examples: 4.4BSD derivatives,
324 # Solaris 2.x, and Linux. See your system documentation for details.
326 -# KILL_OPT= -DKILL_IP_OPTIONS
327 +KILL_OPT= -DKILL_IP_OPTIONS
329 ## End configuration options
330 ############################
332 # Protection against weird shells or weird make programs.
336 -.c.o:; $(CC) $(CFLAGS) -c $*.c
337 +.c.o:; $(CC) $(CFLAGS) -o $*.o -c $*.c
343 +SHLIB = shared/libwrap.so.$(SOMAJOR).$(SOMINOR)
344 +SHLIBSOMAJ= shared/libwrap.so.$(SOMAJOR)
345 +SHLIBSO = shared/libwrap.so
346 +SHLIBFLAGS = -Lshared -lwrap
348 -CFLAGS = -O -DFACILITY=$(FACILITY) $(ACCESS) $(PARANOID) $(NETGROUP) \
350 + $(CC) $(CFLAGS) $(SHCFLAGS) -c $< -o $@
352 +CFLAGS = -O2 -g -DFACILITY=$(FACILITY) $(ACCESS) $(PARANOID) $(NETGROUP) \
353 $(BUGS) $(SYSTYPE) $(AUTH) $(UMASK) \
354 -DREAL_DAEMON_DIR=\"$(REAL_DAEMON_DIR)\" $(STYLE) $(KILL_OPT) \
355 -DSEVERITY=$(SEVERITY) -DRFC931_TIMEOUT=$(RFC931_TIMEOUT) \
356 $(UCHAR) $(TABLES) $(STRINGS) $(TLI) $(EXTRA_CFLAGS) $(DOT) \
357 $(VSYSLOG) $(HOSTNAME)
359 +SHLINKFLAGS = -shared -Xlinker -soname -Xlinker libwrap.so.$(SOMAJOR) -lc $(LIBS)
360 +SHCFLAGS = -fPIC -shared -D_REENTRANT
362 LIB_OBJ= hosts_access.o options.o shell_cmd.o rfc931.o eval.o \
363 hosts_ctl.o refuse.o percent_x.o clean_exit.o $(AUX_OBJ) \
364 $(FROM_OBJ) fix_options.o socket.o tli.o workarounds.o \
365 update.o misc.o diag.o percent_m.o myvsyslog.o
367 +SHLIB_OBJ= $(addprefix shared/, $(LIB_OBJ));
371 KIT = README miscd.c tcpd.c fromhost.c hosts_access.c shell_cmd.c \
372 @@ -684,46 +719,78 @@ KIT = README miscd.c tcpd.c fromhost.c h
373 refuse.c tcpdchk.8 setenv.c inetcf.c inetcf.h scaffold.c \
374 scaffold.h tcpdmatch.8 README.NIS
378 -all other: config-check tcpd tcpdmatch try-from safe_finger tcpdchk
379 +all other: config-check tcpd tcpdmatch try-from safe_finger tcpdchk $(LIB)
381 # Invalidate all object files when the compiler options (CFLAGS) have changed.
384 @set +e; test -n "$(REAL_DAEMON_DIR)" || { make; exit 1; }
385 - @set +e; echo $(CFLAGS) >/tmp/cflags.$$$$ ; \
386 - if cmp cflags /tmp/cflags.$$$$ ; \
387 - then rm /tmp/cflags.$$$$ ; \
388 - else mv /tmp/cflags.$$$$ cflags ; \
389 + @set +e; echo $(CFLAGS) >cflags.new ; \
390 + if cmp cflags cflags.new ; \
391 + then rm cflags.new ; \
392 + else mv cflags.new cflags ; \
393 fi >/dev/null 2>/dev/null
394 + @if [ ! -d shared ]; then mkdir shared; fi
398 $(AR) $(ARFLAGS) $(LIB) $(LIB_OBJ)
402 - $(CC) $(CFLAGS) -o $@ tcpd.o $(LIB) $(LIBS)
403 +$(SHLIB): $(SHLIB_OBJ)
405 + $(CC) -o $(SHLIB) $(SHLINKFLAGS) $(SHLIB_OBJ)
406 + ln -s $(notdir $(SHLIB)) $(SHLIBSOMAJ)
407 + ln -s $(notdir $(SHLIBSOMAJ)) $(SHLIBSO)
409 +tcpd: tcpd.o $(SHLIB)
410 + $(CC) $(CFLAGS) -o $@ tcpd.o $(SHLIBFLAGS)
412 -miscd: miscd.o $(LIB)
413 - $(CC) $(CFLAGS) -o $@ miscd.o $(LIB) $(LIBS)
414 +miscd: miscd.o $(SHLIB)
415 + $(CC) $(CFLAGS) -o $@ miscd.o $(SHLIBFLAGS)
417 -safe_finger: safe_finger.o $(LIB)
418 - $(CC) $(CFLAGS) -o $@ safe_finger.o $(LIB) $(LIBS)
419 +safe_finger: safe_finger.o $(SHLIB)
420 + $(CC) $(CFLAGS) -o $@ safe_finger.o $(SHLIBFLAGS)
422 TCPDMATCH_OBJ = tcpdmatch.o fakelog.o inetcf.o scaffold.o
424 -tcpdmatch: $(TCPDMATCH_OBJ) $(LIB)
425 - $(CC) $(CFLAGS) -o $@ $(TCPDMATCH_OBJ) $(LIB) $(LIBS)
426 +tcpdmatch: $(TCPDMATCH_OBJ) $(SHLIB)
427 + $(CC) $(CFLAGS) -o $@ $(TCPDMATCH_OBJ) $(SHLIBFLAGS)
429 -try-from: try-from.o fakelog.o $(LIB)
430 - $(CC) $(CFLAGS) -o $@ try-from.o fakelog.o $(LIB) $(LIBS)
431 +try-from: try-from.o fakelog.o $(SHLIB)
432 + $(CC) $(CFLAGS) -o $@ try-from.o fakelog.o $(SHLIBFLAGS)
434 TCPDCHK_OBJ = tcpdchk.o fakelog.o inetcf.o scaffold.o
436 -tcpdchk: $(TCPDCHK_OBJ) $(LIB)
437 - $(CC) $(CFLAGS) -o $@ $(TCPDCHK_OBJ) $(LIB) $(LIBS)
438 +tcpdchk: $(TCPDCHK_OBJ) $(SHLIB)
439 + $(CC) $(CFLAGS) -o $@ $(TCPDCHK_OBJ) $(SHLIBFLAGS)
441 +install: install-lib install-bin install-dev
444 + install -o root -g root -m 0644 $(SHLIB) ${DESTDIR}/lib/
445 + ln -s $(notdir $(SHLIB)) ${DESTDIR}/lib/$(notdir $(SHLIBSOMAJ))
448 + install -o root -g root -m 0755 tcpd ${DESTDIR}/usr/sbin/
449 + install -o root -g root -m 0755 tcpdchk ${DESTDIR}/usr/sbin/
450 + install -o root -g root -m 0755 tcpdmatch ${DESTDIR}/usr/sbin/
451 + install -o root -g root -m 0755 try-from ${DESTDIR}/usr/sbin/
452 + install -o root -g root -m 0755 safe_finger ${DESTDIR}/usr/sbin/
453 + install -o root -g root -m 0644 tcpd.8 ${DESTDIR}/usr/share/man/man8/
454 + install -o root -g root -m 0644 tcpdchk.8 ${DESTDIR}/usr/share/man/man8/
455 + install -o root -g root -m 0644 tcpdmatch.8 ${DESTDIR}/usr/share/man/man8/
456 + install -o root -g root -m 0644 hosts_access.5 ${DESTDIR}/usr/share/man/man5/
457 + install -o root -g root -m 0644 hosts_options.5 ${DESTDIR}/usr/share/man/man5/
460 + ln -s /lib/$(notdir $(SHLIBSOMAJ)) ${DESTDIR}/usr/lib/$(notdir $(SHLIBSO))
461 + install -o root -g root -m 0644 hosts_access.3 ${DESTDIR}/usr/share/man/man3/
462 + install -o root -g root -m 0644 tcpd.h ${DESTDIR}/usr/include/
463 + install -o root -g root -m 0644 $(LIB) ${DESTDIR}/usr/lib/
464 + ln -s hosts_access.3 ${DESTDIR}/usr/share/man/man3/hosts_ctl.3
465 + ln -s hosts_access.3 ${DESTDIR}/usr/share/man/man3/request_init.3
466 + ln -s hosts_access.3 ${DESTDIR}/usr/share/man/man3/request_set.3
470 @@ -739,7 +806,8 @@ archive:
473 rm -f tcpd miscd safe_finger tcpdmatch tcpdchk try-from *.[oa] core \
475 + cflags libwrap*.so*
480 @@ -885,5 +953,6 @@ update.o: cflags
484 +weak_symbols.o: tcpd.h
485 workarounds.o: cflags
486 workarounds.o: tcpd.h
489 @@ -8,9 +8,9 @@ name, host name/address) patterns. Exam
490 impatient reader is encouraged to skip to the EXAMPLES section for a
493 -An extended version of the access control language is described in the
494 -\fIhosts_options\fR(5) document. The extensions are turned on at
495 -program build time by building with -DPROCESS_OPTIONS.
496 +The extended version of the access control language is described in the
497 +\fIhosts_options\fR(5) document. \fBNote that this language supersedes
498 +the meaning of \fIshell_command\fB as documented below.\fR
500 In the following text, \fIdaemon\fR is the the process name of a
501 network daemon process, and \fIclient\fR is the name and/or address of
502 @@ -40,7 +40,7 @@ A newline character is ignored when it i
503 character. This permits you to break up long lines so that they are
506 -Blank lines or lines that begin with a `#\' character are ignored.
507 +Blank lines or lines that begin with a `#' character are ignored.
508 This permits you to insert comments and whitespace so that the tables
511 @@ -69,26 +69,33 @@ checks are case insensitive.
513 The access control language implements the following patterns:
515 -A string that begins with a `.\' character. A host name is matched if
516 +A string that begins with a `.' character. A host name is matched if
517 the last components of its name match the specified pattern. For
518 -example, the pattern `.tue.nl\' matches the host name
520 +example, the pattern `.tue.nl' matches the host name
523 -A string that ends with a `.\' character. A host address is matched if
524 +A string that ends with a `.' character. A host address is matched if
525 its first numeric fields match the given string. For example, the
526 -pattern `131.155.\' matches the address of (almost) every host on the
527 +pattern `131.155.' matches the address of (almost) every host on the
528 Eind\%hoven University network (131.155.x.x).
530 -A string that begins with an `@\' character is treated as an NIS
531 +A string that begins with an `@' character is treated as an NIS
532 (formerly YP) netgroup name. A host name is matched if it is a host
533 member of the specified netgroup. Netgroup matches are not supported
534 for daemon process names or for client user names.
536 -An expression of the form `n.n.n.n/m.m.m.m\' is interpreted as a
537 -`net/mask\' pair. A host address is matched if `net\' is equal to the
538 -bitwise AND of the address and the `mask\'. For example, the net/mask
539 -pattern `131.155.72.0/255.255.254.0\' matches every address in the
540 -range `131.155.72.0\' through `131.155.73.255\'.
541 +An expression of the form `n.n.n.n/m.m.m.m' is interpreted as a
542 +`net/mask' pair. A host address is matched if `net' is equal to the
543 +bitwise AND of the address and the `mask'. For example, the net/mask
544 +pattern `131.155.72.0/255.255.254.0' matches every address in the
545 +range `131.155.72.0' through `131.155.73.255'.
547 +A string that begins with a `/' character is treated as a file
548 +name. A host name or address is matched if it matches any host name
549 +or address pattern listed in the named file. The file format is
550 +zero or more lines with zero or more host name or address patterns
551 +separated by whitespace. A file name pattern can be used anywhere
552 +a host name or address pattern can be used.
554 The access control language supports explicit wildcards:
556 @@ -115,19 +122,19 @@ without -DPARANOID when you want more co
560 -Intended use is of the form: `list_1 EXCEPT list_2\'; this construct
561 +Intended use is of the form: `list_1 EXCEPT list_2'; this construct
562 matches anything that matches \fIlist_1\fR unless it matches
563 \fIlist_2\fR. The EXCEPT operator can be used in daemon_lists and in
564 client_lists. The EXCEPT operator can be nested: if the control
565 -language would permit the use of parentheses, `a EXCEPT b EXCEPT c\'
566 -would parse as `(a EXCEPT (b EXCEPT c))\'.
567 +language would permit the use of parentheses, `a EXCEPT b EXCEPT c'
568 +would parse as `(a EXCEPT (b EXCEPT c))'.
572 If the first-matched access control rule contains a shell command, that
573 command is subjected to %<letter> substitutions (see next section).
574 The result is executed by a \fI/bin/sh\fR child process with standard
575 -input, output and error connected to \fI/dev/null\fR. Specify an `&\'
576 +input, output and error connected to \fI/dev/null\fR. Specify an `&'
577 at the end of the command if you do not want to wait until it has
580 @@ -159,7 +166,7 @@ depending on how much information is ava
582 The client user name (or "unknown").
584 -Expands to a single `%\' character.
585 +Expands to a single `%' character.
587 Characters in % expansions that may confuse the shell are replaced by
589 @@ -243,9 +250,9 @@ A positive IDENT lookup result (the clie
590 less trustworthy. It is possible for an intruder to spoof both the
591 client connection and the IDENT lookup, although doing so is much
592 harder than spoofing just a client connection. It may also be that
593 -the client\'s IDENT server is lying.
594 +the client's IDENT server is lying.
596 -Note: IDENT lookups don\'t work with UDP services.
597 +Note: IDENT lookups don't work with UDP services.
599 The language is flexible enough that different types of access control
600 policy can be expressed with a minimum of fuss. Although the language
601 @@ -285,7 +292,7 @@ ALL: LOCAL @some_netgroup
603 ALL: .foobar.edu EXCEPT terminalserver.foobar.edu
605 -The first rule permits access from hosts in the local domain (no `.\'
606 +The first rule permits access from hosts in the local domain (no `.'
607 in the host name) and from members of the \fIsome_netgroup\fP
608 netgroup. The second rule permits access from all hosts in the
609 \fIfoobar.edu\fP domain (notice the leading dot), with the exception of
610 @@ -322,8 +329,8 @@ in.tftpd: LOCAL, .my.domain
614 -in.tftpd: ALL: (/some/where/safe_finger -l @%h | \\
615 - /usr/ucb/mail -s %d-%h root) &
616 +in.tftpd: ALL: (/usr/sbin/safe_finger -l @%h | \\
617 + /usr/bin/mail -s %d-%h root) &
620 The safe_finger command comes with the tcpd wrapper and should be
621 @@ -349,7 +356,7 @@ control rule; when the length of an acce
622 capacity of an internal buffer; when an access control rule is not
623 terminated by a newline character; when the result of %<letter>
624 expansion would overflow an internal buffer; when a system call fails
625 -that shouldn\'t. All problems are reported via the syslog daemon.
626 +that shouldn't. All problems are reported via the syslog daemon.
632 @@ -33,7 +33,7 @@ static char sccsid[] = "@(#) rfc931.c 1.
634 int rfc931_timeout = RFC931_TIMEOUT;/* Global so it can be changed */
636 -static jmp_buf timebuf;
637 +static sigjmp_buf timebuf;
639 /* fsocket - open stdio stream on top of socket */
641 @@ -62,7 +62,7 @@ int protocol;
642 static void timeout(sig)
645 - longjmp(timebuf, sig);
646 + siglongjmp(timebuf, sig);
649 /* rfc931 - return remote user name, given socket structures */
650 @@ -99,7 +99,7 @@ char *dest;
651 * Set up a timer so we won't get stuck while waiting for the server.
654 - if (setjmp(timebuf) == 0) {
655 + if (sigsetjmp(timebuf,1) == 0) {
656 signal(SIGALRM, timeout);
657 alarm(rfc931_timeout);
661 @@ -94,7 +94,7 @@ configuration files.
663 The example assumes that the network daemons live in /usr/etc. On some
664 systems, network daemons live in /usr/sbin or in /usr/libexec, or have
665 -no `in.\' prefix to their name.
666 +no `in.' prefix to their name.
668 This example applies when \fItcpd\fR expects that the network daemons
669 are left in their original place.
670 @@ -110,26 +110,26 @@ finger stream tcp nowait nobody /us
674 -finger stream tcp nowait nobody /some/where/tcpd in.fingerd
675 +finger stream tcp nowait nobody /usr/sbin/tcpd in.fingerd
679 The example assumes that the network daemons live in /usr/etc. On some
680 systems, network daemons live in /usr/sbin or in /usr/libexec, the
681 -daemons have no `in.\' prefix to their name, or there is no userid
682 +daemons have no `in.' prefix to their name, or there is no userid
683 field in the inetd configuration file.
685 Similar changes will be needed for the other services that are to be
686 -covered by \fItcpd\fR. Send a `kill -HUP\' to the \fIinetd\fR(8)
687 +covered by \fItcpd\fR. Send a `kill -HUP' to the \fIinetd\fR(8)
688 process to make the changes effective. AIX users may also have to
689 -execute the `inetimp\' command.
690 +execute the `inetimp' command.
692 In the case of daemons that do not live in a common directory ("secret"
693 or otherwise), edit the \fIinetd\fR configuration file so that it
694 specifies an absolute path name for the process name field. For example:
697 - ntalk dgram udp wait root /some/where/tcpd /usr/local/lib/ntalkd
698 + ntalk dgram udp wait root /usr/sbin/tcpd /usr/sbin/in.ntalkd
705 hosts_access, hosts_ctl, request_init, request_set \- access control library
711 extern int allow_severity;
712 extern int deny_severity;
715 @@ -473,6 +473,9 @@ static struct syslog_names log_fac[] = {
723 "local0", LOG_LOCAL0,
727 @@ -35,7 +35,12 @@ struct request_info *request;
729 unsigned char optbuf[BUFFER_SIZE / 3], *cp;
730 char lbuf[BUFFER_SIZE], *lp;
731 +#if !defined(__GLIBC__)
732 int optsize = sizeof(optbuf), ipproto;
733 +#else /* __GLIBC__ */
734 + size_t optsize = sizeof(optbuf);
736 +#endif /* __GLIBC__ */
738 int fd = request->fd;
742 @@ -163,7 +163,11 @@ int *fromlen;
743 int fix_getpeername(sock, sa, len)
746 +#if !defined(__GLIBC__)
748 +#else /* __GLIBC__ */
750 +#endif /* __GLIBC__ */
753 struct sockaddr_in *sin = (struct sockaddr_in *) sa;
756 @@ -76,7 +76,11 @@ struct request_info *request;
758 static struct sockaddr_in client;
759 static struct sockaddr_in server;
760 +#if !defined (__GLIBC__)
762 +#else /* __GLIBC__ */
764 +#endif /* __GLIBC__ */
766 int fd = request->fd;
768 @@ -224,7 +228,11 @@ int fd;
771 struct sockaddr_in sin;
772 +#if !defined(__GLIBC__)
773 int size = sizeof(sin);
774 +#else /* __GLIBC__ */
775 + size_t size = sizeof(sin);
776 +#endif /* __GLIBC__ */
779 * Eat up the not-yet received datagram. Some systems insist on a
782 @@ -26,21 +26,24 @@ static char sccsid[] = "@(#) safe_finger
792 -char path[] = "PATH=/bin:/usr/bin:/usr/ucb:/usr/bsd:/etc:/usr/etc:/usr/sbin";
793 +char path[] = "PATH=/bin:/usr/bin:/sbin:/usr/sbin";
795 #define TIME_LIMIT 60 /* Do not keep listinging forever */
796 #define INPUT_LENGTH 100000 /* Do not keep listinging forever */
797 #define LINE_LENGTH 128 /* Editors can choke on long lines */
798 #define FINGER_PROGRAM "finger" /* Most, if not all, UNIX systems */
799 #define UNPRIV_NAME "nobody" /* Preferred privilege level */
800 -#define UNPRIV_UGID 32767 /* Default uid and gid */
801 +#define UNPRIV_UGID 65534 /* Default uid and gid */
804 +int allow_severity = SEVERITY;
805 +int deny_severity = LOG_WARNING;
809 --- a/hosts_options.5
810 +++ b/hosts_options.5
811 @@ -58,12 +58,12 @@ Notice the leading dot on the domain nam
812 Execute, in a child process, the specified shell command, after
813 performing the %<letter> expansions described in the hosts_access(5)
814 manual page. The command is executed with stdin, stdout and stderr
815 -connected to the null device, so that it won\'t mess up the
816 +connected to the null device, so that it won't mess up the
817 conversation with the client host. Example:
821 -spawn (/some/where/safe_finger -l @%h | /usr/ucb/mail root) &
822 +spawn (/usr/sbin/safe_finger -l @%h | /usr/bin/mail root) &
825 executes, in a background child process, the shell command "safe_finger
828 @@ -350,6 +350,8 @@ char *pat;
831 tcpd_warn("%s: daemon name begins with \"@\"", pat);
832 + } else if (pat[0] == '/') {
833 + tcpd_warn("%s: daemon name begins with \"/\"", pat);
834 } else if (pat[0] == '.') {
835 tcpd_warn("%s: daemon name begins with dot", pat);
836 } else if (pat[strlen(pat) - 1] == '.') {
837 @@ -382,6 +384,8 @@ char *pat;
839 if (pat[0] == '@') { /* @netgroup */
840 tcpd_warn("%s: user name begins with \"@\"", pat);
841 + } else if (pat[0] == '/') {
842 + tcpd_warn("%s: user name begins with \"/\"", pat);
843 } else if (pat[0] == '.') {
844 tcpd_warn("%s: user name begins with dot", pat);
845 } else if (pat[strlen(pat) - 1] == '.') {
846 @@ -402,8 +406,13 @@ char *pat;
847 static int check_host(pat)
854 + struct tcpd_context saved_context;
856 + char *wsp = " \t\r\n";
858 if (pat[0] == '@') { /* @netgroup */
860 @@ -422,6 +431,21 @@ char *pat;
861 tcpd_warn("netgroup support disabled");
864 + } else if (pat[0] == '/') { /* /path/name */
865 + if ((fp = fopen(pat, "r")) != 0) {
866 + saved_context = tcpd_context;
867 + tcpd_context.file = pat;
868 + tcpd_context.line = 0;
869 + while (fgets(buf, sizeof(buf), fp)) {
870 + tcpd_context.line++;
871 + for (cp = strtok(buf, wsp); cp; cp = strtok((char *) 0, wsp))
874 + tcpd_context = saved_context;
876 + } else if (errno != ENOENT) {
877 + tcpd_warn("open %s: %m", pat);
879 } else if (mask = split_at(pat, '/')) { /* network/netmask */
880 if (dot_quad_addr(pat) == INADDR_NONE
881 || dot_quad_addr(mask) == INADDR_NONE)
884 @@ -13,7 +13,7 @@ static char sccsid[] = "@(#) percent_m.c
888 -#ifndef SYS_ERRLIST_DEFINED
889 +#if !defined(SYS_ERRLIST_DEFINED) && !defined(HAVE_STRERROR)
890 extern char *sys_errlist[];
893 @@ -29,11 +29,15 @@ char *ibuf;
896 if (*cp == '%' && cp[1] == 'm') {
897 +#ifdef HAVE_STRERROR
898 + strcpy(bp, strerror(errno));
900 if (errno < sys_nerr && errno > 0) {
901 strcpy(bp, sys_errlist[errno]);
903 sprintf(bp, "Unknown error %d", errno);
911 @@ -180,10 +180,12 @@ struct request_info *request;
915 -void rfc931(request)
916 -struct request_info *request;
917 +void rfc931(rmt_sin, our_sin, dest)
918 +struct sockaddr_in *rmt_sin;
919 +struct sockaddr_in *our_sin;
922 - strcpy(request->user, unknown);
923 + strcpy(dest, unknown);
926 /* check_path - examine accessibility */
931 + * @(#) weak_symbols.h 1.5 99/12/29 23:50
933 + * Author: Anthony Towns <ajt@debian.org>
936 +#ifdef HAVE_WEAKSYMS
938 +int deny_severity = LOG_WARNING;
939 +int allow_severity = SEVERITY;