b5ae06
725657: net-snmp should be compiled with relro
b5ae06
b5ae06
This patch probably won't get ever upstream. It ensures that relro options [1]
b5ae06
are propagated where appropriate.
b5ae06
b5ae06
[1]: configure --with-ldflags="-Wl,-z,relro -Wl,-z,now"
b5ae06
b5ae06
diff -up net-snmp-5.7.2.pre2/apps/Makefile.in.rhel net-snmp-5.7.2.pre2/apps/Makefile.in
b5ae06
--- net-snmp-5.7.2.pre2/apps/Makefile.in.rhel	2012-07-31 14:00:04.051915227 +0200
b5ae06
+++ net-snmp-5.7.2.pre2/apps/Makefile.in	2012-07-31 14:00:05.506909768 +0200
b5ae06
@@ -204,7 +204,7 @@ snmpdf$(EXEEXT):    snmpdf.$(OSUFFIX) $(
b5ae06
 	$(LINK) ${CFLAGS} -o $@ snmpdf.$(OSUFFIX) ${LDFLAGS} ${LIBS}
b5ae06
 
b5ae06
 libnetsnmptrapd.$(LIB_EXTENSION)$(LIB_VERSION): $(LLIBTRAPD_OBJS)
b5ae06
-	$(LIB_LD_CMD) $@ ${LLIBTRAPD_OBJS} $(MIBLIB) $(USELIBS) $(PERLLDOPTS_FOR_LIBS) $(LIB_LD_LIBS)
b5ae06
+	$(LIB_LD_CMD) $@ ${LLIBTRAPD_OBJS} $(MIBLIB) $(USELIBS) $(PERLLDOPTS_FOR_LIBS) $(LIB_LD_LIBS) ${LDFLAGS}
b5ae06
 	$(RANLIB) $@
b5ae06
 
b5ae06
 snmpinforminstall:
b5ae06
diff -up net-snmp-5.7.2.pre2/perl/agent/default_store/Makefile.PL.rhel net-snmp-5.7.2.pre2/perl/agent/default_store/Makefile.PL
b5ae06
--- net-snmp-5.7.2.pre2/perl/agent/default_store/Makefile.PL.rhel	2012-07-12 04:23:25.000000000 +0200
b5ae06
+++ net-snmp-5.7.2.pre2/perl/agent/default_store/Makefile.PL	2012-07-31 14:00:08.835898341 +0200
b5ae06
@@ -69,6 +69,8 @@ sub InitMakeParams {
b5ae06
     }
b5ae06
     else {
b5ae06
 	$opts = NetSNMPGetOpts("../../");
b5ae06
+	$Params{'LDDLFLAGS'} = "$Config{lddlflags} " . `$opts->{'nsconfig'} --ldflags`;
b5ae06
+	chomp($Params{'LDDLFLAGS'});
b5ae06
 	$Params{'LIBS'}    = `$opts->{'nsconfig'} --libs`;
b5ae06
 	chomp($Params{'LIBS'});
b5ae06
 	$Params{'CCFLAGS'} = `$opts->{'nsconfig'} --cflags`;
b5ae06
diff -up net-snmp-5.7.2.pre2/python/setup.py.rhel net-snmp-5.7.2.pre2/python/setup.py
b5ae06
--- net-snmp-5.7.2.pre2/python/setup.py.rhel	2012-07-12 04:23:25.000000000 +0200
b5ae06
+++ net-snmp-5.7.2.pre2/python/setup.py	2012-07-31 14:00:07.618902228 +0200
b5ae06
@@ -18,14 +18,18 @@ if intree:
b5ae06
     netsnmp_libs = os.popen(basedir+'/net-snmp-config --libs').read()
b5ae06
     libdir = os.popen(basedir+'/net-snmp-config --build-lib-dirs '+basedir).read()
b5ae06
     incdir = os.popen(basedir+'/net-snmp-config --build-includes '+basedir).read()
b5ae06
+    ldflags = os.popen(basedir+'/net-snmp-config --ldflags').read()
b5ae06
     libs = re.findall(r"-l(\S+)", netsnmp_libs)
b5ae06
     libdirs = re.findall(r"-L(\S+)", libdir)
b5ae06
     incdirs = re.findall(r"-I(\S+)", incdir)
b5ae06
+    linkargs = ldflags.split()
b5ae06
 else:
b5ae06
     netsnmp_libs = os.popen('net-snmp-config --libs').read()
b5ae06
+    ldflags = os.popen('net-snmp-config --ldflags').read()
b5ae06
     libdirs = re.findall(r"-L(\S+)", netsnmp_libs)
b5ae06
     incdirs = []
b5ae06
     libs = re.findall(r"-l(\S+)", netsnmp_libs)
b5ae06
+    linkargs = ldflags.split()
b5ae06
 
b5ae06
 setup(
b5ae06
     name="netsnmp-python", version="1.0a1",
b5ae06
@@ -41,6 +45,7 @@ setup(
b5ae06
        Extension("netsnmp.client_intf", ["netsnmp/client_intf.c"],
b5ae06
                  library_dirs=libdirs,
b5ae06
                  include_dirs=incdirs,
b5ae06
-                 libraries=libs )
b5ae06
+                 libraries=libs,
b5ae06
+                 extra_link_args=linkargs )
b5ae06
        ]
b5ae06
     )