SHA256
3
0
forked from pool/tcpd
tcpd/tcp_wrappers_7.6-shared-lib.diff

164 lines
5.0 KiB
Diff

--- Makefile.orig
+++ Makefile
@@ -145,9 +145,9 @@ freebsd:
linux:
@make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
- LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ= \
+ LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ=weak_symbols.o \
NETGROUP=-DNETGROUP TLI= \
- EXTRA_CFLAGS="-fPIC -DSYS_ERRLIST_DEFINED -DINET6=1 -Dss_family=__ss_family" all
+ EXTRA_CFLAGS="-fPIC -DSYS_ERRLIST_DEFINED -DINET6=1 -Dss_family=__ss_family -DHAVE_WEAKSYMS -D_REENTRANT" all
# This is good for many SYSV+BSD hybrids with NIS, probably also for HP-UX 7.x.
hpux hpux8 hpux9 hpux10:
@@ -660,7 +660,18 @@ HOSTNAME= -DALWAYS_HOSTNAME
# Protection against weird shells or weird make programs.
SHELL = /bin/sh
-.c.o:; $(CC) $(CFLAGS) -c $*.c
+.c.o:; $(CC) $(CFLAGS) -o $*.o -c $*.c
+
+SOMAJOR = 0
+SOMINOR = 7.6
+LIB = libwrap.a
+SHLIB = shared/libwrap.so.$(SOMAJOR).$(SOMINOR)
+SHLIBSOMAJ = shared/libwrap.so.$(SOMAJOR)
+SHLIBSO = shared/libwrap.so
+SHLIBFLAGS = -Lshared -lwrap
+
+shared/%.o: %.c
+ $(CC) $(CFLAGS) $(SHCFLAGS) -c $< -o $@
CFLAGS = -O2 -pipe -DFACILITY=$(FACILITY) $(ACCESS) $(PARANOID) $(NETGROUP) \
$(BUGS) $(SYSTYPE) $(AUTH) $(UMASK) \
@@ -669,11 +680,16 @@ CFLAGS = -O2 -pipe -DFACILITY=$(FACILITY
$(UCHAR) $(TABLES) $(STRINGS) $(TLI) $(EXTRA_CFLAGS) $(DOT) \
$(VSYSLOG)
+SHLINKFLAGS = -shared -Xlinker -soname -Xlinker libwrap.so.$(SOMAJOR) -lc $(LIBS)
+SHCFLAGS = -fPIC -shared -D_REENTRANT
+
LIB_OBJ= hosts_access.o options.o shell_cmd.o rfc931.o eval.o \
hosts_ctl.o refuse.o percent_x.o clean_exit.o $(AUX_OBJ) \
$(FROM_OBJ) fix_options.o socket.o tli.o workarounds.o \
update.o misc.o diag.o percent_m.o myvsyslog.o ip6utils.o
+SHLIB_OBJ= $(addprefix shared/, $(LIB_OBJ));
+
FROM_OBJ= fromhost.o
KIT = README miscd.c tcpd.c fromhost.c hosts_access.c shell_cmd.c \
@@ -688,9 +704,8 @@ KIT = README miscd.c tcpd.c fromhost.c h
ip6utils.c ip6utils.h \
scaffold.h tcpdmatch.8 README.NIS
-LIB = libwrap.a
+all other: config-check tcpd tcpdmatch try-from safe_finger tcpdchk $(LIB)
-all other: config-check tcpd tcpdmatch try-from safe_finger tcpdchk
# Invalidate all object files when the compiler options (CFLAGS) have changed.
@@ -701,33 +716,40 @@ config-check:
then rm /tmp/cflags.$$$$ ; \
else mv /tmp/cflags.$$$$ cflags ; \
fi >/dev/null 2>/dev/null
+ @if [ ! -d shared ]; then mkdir shared; fi
$(LIB): $(LIB_OBJ)
rm -f $(LIB)
$(AR) $(ARFLAGS) $(LIB) $(LIB_OBJ)
-$(RANLIB) $(LIB)
-tcpd: tcpd.o $(LIB)
- $(CC) $(CFLAGS) -o $@ tcpd.o $(LIB) $(LIBS)
+$(SHLIB): $(SHLIB_OBJ)
+ rm -f $(SHLIB)
+ $(CC) -o $(SHLIB) $(SHLINKFLAGS) $(SHLIB_OBJ)
+ ln -s $(notdir $(SHLIB)) $(SHLIBSOMAJ)
+ ln -s $(notdir $(SHLIBSOMAJ)) $(SHLIBSO)
+
+tcpd: tcpd.o $(SHLIB)
+ $(CC) $(CFLAGS) -o $@ tcpd.o $(SHLIBFLAGS)
-miscd: miscd.o $(LIB)
- $(CC) $(CFLAGS) -o $@ miscd.o $(LIB) $(LIBS)
+miscd: miscd.o $(SHLIB)
+ $(CC) $(CFLAGS) -o $@ miscd.o $(SHLIBFLAGS)
-safe_finger: safe_finger.o $(LIB)
- $(CC) $(CFLAGS) -o $@ safe_finger.o $(LIB) $(LIBS)
+safe_finger: safe_finger.o $(SHLIB)
+ $(CC) $(CFLAGS) -o $@ safe_finger.o $(SHLIBFLAGS)
TCPDMATCH_OBJ = tcpdmatch.o fakelog.o inetcf.o scaffold.o
-tcpdmatch: $(TCPDMATCH_OBJ) $(LIB)
- $(CC) $(CFLAGS) -o $@ $(TCPDMATCH_OBJ) $(LIB) $(LIBS)
+tcpdmatch: $(TCPDMATCH_OBJ) $(SHLIB)
+ $(CC) $(CFLAGS) -o $@ $(TCPDMATCH_OBJ) $(SHLIBFLAGS)
-try-from: try-from.o fakelog.o $(LIB)
- $(CC) $(CFLAGS) -o $@ try-from.o fakelog.o $(LIB) $(LIBS)
+try-from: try-from.o fakelog.o $(SHLIB)
+ $(CC) $(CFLAGS) -o $@ try-from.o fakelog.o $(SHLIBFLAGS)
TCPDCHK_OBJ = tcpdchk.o fakelog.o inetcf.o scaffold.o
-tcpdchk: $(TCPDCHK_OBJ) $(LIB)
- $(CC) $(CFLAGS) -o $@ $(TCPDCHK_OBJ) $(LIB) $(LIBS)
+tcpdchk: $(TCPDCHK_OBJ) $(SHLIB)
+ $(CC) $(CFLAGS) -o $@ $(TCPDCHK_OBJ) $(SHLIBFLAGS)
shar: $(KIT)
@shar $(KIT)
@@ -743,7 +765,8 @@ archive:
clean:
rm -f tcpd miscd safe_finger tcpdmatch tcpdchk try-from *.[oa] core \
- cflags
+ cflags libwrap*.so*
+ rm -rf shared
tidy: clean
chmod -R a+r .
@@ -890,5 +913,6 @@ update.o: cflags
update.o: mystdarg.h
update.o: tcpd.h
vfprintf.o: cflags
+weak_symbols.o: tcpd.h
workarounds.o: cflags
workarounds.o: tcpd.h
--- tcpd.h.orig
+++ tcpd.h
@@ -106,8 +106,14 @@ extern unsigned long dot_quad_addr(); /*
/* Global variables. */
+#ifdef HAVE_WEAKSYMS
+extern int allow_severity __attribute__ ((weak)); /* for connection logging */
+extern int deny_severity __attribute__ ((weak)); /* for connection logging */
+#else
extern int allow_severity; /* for connection logging */
extern int deny_severity; /* for connection logging */
+#endif
+
extern char *hosts_allow_table; /* for verification mode redirection */
extern char *hosts_deny_table; /* for verification mode redirection */
extern int hosts_access_verbose; /* for verbose matching mode */
--- /dev/null
+++ weak_symbols.c
@@ -0,0 +1,11 @@
+/*
+ * @(#) weak_symbols.h 1.5 99/12/29 23:50
+ *
+ * Author: Anthony Towns <ajt@debian.org>
+ */
+
+#ifdef HAVE_WEAKSYMS
+#include <syslog.h>
+int deny_severity = LOG_WARNING;
+int allow_severity = SEVERITY;
+#endif