patches from Simon Ruderich that broaden use of hardening build flags
[debian/sudo] / debian / patches / actually-use-buildflags.diff
1 Description: Use build flags from environment (dpkg-buildflags).
2  Necessary for hardening flags.
3 Author: Simon Ruderich <simon@ruderich.org>
4 Last-Update: 2012-03-13
5
6 Index: sudo-1.8.3p2/src/Makefile.in
7 ===================================================================
8 --- sudo-1.8.3p2.orig/src/Makefile.in   2012-03-13 17:46:43.069036559 +0100
9 +++ sudo-1.8.3p2/src/Makefile.in        2012-03-13 17:47:12.949037698 +0100
10 @@ -101,7 +101,7 @@
11         $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) $(LTLDFLAGS) -o $@ sudo_noexec.lo -avoid-version -rpath $(noexecdir)
12  
13  sesh: sesh.o
14 -       $(CC) -o $@ sesh.o
15 +       $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ sesh.o
16  
17  pre-install:
18  
19 Index: sudo-1.8.3p2/compat/Makefile.in
20 ===================================================================
21 --- sudo-1.8.3p2.orig/compat/Makefile.in        2012-03-13 17:46:43.069036559 +0100
22 +++ sudo-1.8.3p2/compat/Makefile.in     2012-03-13 17:47:12.949037698 +0100
23 @@ -35,6 +35,9 @@
24  # Usually -O and/or -g
25  CFLAGS = @CFLAGS@
26  
27 +# Linker flags
28 +LDFLAGS = @LDFLAGS@
29 +
30  # OS dependent defines
31  DEFS = @OSDEFS@
32  
33 @@ -62,19 +65,19 @@
34         $(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(DEFS) $<
35  
36  libreplace.la: $(LTLIBOBJS)
37 -       $(LIBTOOL) --mode=link $(CC) -o $@ $(LTLIBOBJS) -no-install
38 +       $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(LTLIBOBJS) -no-install
39  
40  siglist.c: mksiglist
41         ./mksiglist > $@
42  
43  mksiglist: $(srcdir)/mksiglist.c $(srcdir)/mksiglist.h $(incdir)/missing.h $(top_builddir)/config.h
44 -       $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/mksiglist.c -o $@
45 +       $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(DEFS) $(srcdir)/mksiglist.c -o $@
46  
47  fnm_test: fnm_test.o libreplace.la
48 -       $(LIBTOOL) --mode=link $(CC) -o $@ fnm_test.o libreplace.la
49 +       $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ fnm_test.o libreplace.la
50  
51  globtest: globtest.o libreplace.la
52 -       $(LIBTOOL) --mode=link $(CC) -o $@ globtest.o libreplace.la
53 +       $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ globtest.o libreplace.la
54  
55  @DEV@$(srcdir)/mksiglist.h: $(srcdir)/siglist.in
56  @DEV@  awk 'BEGIN {print "/* public domain */\n"} /^    [A-Z]/ {printf("#ifdef SIG%s\n    if (my_sys_siglist[SIG%s] == NULL)\n\tmy_sys_siglist[SIG%s] = \"%s\";\n#endif\n", $$1, $$1, $$1, substr($$0, 13))}' < $(srcdir)/siglist.in > $@
57 Index: sudo-1.8.3p2/common/Makefile.in
58 ===================================================================
59 --- sudo-1.8.3p2.orig/common/Makefile.in        2012-03-13 17:46:43.013036558 +0100
60 +++ sudo-1.8.3p2/common/Makefile.in     2012-03-13 17:47:12.949037698 +0100
61 @@ -35,6 +35,9 @@
62  # Usually -O and/or -g
63  CFLAGS = @CFLAGS@
64  
65 +# Linker flags
66 +LDFLAGS = @LDFLAGS@
67 +
68  # OS dependent defines
69  DEFS = @OSDEFS@
70  
71 @@ -56,7 +59,7 @@
72         $(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(DEFS) $<
73  
74  libcommon.la: $(LTOBJS)
75 -       $(LIBTOOL) --mode=link $(CC) -o $@ $(LTOBJS) -no-install
76 +       $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(LTOBJS) -no-install
77  
78  pre-install:
79  
80 Index: sudo-1.8.3p2/plugins/sudoers/Makefile.in
81 ===================================================================
82 --- sudo-1.8.3p2.orig/plugins/sudoers/Makefile.in       2012-03-13 17:46:42.985036557 +0100
83 +++ sudo-1.8.3p2/plugins/sudoers/Makefile.in    2012-03-13 17:47:12.949037698 +0100
84 @@ -159,7 +159,7 @@
85         (cd $(top_builddir) && ./config.status --file plugins/sudoers/Makefile)
86  
87  libparsesudoers.la: $(LIBPARSESUDOERS_OBJS)
88 -       $(LIBTOOL) --mode=link $(CC) -o $@ $(LIBPARSESUDOERS_OBJS) -no-install
89 +       $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(LIBPARSESUDOERS_OBJS) -no-install
90  
91  sudoers.la: $(SUDOERS_OBJS) $(LT_LIBS) libparsesudoers.la
92         $(LIBTOOL) @LT_STATIC@ --mode=link $(CC) $(SUDOERS_LDFLAGS) $(LTLDFLAGS) -o $@ $(SUDOERS_OBJS) libparsesudoers.la $(SUDOERS_LIBS) -module -export-symbols $(srcdir)/sudoers.sym -avoid-version -rpath $(plugindir)