1*eb8dc403SDave CobbleyUpstream-Status: Backport
2*eb8dc403SDave Cobbley
3*eb8dc403SDave Cobbleydiff -ruN tcp_wrappers_7.6.orig/Makefile tcp_wrappers_7.6/Makefile
4*eb8dc403SDave Cobbley--- tcp_wrappers_7.6.orig/Makefile	2004-05-02 15:37:59.000000000 +0200
5*eb8dc403SDave Cobbley+++ tcp_wrappers_7.6/Makefile	2004-05-02 15:31:09.000000000 +0200
6*eb8dc403SDave Cobbley@@ -150,15 +150,15 @@
7*eb8dc403SDave Cobbley
8*eb8dc403SDave Cobbley linux:
9*eb8dc403SDave Cobbley 	@make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
10*eb8dc403SDave Cobbley-	LIBS=-lnsl RANLIB=ranlib ARFLAGS=rv AUX_OBJ= \
11*eb8dc403SDave Cobbley+	LIBS=-lnsl RANLIB=ranlib ARFLAGS=rv AUX_OBJ=weak_symbols.o \
12*eb8dc403SDave Cobbley 	NETGROUP="-DNETGROUP" TLI= VSYSLOG= BUGS= \
13*eb8dc403SDave Cobbley-	EXTRA_CFLAGS="-DSYS_ERRLIST_DEFINED -DHAVE_STRERROR -DINET6=1 -Dss_family=__ss_family -Dss_len=__ss_len" all
14*eb8dc403SDave Cobbley+	EXTRA_CFLAGS="-DSYS_ERRLIST_DEFINED -DHAVE_STRERROR -DHAVE_WEAKSYMS -D_REENTRANT -DINET6=1 -Dss_family=__ss_family -Dss_len=__ss_len" all
15*eb8dc403SDave Cobbley
16*eb8dc403SDave Cobbley gnu:
17*eb8dc403SDave Cobbley 	@make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
18*eb8dc403SDave Cobbley-	LIBS=-lnsl RANLIB=ranlib ARFLAGS=rv AUX_OBJ= \
19*eb8dc403SDave Cobbley+	LIBS=-lnsl RANLIB=ranlib ARFLAGS=rv AUX_OBJ=weak_symbols.o \
20*eb8dc403SDave Cobbley 	NETGROUP=-DNETGROUP TLI= VSYSLOG= BUGS= \
21*eb8dc403SDave Cobbley-	EXTRA_CFLAGS="-DSYS_ERRLIST_DEFINED -DHAVE_STRERROR" all
22*eb8dc403SDave Cobbley+	EXTRA_CFLAGS="-DSYS_ERRLIST_DEFINED -DHAVE_STRERROR -DHAVE_WEAKSYMS -D_REENTRANT" all
23*eb8dc403SDave Cobbley
24*eb8dc403SDave Cobbley # This is good for many SYSV+BSD hybrids with NIS, probably also for HP-UX 7.x.
25*eb8dc403SDave Cobbley hpux hpux8 hpux9 hpux10:
26*eb8dc403SDave Cobbley@@ -713,7 +713,22 @@
27*eb8dc403SDave Cobbley
28*eb8dc403SDave Cobbley LIB	= libwrap.a
29*eb8dc403SDave Cobbley
30*eb8dc403SDave Cobbley-all other: config-check tcpd tcpdmatch try-from safe_finger tcpdchk
31*eb8dc403SDave Cobbley+shared/%.o: %.c
32*eb8dc403SDave Cobbley+	$(CC) $(CFLAGS) $(SHCFLAGS) -c $< -o $@
33*eb8dc403SDave Cobbley+
34*eb8dc403SDave Cobbley+SOMAJOR = 0
35*eb8dc403SDave Cobbley+SOMINOR = 7.6
36*eb8dc403SDave Cobbley+
37*eb8dc403SDave Cobbley+SHLIB		= shared/libwrap.so.$(SOMAJOR).$(SOMINOR)
38*eb8dc403SDave Cobbley+SHLIBSOMAJ	= shared/libwrap.so.$(SOMAJOR)
39*eb8dc403SDave Cobbley+SHLIBSO		= shared/libwrap.so
40*eb8dc403SDave Cobbley+SHLIBFLAGS	= -Lshared -lwrap
41*eb8dc403SDave Cobbley+
42*eb8dc403SDave Cobbley+SHLINKFLAGS = -shared -Xlinker -soname -Xlinker libwrap.so.$(SOMAJOR) -lc $(LIBS)
43*eb8dc403SDave Cobbley+SHCFLAGS = -fPIC -shared -D_REENTRANT
44*eb8dc403SDave Cobbley+SHLIB_OBJ= $(addprefix shared/, $(LIB_OBJ));
45*eb8dc403SDave Cobbley+
46*eb8dc403SDave Cobbley+all other: config-check tcpd tcpdmatch try-from safe_finger tcpdchk $(LIB)
47*eb8dc403SDave Cobbley
48*eb8dc403SDave Cobbley # Invalidate all object files when the compiler options (CFLAGS) have changed.
49*eb8dc403SDave Cobbley
50*eb8dc403SDave Cobbley@@ -731,27 +746,33 @@
51*eb8dc403SDave Cobbley 	$(AR) $(ARFLAGS) $(LIB) $(LIB_OBJ)
52*eb8dc403SDave Cobbley 	-$(RANLIB) $(LIB)
53*eb8dc403SDave Cobbley
54*eb8dc403SDave Cobbley-tcpd:	tcpd.o $(LIB)
55*eb8dc403SDave Cobbley-	$(CC) $(CFLAGS) -o $@ tcpd.o $(LIB) $(LIBS)
56*eb8dc403SDave Cobbley+$(SHLIB): $(SHLIB_OBJ)
57*eb8dc403SDave Cobbley+	rm -f $(SHLIB)
58*eb8dc403SDave Cobbley+	$(CC) -o $(SHLIB) $(SHLINKFLAGS) $(SHLIB_OBJ)
59*eb8dc403SDave Cobbley+	ln -sf $(notdir $(SHLIB)) $(SHLIBSOMAJ)
60*eb8dc403SDave Cobbley+	ln -sf $(notdir $(SHLIBSOMAJ)) $(SHLIBSO)
61*eb8dc403SDave Cobbley+
62*eb8dc403SDave Cobbley+tcpd:	tcpd.o $(SHLIB)
63*eb8dc403SDave Cobbley+	$(CC) $(CFLAGS) -o $@ tcpd.o $(SHLIBFLAGS)
64*eb8dc403SDave Cobbley
65*eb8dc403SDave Cobbley miscd:	miscd.o $(LIB)
66*eb8dc403SDave Cobbley 	$(CC) $(CFLAGS) -o $@ miscd.o $(LIB) $(LIBS)
67*eb8dc403SDave Cobbley
68*eb8dc403SDave Cobbley-safe_finger: safe_finger.o $(LIB)
69*eb8dc403SDave Cobbley-	$(CC) $(CFLAGS) -o $@ safe_finger.o $(LIB) $(LIBS)
70*eb8dc403SDave Cobbley+safe_finger: safe_finger.o $(SHLIB)
71*eb8dc403SDave Cobbley+	$(CC) $(CFLAGS) -o $@ safe_finger.o $(SHLIBFLAGS)
72*eb8dc403SDave Cobbley
73*eb8dc403SDave Cobbley TCPDMATCH_OBJ = tcpdmatch.o fakelog.o inetcf.o scaffold.o
74*eb8dc403SDave Cobbley
75*eb8dc403SDave Cobbley-tcpdmatch: $(TCPDMATCH_OBJ) $(LIB)
76*eb8dc403SDave Cobbley-	$(CC) $(CFLAGS) -o $@ $(TCPDMATCH_OBJ) $(LIB) $(LIBS)
77*eb8dc403SDave Cobbley+tcpdmatch: $(TCPDMATCH_OBJ) $(SHLIB)
78*eb8dc403SDave Cobbley+	$(CC) $(CFLAGS) -o $@ $(TCPDMATCH_OBJ) $(SHLIBFLAGS)
79*eb8dc403SDave Cobbley
80*eb8dc403SDave Cobbley-try-from: try-from.o fakelog.o $(LIB)
81*eb8dc403SDave Cobbley-	$(CC) $(CFLAGS) -o $@ try-from.o fakelog.o $(LIB) $(LIBS)
82*eb8dc403SDave Cobbley+try-from: try-from.o fakelog.o $(SHLIB)
83*eb8dc403SDave Cobbley+	$(CC) $(CFLAGS) -o $@ try-from.o fakelog.o $(SHLIBFLAGS)
84*eb8dc403SDave Cobbley
85*eb8dc403SDave Cobbley TCPDCHK_OBJ = tcpdchk.o fakelog.o inetcf.o scaffold.o
86*eb8dc403SDave Cobbley
87*eb8dc403SDave Cobbley-tcpdchk: $(TCPDCHK_OBJ) $(LIB)
88*eb8dc403SDave Cobbley-	$(CC) $(CFLAGS) -o $@ $(TCPDCHK_OBJ) $(LIB) $(LIBS)
89*eb8dc403SDave Cobbley+tcpdchk: $(TCPDCHK_OBJ) $(SHLIB)
90*eb8dc403SDave Cobbley+	$(CC) $(CFLAGS) -o $@ $(TCPDCHK_OBJ) $(SHLIBFLAGS)
91*eb8dc403SDave Cobbley
92*eb8dc403SDave Cobbley shar:	$(KIT)
93*eb8dc403SDave Cobbley 	@shar $(KIT)
94*eb8dc403SDave Cobbley@@ -767,7 +788,9 @@
95*eb8dc403SDave Cobbley
96*eb8dc403SDave Cobbley clean:
97*eb8dc403SDave Cobbley 	rm -f tcpd miscd safe_finger tcpdmatch tcpdchk try-from *.[oa] core \
98*eb8dc403SDave Cobbley+	libwrap*.so* \
99*eb8dc403SDave Cobbley 	cflags
100*eb8dc403SDave Cobbley+	rm -rf shared/
101*eb8dc403SDave Cobbley
102*eb8dc403SDave Cobbley tidy:	clean
103*eb8dc403SDave Cobbley 	chmod -R a+r .
104*eb8dc403SDave Cobbley@@ -913,5 +936,6 @@
105*eb8dc403SDave Cobbley update.o: mystdarg.h
106*eb8dc403SDave Cobbley update.o: tcpd.h
107*eb8dc403SDave Cobbley vfprintf.o: cflags
108*eb8dc403SDave Cobbley+weak_symbols.o: tcpd.h
109*eb8dc403SDave Cobbley workarounds.o: cflags
110*eb8dc403SDave Cobbley workarounds.o: tcpd.h
111*eb8dc403SDave Cobbleydiff -ruN tcp_wrappers_7.6.orig/tcpd.h tcp_wrappers_7.6/tcpd.h
112*eb8dc403SDave Cobbley--- tcp_wrappers_7.6.orig/tcpd.h	2004-05-02 15:37:59.000000000 +0200
113*eb8dc403SDave Cobbley+++ tcp_wrappers_7.6/tcpd.h	2004-05-02 15:37:49.000000000 +0200
114*eb8dc403SDave Cobbley@@ -4,6 +4,15 @@
115*eb8dc403SDave Cobbley   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
116*eb8dc403SDave Cobbley   */
117*eb8dc403SDave Cobbley
118*eb8dc403SDave Cobbley+#ifndef _TCPWRAPPERS_TCPD_H
119*eb8dc403SDave Cobbley+#define _TCPWRAPPERS_TCPD_H
120*eb8dc403SDave Cobbley+
121*eb8dc403SDave Cobbley+/* Need definitions of struct sockaddr_in and FILE. */
122*eb8dc403SDave Cobbley+#include <netinet/in.h>
123*eb8dc403SDave Cobbley+#include <stdio.h>
124*eb8dc403SDave Cobbley+
125*eb8dc403SDave Cobbley+__BEGIN_DECLS
126*eb8dc403SDave Cobbley+
127*eb8dc403SDave Cobbley /* Structure to describe one communications endpoint. */
128*eb8dc403SDave Cobbley
129*eb8dc403SDave Cobbley #define STRING_LENGTH	128		/* hosts, users, processes */
130*eb8dc403SDave Cobbley@@ -29,10 +38,10 @@
131*eb8dc403SDave Cobbley     char    pid[10];			/* access via eval_pid(request) */
132*eb8dc403SDave Cobbley     struct host_info client[1];		/* client endpoint info */
133*eb8dc403SDave Cobbley     struct host_info server[1];		/* server endpoint info */
134*eb8dc403SDave Cobbley-    void  (*sink) ();			/* datagram sink function or 0 */
135*eb8dc403SDave Cobbley-    void  (*hostname) ();		/* address to printable hostname */
136*eb8dc403SDave Cobbley-    void  (*hostaddr) ();		/* address to printable address */
137*eb8dc403SDave Cobbley-    void  (*cleanup) ();		/* cleanup function or 0 */
138*eb8dc403SDave Cobbley+    void  (*sink) (int);		/* datagram sink function or 0 */
139*eb8dc403SDave Cobbley+    void  (*hostname) (struct host_info *); /* address to printable hostname */
140*eb8dc403SDave Cobbley+    void  (*hostaddr) (struct host_info *); /* address to printable address */
141*eb8dc403SDave Cobbley+    void  (*cleanup) (struct request_info *); /* cleanup function or 0 */
142*eb8dc403SDave Cobbley     struct netconfig *config;		/* netdir handle */
143*eb8dc403SDave Cobbley };
144*eb8dc403SDave Cobbley
145*eb8dc403SDave Cobbley@@ -70,20 +79,27 @@
146*eb8dc403SDave Cobbley #define fromhost sock_host		/* no TLI support needed */
147*eb8dc403SDave Cobbley #endif
148*eb8dc403SDave Cobbley
149*eb8dc403SDave Cobbley-extern int hosts_access();		/* access control */
150*eb8dc403SDave Cobbley-extern void shell_cmd();		/* execute shell command */
151*eb8dc403SDave Cobbley-extern char *percent_x();		/* do %<char> expansion */
152*eb8dc403SDave Cobbley-extern void rfc931();			/* client name from RFC 931 daemon */
153*eb8dc403SDave Cobbley-extern void clean_exit();		/* clean up and exit */
154*eb8dc403SDave Cobbley-extern void refuse();			/* clean up and exit */
155*eb8dc403SDave Cobbley-extern char *xgets();			/* fgets() on steroids */
156*eb8dc403SDave Cobbley-extern char *split_at();		/* strchr() and split */
157*eb8dc403SDave Cobbley-extern unsigned long dot_quad_addr();	/* restricted inet_addr() */
158*eb8dc403SDave Cobbley+extern int hosts_access(struct request_info *request);	/* access control */
159*eb8dc403SDave Cobbley+extern void shell_cmd(char *);		/* execute shell command */
160*eb8dc403SDave Cobbley+extern char *percent_x(char *, int, char *, struct request_info *);
161*eb8dc403SDave Cobbley+					/* do %<char> expansion */
162*eb8dc403SDave Cobbley+extern void rfc931(struct sockaddr *, struct sockaddr *, char *);
163*eb8dc403SDave Cobbley+					/* client name from RFC 931 daemon */
164*eb8dc403SDave Cobbley+extern void clean_exit(struct request_info *);	/* clean up and exit */
165*eb8dc403SDave Cobbley+extern void refuse(struct request_info *);	/* clean up and exit */
166*eb8dc403SDave Cobbley+extern char *xgets(char *, int, FILE *);	/* fgets() on steroids */
167*eb8dc403SDave Cobbley+extern char *split_at(char *, int);		/* strchr() and split */
168*eb8dc403SDave Cobbley+extern unsigned long dot_quad_addr(char *);	/* restricted inet_addr() */
169*eb8dc403SDave Cobbley
170*eb8dc403SDave Cobbley /* Global variables. */
171*eb8dc403SDave Cobbley
172*eb8dc403SDave Cobbley+#ifdef HAVE_WEAKSYMS
173*eb8dc403SDave Cobbley+extern int allow_severity __attribute__ ((weak)); /* for connection logging */
174*eb8dc403SDave Cobbley+extern int deny_severity __attribute__ ((weak)); /* for connection logging */
175*eb8dc403SDave Cobbley+#else
176*eb8dc403SDave Cobbley extern int allow_severity;		/* for connection logging */
177*eb8dc403SDave Cobbley extern int deny_severity;		/* for connection logging */
178*eb8dc403SDave Cobbley+#endif
179*eb8dc403SDave Cobbley extern char *hosts_allow_table;		/* for verification mode redirection */
180*eb8dc403SDave Cobbley extern char *hosts_deny_table;		/* for verification mode redirection */
181*eb8dc403SDave Cobbley extern int hosts_access_verbose;	/* for verbose matching mode */
182*eb8dc403SDave Cobbley@@ -98,6 +114,8 @@
183*eb8dc403SDave Cobbley #ifdef __STDC__
184*eb8dc403SDave Cobbley extern struct request_info *request_init(struct request_info *,...);
185*eb8dc403SDave Cobbley extern struct request_info *request_set(struct request_info *,...);
186*eb8dc403SDave Cobbley+extern int hosts_ctl(char *daemon, char *client_name, char *client_addr,
187*eb8dc403SDave Cobbley+		char *client_user);
188*eb8dc403SDave Cobbley #else
189*eb8dc403SDave Cobbley extern struct request_info *request_init();	/* initialize request */
190*eb8dc403SDave Cobbley extern struct request_info *request_set();	/* update request structure */
191*eb8dc403SDave Cobbley@@ -121,20 +139,23 @@
192*eb8dc403SDave Cobbley   * host_info structures serve as caches for the lookup results.
193*eb8dc403SDave Cobbley   */
194*eb8dc403SDave Cobbley
195*eb8dc403SDave Cobbley-extern char *eval_user();		/* client user */
196*eb8dc403SDave Cobbley-extern char *eval_hostname();		/* printable hostname */
197*eb8dc403SDave Cobbley-extern char *eval_hostaddr();		/* printable host address */
198*eb8dc403SDave Cobbley-extern char *eval_hostinfo();		/* host name or address */
199*eb8dc403SDave Cobbley-extern char *eval_client();		/* whatever is available */
200*eb8dc403SDave Cobbley-extern char *eval_server();		/* whatever is available */
201*eb8dc403SDave Cobbley+extern char *eval_user(struct request_info *);	/* client user */
202*eb8dc403SDave Cobbley+extern char *eval_hostname(struct host_info *);	/* printable hostname */
203*eb8dc403SDave Cobbley+extern char *eval_hostaddr(struct host_info *);	/* printable host address */
204*eb8dc403SDave Cobbley+extern char *eval_hostinfo(struct host_info *);	/* host name or address */
205*eb8dc403SDave Cobbley+extern char *eval_client(struct request_info *);/* whatever is available */
206*eb8dc403SDave Cobbley+extern char *eval_server(struct request_info *);/* whatever is available */
207*eb8dc403SDave Cobbley #define eval_daemon(r)	((r)->daemon)	/* daemon process name */
208*eb8dc403SDave Cobbley #define eval_pid(r)	((r)->pid)	/* process id */
209*eb8dc403SDave Cobbley
210*eb8dc403SDave Cobbley /* Socket-specific methods, including DNS hostname lookups. */
211*eb8dc403SDave Cobbley
212*eb8dc403SDave Cobbley-extern void sock_host();		/* look up endpoint addresses */
213*eb8dc403SDave Cobbley-extern void sock_hostname();		/* translate address to hostname */
214*eb8dc403SDave Cobbley-extern void sock_hostaddr();		/* address to printable address */
215*eb8dc403SDave Cobbley+/* look up endpoint addresses */
216*eb8dc403SDave Cobbley+extern void sock_host(struct request_info *);
217*eb8dc403SDave Cobbley+/* translate address to hostname */
218*eb8dc403SDave Cobbley+extern void sock_hostname(struct host_info *);
219*eb8dc403SDave Cobbley+/* address to printable address */
220*eb8dc403SDave Cobbley+extern void sock_hostaddr(struct host_info *);
221*eb8dc403SDave Cobbley #define sock_methods(r) \
222*eb8dc403SDave Cobbley 	{ (r)->hostname = sock_hostname; (r)->hostaddr = sock_hostaddr; }
223*eb8dc403SDave Cobbley
224*eb8dc403SDave Cobbley@@ -182,7 +203,7 @@
225*eb8dc403SDave Cobbley   * behavior.
226*eb8dc403SDave Cobbley   */
227*eb8dc403SDave Cobbley
228*eb8dc403SDave Cobbley-extern void process_options();		/* execute options */
229*eb8dc403SDave Cobbley+extern void process_options(char *, struct request_info *);/* execute options */
230*eb8dc403SDave Cobbley extern int dry_run;			/* verification flag */
231*eb8dc403SDave Cobbley
232*eb8dc403SDave Cobbley /* Bug workarounds. */
233*eb8dc403SDave Cobbley@@ -221,3 +242,7 @@
234*eb8dc403SDave Cobbley #define strtok	my_strtok
235*eb8dc403SDave Cobbley extern char *my_strtok();
236*eb8dc403SDave Cobbley #endif
237*eb8dc403SDave Cobbley+
238*eb8dc403SDave Cobbley+__END_DECLS
239*eb8dc403SDave Cobbley+
240*eb8dc403SDave Cobbley+#endif
241*eb8dc403SDave Cobbleydiff -ruN tcp_wrappers_7.6.orig/weak_symbols.c tcp_wrappers_7.6/weak_symbols.c
242*eb8dc403SDave Cobbley--- tcp_wrappers_7.6.orig/weak_symbols.c	1970-01-01 01:00:00.000000000 +0100
243*eb8dc403SDave Cobbley+++ tcp_wrappers_7.6/weak_symbols.c	2004-05-02 15:31:09.000000000 +0200
244*eb8dc403SDave Cobbley@@ -0,0 +1,11 @@
245*eb8dc403SDave Cobbley+ /*
246*eb8dc403SDave Cobbley+  * @(#) weak_symbols.h 1.5 99/12/29 23:50
247*eb8dc403SDave Cobbley+  *
248*eb8dc403SDave Cobbley+  * Author: Anthony Towns <ajt@debian.org>
249*eb8dc403SDave Cobbley+  */
250*eb8dc403SDave Cobbley+
251*eb8dc403SDave Cobbley+#ifdef HAVE_WEAKSYMS
252*eb8dc403SDave Cobbley+#include <syslog.h>
253*eb8dc403SDave Cobbley+int deny_severity = LOG_WARNING;
254*eb8dc403SDave Cobbley+int allow_severity = SEVERITY;
255*eb8dc403SDave Cobbley+#endif
256