mirror of https://github.com/vitalif/e2fsprogs
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
parent
a3f464ffe7
commit
29a5deed21
|
@ -1,15 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
ASM_TYPES=/usr/include/asm/types.h
|
||||
|
||||
if test ! -f $ASM_TYPES
|
||||
then
|
||||
echo "" > asm_types.h
|
||||
echo "No asm_types file found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat > /tmp/sed.script << "EOF"
|
||||
cat > sed.script << "EOF"
|
||||
/^#/d
|
||||
/^$/d
|
||||
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/
|
||||
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
|
||||
|
||||
cat >> asm_types.c <<EOF
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
#ifdef __U8_TYPEDEF
|
||||
|
@ -102,7 +98,7 @@ main(int argc, char **argv)
|
|||
}
|
||||
EOF
|
||||
|
||||
cc -o asm_types asm_types.c
|
||||
${BUILD_CC-${CC-gcc}} -o asm_types asm_types.c
|
||||
if ! ./asm_types
|
||||
then
|
||||
echo "Problem detected with asm_types.h"
|
||||
|
|
|
@ -82,6 +82,7 @@ if test -z "$CC" ; then CC=cc; fi
|
|||
export CC
|
||||
AC_SUBST([CC])
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
dnl
|
||||
dnl set $(LD) from --with-linker=value
|
||||
dnl
|
||||
|
@ -636,7 +637,7 @@ AC_SUBST(SIZEOF_INT)
|
|||
AC_SUBST(SIZEOF_LONG)
|
||||
AC_SUBST(SIZEOF_LONG_LONG)
|
||||
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
|
||||
AC_SUBST_FILE(ASM_TYPES_HEADER)
|
||||
dnl
|
||||
|
|
Loading…
Reference in New Issue