chiark / gitweb /
build-sys: enable a couple of security features
authorLennart Poettering <lennart@poettering.net>
Wed, 8 Aug 2012 10:03:34 +0000 (12:03 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 8 Aug 2012 10:03:34 +0000 (12:03 +0200)
Most distributions enable these downstream anyway, but it probably makes
sense to enable them unconditionally upstream too.

Makefile.am
autogen.sh
configure.ac

index b1a8cc19902cfeffaa92ca653400defe901bfe85..696372246053a5ced9ba78ca5ac049132ffdc863 100644 (file)
@@ -148,10 +148,11 @@ AM_CPPFLAGS = \
        -I $(top_builddir)/src/core \
        -I $(top_srcdir)/src/core \
        -I $(top_srcdir)/src/libudev \
        -I $(top_builddir)/src/core \
        -I $(top_srcdir)/src/core \
        -I $(top_srcdir)/src/libudev \
-       -I $(top_srcdir)/src/udev
+       -I $(top_srcdir)/src/udev \
+       $(OUR_CPPFLAGS)
 
 
-AM_CFLAGS = $(WARNINGFLAGS)
-AM_LDFLAGS = $(GCLDFLAGS)
+AM_CFLAGS = $(OUR_GFLAGS)
+AM_LDFLAGS = $(OUR_LDFLAGS)
 
 # ------------------------------------------------------------------------------
 if TARGET_GENTOO
 
 # ------------------------------------------------------------------------------
 if TARGET_GENTOO
index 33d8fcda2342ad7cb91deba510f6fd24b54f4a26..86fe9b3785a27453e4808ed861aeff82a970005b 100755 (executable)
@@ -54,7 +54,7 @@ args="$args \
 fi
 
 if [ "x$1" = "xc" ]; then
 fi
 
 if [ "x$1" = "xc" ]; then
-        ./configure CFLAGS='-g -O0 -Wp,-U_FORTIFY_SOURCE' $args
+        ./configure CFLAGS='-g -O0' $args
         make clean
 else
         echo
         make clean
 else
         echo
@@ -62,6 +62,6 @@ else
         echo "Initialized build system. For a common configuration please run:"
         echo "----------------------------------------------------------------"
         echo
         echo "Initialized build system. For a common configuration please run:"
         echo "----------------------------------------------------------------"
         echo
-        echo "./configure CFLAGS='-g -O0 -Wp,-U_FORTIFY_SOURCE' $args"
+        echo "./configure CFLAGS='-g -O0' $args"
         echo
 fi
         echo
 fi
index 51452982045bf047a802d0cc0401a57b0f377fb1..d6a158396f6a11c350d37f753a21c327ae808828 100644 (file)
@@ -117,20 +117,26 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
         -Wno-missing-field-initializers \
         -Wno-unused-result \
         -Werror=overflow \
         -Wno-missing-field-initializers \
         -Wno-unused-result \
         -Werror=overflow \
-        -Wp,-D_FORTIFY_SOURCE=2 \
         -ffast-math \
         -fno-common \
         -fdiagnostics-show-option \
         -fno-strict-aliasing \
         -fvisibility=hidden \
         -ffunction-sections \
         -ffast-math \
         -fno-common \
         -fdiagnostics-show-option \
         -fno-strict-aliasing \
         -fvisibility=hidden \
         -ffunction-sections \
-        -fdata-sections])
-AC_SUBST([WARNINGFLAGS], $with_cflags)
+        -fdata-sections \
+        -fstack-protector])
+AC_SUBST([OUR_CFLAGS], $with_cflags)
+
+CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
+        -Wp,-D_FORTIFY_SOURCE=2])
+AC_SUBST([OUR_CPPFLAGS], $with_cppflags)
 
 CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
         -Wl,--as-needed \
 
 CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
         -Wl,--as-needed \
-        -Wl,--gc-sections])
-AC_SUBST([GCLDFLAGS], $with_ldflags)
+        -Wl,--gc-sections \
+        -Wl,-z,relro \
+        -Wl,-z,now])
+AC_SUBST([OUR_LDFLAGS], $with_ldflags)
 
 AC_SEARCH_LIBS([clock_gettime], [rt], [], [AC_MSG_ERROR([*** POSIX RT library not found])])
 AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([*** Dynamic linking loader library not found])])
 
 AC_SEARCH_LIBS([clock_gettime], [rt], [], [AC_MSG_ERROR([*** POSIX RT library not found])])
 AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([*** Dynamic linking loader library not found])])
@@ -753,7 +759,7 @@ AC_MSG_RESULT([
         Split /usr:              ${enable_split_usr}
         man pages:               ${have_manpages}
 
         Split /usr:              ${enable_split_usr}
         man pages:               ${have_manpages}
 
-        CFLAGS:                  ${CFLAGS}
-        CPPLAGS:                 ${CPPFLAGS}
-        LDFLAGS:                 ${LDFLAGS}
+        CFLAGS:                  ${OUR_CFLAGS} ${CFLAGS}
+        CPPLAGS:                 ${OUR_CPPFLAGS} ${CPPFLAGS}
+        LDFLAGS:                 ${OUR_LDFLAGS} ${LDFLAGS}
 ])
 ])