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