Pass ldflags through so hardening actually works

This commit is contained in:
Adam Jackson 2015-08-14 13:07:52 -04:00
parent 7294007c8a
commit 97e4cb55de
2 changed files with 44 additions and 1 deletions

36
bzip2-ldflags.patch Normal file
View File

@ -0,0 +1,36 @@
diff -up bzip2-1.0.6/Makefile.jx bzip2-1.0.6/Makefile
--- bzip2-1.0.6/Makefile.jx 2010-09-10 18:46:02.000000000 -0400
+++ bzip2-1.0.6/Makefile 2015-08-14 13:04:33.891504131 -0400
@@ -18,10 +18,6 @@ SHELL=/bin/sh
CC=gcc
AR=ar
RANLIB=ranlib
-LDFLAGS=
-
-BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
# Where you want it installed when you do 'make install'
PREFIX=/usr/local
diff -up bzip2-1.0.6/Makefile-libbz2_so.jx bzip2-1.0.6/Makefile-libbz2_so
--- bzip2-1.0.6/Makefile-libbz2_so.jx 2015-08-14 13:04:33.885503955 -0400
+++ bzip2-1.0.6/Makefile-libbz2_so 2015-08-14 13:06:52.554581179 -0400
@@ -24,7 +24,6 @@
SHELL=/bin/sh
CC=gcc
BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
OBJS= blocksort.o \
huffman.o \
@@ -35,8 +34,8 @@ OBJS= blocksort.o \
bzlib.o
all: $(OBJS)
- $(CC) $(CFLAGS) -shared -Wl,-soname -Wl,libbz2.so.1 -o libbz2.so.1.0.6 $(OBJS)
- $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.6
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname -Wl,libbz2.so.1 -o libbz2.so.1.0.6 $(OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.6
rm -f libbz2.so.1.0
ln -s libbz2.so.1.0.6 libbz2.so.1.0

View File

@ -3,7 +3,7 @@
Summary: A file compression utility Summary: A file compression utility
Name: bzip2 Name: bzip2
Version: 1.0.6 Version: 1.0.6
Release: 16%{?dist} Release: 17%{?dist}
License: BSD License: BSD
Group: Applications/File Group: Applications/File
URL: http://www.bzip.org/ URL: http://www.bzip.org/
@ -13,6 +13,7 @@ Patch0: bzip2-1.0.4-saneso.patch
Patch1: bzip2-1.0.4-cflags.patch Patch1: bzip2-1.0.4-cflags.patch
# resolves: #226979 # resolves: #226979
Patch2: bzip2-1.0.4-bzip2recover.patch Patch2: bzip2-1.0.4-bzip2recover.patch
Patch3: bzip2-ldflags.patch
%description %description
Bzip2 is a freely available, patent-free, high quality data compressor. Bzip2 is a freely available, patent-free, high quality data compressor.
@ -48,6 +49,7 @@ Libraries for applications using the bzip2 compression format.
%patch0 -p1 -b .saneso %patch0 -p1 -b .saneso
%patch1 -p1 -b .cflags %patch1 -p1 -b .cflags
%patch2 -p1 -b .bz2recover %patch2 -p1 -b .bz2recover
%patch3 -p1 -b .ldflags
%build %build
%if 0%{?rhel} >= 7 %if 0%{?rhel} >= 7
@ -62,11 +64,13 @@ Libraries for applications using the bzip2 compression format.
make -f Makefile-libbz2_so CC="%{__cc}" AR="%{__ar}" RANLIB="%{__ranlib}" \ make -f Makefile-libbz2_so CC="%{__cc}" AR="%{__ar}" RANLIB="%{__ranlib}" \
CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64 -fpic -fPIC $O3" \ CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64 -fpic -fPIC $O3" \
LDFLAGS="%{__global_ldflags}" \
%{?_smp_mflags} all %{?_smp_mflags} all
rm -f *.o rm -f *.o
make CC="%{__cc}" AR="%{__ar}" RANLIB="%{__ranlib}" \ make CC="%{__cc}" AR="%{__ar}" RANLIB="%{__ranlib}" \
CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64 $O3" \ CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64 $O3" \
LDFLAGS="%{__global_ldflags}" \
%{?_smp_mflags} all %{?_smp_mflags} all
%install %install
@ -115,6 +119,9 @@ ln -s bzgrep.1 $RPM_BUILD_ROOT%{_mandir}/man1/bzfgrep.1
%{_libdir}/*.so %{_libdir}/*.so
%changelog %changelog
* Fri Aug 14 2015 Adam Jackson <ajax@redhat.com> 1.0.6-17
- Pass ldflags through so hardening actually works
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.6-16 * Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.6-16
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild