Improve the config/parse_types.sh helper script

Fix a potential security problem if e2fsprogs is built as root (as
Gentoo does!).  In addition fix the script and how it is called from
the configure script so that it does the right thing when
cross-compiling.

Fixes-Gentoo-bug: #146903

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2007-07-04 16:28:47 -04:00
parent a3f464ffe7
commit 29a5deed21
3 changed files with 807 additions and 2672 deletions

View File

@ -1,15 +1,6 @@
#!/bin/sh #!/bin/sh
ASM_TYPES=/usr/include/asm/types.h cat > sed.script << "EOF"
if test ! -f $ASM_TYPES
then
echo "" > asm_types.h
echo "No asm_types file found"
exit 1
fi
cat > /tmp/sed.script << "EOF"
/^#/d /^#/d
/^$/d /^$/d
s/__extension__ // s/__extension__ //
@ -17,11 +8,16 @@ s/typedef \(.*\) __u\([1-9]*\);/#define __U\2_TYPEDEF \1/
s/typedef \(.*\) __s\([1-9]*\);/#define __S\2_TYPEDEF \1/ s/typedef \(.*\) __s\([1-9]*\);/#define __S\2_TYPEDEF \1/
EOF EOF
gcc -E $ASM_TYPES | sed -f /tmp/sed.script | grep ^# > asm_types.h echo '#include <asm/types.h>' | ${CPP-${CC-gcc} -E} - | \
sed -f sed.script | grep ^# > asm_types.h
rm sed.script
cp asm_types.h asm_types.c cp asm_types.h asm_types.c
cat >> asm_types.c <<EOF cat >> asm_types.c <<EOF
#include <stdio.h>
#include <stdlib.h>
main(int argc, char **argv) main(int argc, char **argv)
{ {
#ifdef __U8_TYPEDEF #ifdef __U8_TYPEDEF
@ -102,7 +98,7 @@ main(int argc, char **argv)
} }
EOF EOF
cc -o asm_types asm_types.c ${BUILD_CC-${CC-gcc}} -o asm_types asm_types.c
if ! ./asm_types if ! ./asm_types
then then
echo "Problem detected with asm_types.h" echo "Problem detected with asm_types.h"

3456
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -82,6 +82,7 @@ if test -z "$CC" ; then CC=cc; fi
export CC export CC
AC_SUBST([CC]) AC_SUBST([CC])
AC_PROG_CC AC_PROG_CC
AC_PROG_CPP
dnl dnl
dnl set $(LD) from --with-linker=value dnl set $(LD) from --with-linker=value
dnl dnl
@ -636,7 +637,7 @@ AC_SUBST(SIZEOF_INT)
AC_SUBST(SIZEOF_LONG) AC_SUBST(SIZEOF_LONG)
AC_SUBST(SIZEOF_LONG_LONG) AC_SUBST(SIZEOF_LONG_LONG)
AC_C_BIGENDIAN AC_C_BIGENDIAN
/bin/sh $ac_aux_dir/parse-types.sh BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
ASM_TYPES_HEADER=./asm_types.h ASM_TYPES_HEADER=./asm_types.h
AC_SUBST_FILE(ASM_TYPES_HEADER) AC_SUBST_FILE(ASM_TYPES_HEADER)
dnl dnl