summaryrefslogtreecommitdiffstats
path: root/package/sudo/0004-Actually-link-the-test-program-when-checking-for-stack-protector.patch
blob: 87dc29be4972ca03444be8ecfcaa2beff7304670 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
When checking for stack protector support we need to actually link the
test program.

Backported from upstream:
  http://www.sudo.ws/repos/sudo/rev/ab4f94aac7de

Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>

# HG changeset patch
# User Todd C. Miller <Todd.Miller@courtesan.com>
# Date 1446216562 21600
# Node ID ab4f94aac7de73efa1b201890354c74126baf7ca
# Parent  e6bc59225c06c5d45580197519a73e3feea14cbd
When checking for stack protector support we need to actually link
the test program.

diff -r e6bc59225c06 -r ab4f94aac7de configure
--- a/configure	Thu Oct 29 14:06:21 2015 -0600
+++ b/configure	Fri Oct 30 08:49:22 2015 -0600
@@ -23922,11 +23922,17 @@
   $as_echo_n "(cached) " >&6
 else
 
-	    sudo_cv_var_stack_protector=no
+	    # Avoid using CFLAGS since the compiler might optimize away our
+	    # test.  We don't want LIBS to interfere with the test but keep
+	    # LDFLAGS as it may have an rpath needed to find the ssp lib.
 	    _CFLAGS="$CFLAGS"
 	    _LDFLAGS="$LDFLAGS"
-	    CFLAGS="-fstack-protector-strong"
-	    LDFLAGS="$_LDFLAGS -fstack-protector-strong"
+	    _LIBS="$LIBS"
+	    LIBS=
+
+	    sudo_cv_var_stack_protector="-fstack-protector-strong"
+	    CFLAGS="$sudo_cv_var_stack_protector"
+	    LDFLAGS="$_LDFLAGS $sudo_cv_var_stack_protector"
 	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -23940,14 +23946,13 @@
 }
 
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-		sudo_cv_var_stack_protector="-fstack-protector-strong"
-
-else
-
-		CFLAGS="-fstack-protector-all"
-		LDFLAGS="$_LDFLAGS -fstack-protector-all"
+if ac_fn_c_try_link "$LINENO"; then :
+
+else
+
+		sudo_cv_var_stack_protector="-fstack-protector-all"
+		CFLAGS="$sudo_cv_var_stack_protector"
+		LDFLAGS="$_LDFLAGS $sudo_cv_var_stack_protector"
 		cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -23961,14 +23966,13 @@
 }
 
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-		    sudo_cv_var_stack_protector="-fstack-protector-all"
-
-else
-
-		    CFLAGS="-fstack-protector"
-		    LDFLAGS="$_LDFLAGS -fstack-protector"
+if ac_fn_c_try_link "$LINENO"; then :
+
+else
+
+		    sudo_cv_var_stack_protector="-fstack-protector"
+		    CFLAGS="$sudo_cv_var_stack_protector"
+		    LDFLAGS="$_LDFLAGS $sudo_cv_var_stack_protector"
 		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -23982,20 +23986,26 @@
 }
 
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-			sudo_cv_var_stack_protector="-fstack-protector"
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+if ac_fn_c_try_link "$LINENO"; then :
+
+else
+
+			sudo_cv_var_stack_protector=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
 	    CFLAGS="$_CFLAGS"
 	    LDFLAGS="$_LDFLAGS"
+	    LIBS="$_LIBS"
 
 
 fi
diff -r e6bc59225c06 -r ab4f94aac7de configure.ac
--- a/configure.ac	Thu Oct 29 14:06:21 2015 -0600
+++ b/configure.ac	Fri Oct 30 08:49:22 2015 -0600
@@ -3981,37 +3981,42 @@
     AC_CACHE_CHECK([for compiler stack protector support],
 	[sudo_cv_var_stack_protector],
 	[
-	    sudo_cv_var_stack_protector=no
+	    # Avoid using CFLAGS since the compiler might optimize away our
+	    # test.  We don't want LIBS to interfere with the test but keep
+	    # LDFLAGS as it may have an rpath needed to find the ssp lib.
 	    _CFLAGS="$CFLAGS"
 	    _LDFLAGS="$LDFLAGS"
-	    CFLAGS="-fstack-protector-strong"
-	    LDFLAGS="$_LDFLAGS -fstack-protector-strong"
-	    AC_COMPILE_IFELSE([
+	    _LIBS="$LIBS"
+	    LIBS=
+
+	    sudo_cv_var_stack_protector="-fstack-protector-strong"
+	    CFLAGS="$sudo_cv_var_stack_protector"
+	    LDFLAGS="$_LDFLAGS $sudo_cv_var_stack_protector"
+	    AC_LINK_IFELSE([
 		AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
 		[[char buf[1024]; buf[1023] = '\0';]])
-	    ], [
-		sudo_cv_var_stack_protector="-fstack-protector-strong"
-	    ], [
-		CFLAGS="-fstack-protector-all"
-		LDFLAGS="$_LDFLAGS -fstack-protector-all"
-		AC_COMPILE_IFELSE([
+	    ], [], [
+		sudo_cv_var_stack_protector="-fstack-protector-all"
+		CFLAGS="$sudo_cv_var_stack_protector"
+		LDFLAGS="$_LDFLAGS $sudo_cv_var_stack_protector"
+		AC_LINK_IFELSE([
 		    AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
 		    [[char buf[1024]; buf[1023] = '\0';]])
-		], [
-		    sudo_cv_var_stack_protector="-fstack-protector-all"
-		], [
-		    CFLAGS="-fstack-protector"
-		    LDFLAGS="$_LDFLAGS -fstack-protector"
-		    AC_COMPILE_IFELSE([
+		], [], [
+		    sudo_cv_var_stack_protector="-fstack-protector"
+		    CFLAGS="$sudo_cv_var_stack_protector"
+		    LDFLAGS="$_LDFLAGS $sudo_cv_var_stack_protector"
+		    AC_LINK_IFELSE([
 			AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
 			[[char buf[1024]; buf[1023] = '\0';]])
-		    ], [
-			sudo_cv_var_stack_protector="-fstack-protector"
-		    ], [])
+		    ], [], [
+			sudo_cv_var_stack_protector=no
+		    ])
 		])
 	    ])
 	    CFLAGS="$_CFLAGS"
 	    LDFLAGS="$_LDFLAGS"
+	    LIBS="$_LIBS"
 	]
     )
     if test X"$sudo_cv_var_stack_protector" != X"no"; then

OpenPOWER on IntegriCloud