file_ret=
grep_ret=
fail_cnt=
-tmp_file="$dep_script_dir/tmp.list"
-tmp2_file="$dep_script_dir/tmp2.list"
exception_list="$dep_script_dir/exception.list"
function makeInput {
- $RM $tmp_file
- $TOUCH $tmp_file
- $RM $tmp2_file
- $TOUCH $tmp2_file
$RM $input_file
$TOUCH $input_file
- # Find executable and .so*
- $FIND / -type f -perm +111 > $tmp2_file
- $FIND / -name *.so >> $tmp2_file
- $CAT $tmp2_file | $SORT | $UNIQ > $tmp_file
- # Remove proc sys dev tmp run
- $SED -i '/^\/proc\//d' $tmp_file
- $SED -i '/^\/sys\//d' $tmp_file
- $SED -i '/^\/dev\//d' $tmp_file
- $SED -i '/^\/tmp\//d' $tmp_file
- $SED -i '/^\/run\//d' $tmp_file
- # Remove *.mo, *.png, *.sh, *.log, *.xml, *.conf, *.mp3, *.mpg, *.wmv, *.gif, *.avi, *.txt, *.socket, *.service file
- $SED -i '/\.mo$/d' $tmp_file
- $SED -i '/\.png$/d' $tmp_file
- $SED -i '/\.sh$/d' $tmp_file
- $SED -i '/\.log$/d' $tmp_file
- $SED -i '/\.xml$/d' $tmp_file
- $SED -i '/\.conf$/d' $tmp_file
- $SED -i '/\.mp3$/d' $tmp_file
- $SED -i '/\.mpg$/d' $tmp_file
- $SED -i '/\.wmv$/d' $tmp_file
- $SED -i '/\.gif$/d' $tmp_file
- $SED -i '/\.avi$/d' $tmp_file
- $SED -i '/\.txt$/d' $tmp_file
- $SED -i '/\.socket$/d' $tmp_file
- $SED -i '/\.service$/d' $tmp_file
-
- while read line; do
- $utils_dir/file $line | $GREP "ELF" | $CUT -d ":" -f 1 >> $input_file
- done < $tmp_file
- $RM $tmp_file
- $RM $tmp2_file
+ if [[ "$arch" = "a"* ]]; then
+ $FIND /usr /etc /opt -perm +111 | $XARGS $utils_dir/file | grep "ELF" | cut -d ":" -f1 | xargs $utils_dir/execstack -q | grep "^X " | cut -d " " -f2 > $input_file
+ else
+ $FIND /usr /etc /opt -perm +111 ! -iname '*.mo' ! -iname '*.sh' ! -iname '*.png' ! -iname '*.log' ! -iname '*.mp3' ! -iname '*.xml' ! -iname '*.conf' ! -iname '*.gif' ! -iname '*.service' ! -iname '*.txt' | $XARGS $utils_dir/file | $GREP "ELF" | $CUT -d ":" -f1 > $input_file
+ fi
}
function testDEP {
echoI "Check STACK Flag"
while read line; do
grep_ret=""
- echoI "Check $line"
- grep_ret=`$utils_dir/readelf -l $line | $GREP "STACK" | $GREP "RWE"`
-
- if [ ! "$grep_ret" ]; then
- echoS "$line, OK"
+ exception_check="false"
+ is_exception="false"
+ if [[ $arch != "a"* ]]; then
+ #echoI "check $line"
+ grep_ret=`$utils_dir/readelf -l $line | $GREP "STACK" | $GREP "E"`
+ if [ "$grep_ret" ]; then
+ exception_check="true"
+ fi
else
- is_exception="false"
+ exception_check="true"
+ fi
+ if [ "$exception_check" = "true" ]; then
while read line2; do
if [ "$line" = "$line2" ]; then
is_exception="true"
fi
done < $exception_list
- if [ "$is_exception" = "true" ]; then
- echoS "$line"", OK - Not a target of DEP test"
- else
+ if [ "$is_exception" = "false" ]; then
echoE "$line, NOK"
rpm_path=$(/usr/bin/rpm -qf $line)
echo "$line,""$rpm_path"",NOK" >> $log_file
fail_cnt=$((fail_cnt+1))
fi
- fi
+ fi
done < $input_file
$RM $input_file
}
$RM $result_file
$TOUCH $result_file
+#set required so
+LIBELF="libelf-0.153.so"
+LIBELF_LN="libelf.so.0"
+lib_dir=
+arch_info=`$utils_dir/file $utils_dir/file`
+if [[ $arch_info == *"aarch64"* ]]
+then
+ echo "aarch64!!"
+ arch="aarch64"
+ lib_dir="/usr/lib64"
+elif [[ $arch_info == *"ARM"* ]]
+then
+ echo "arm!!"
+ arch="arm"
+ lib_dir="/usr/lib"
+elif [[ $arch_info == *"x86-64"* ]]
+then
+ echo "x86_64!!"
+ arch="x86_64"
+elif [[ $arch_info == *"Intel"* ]]
+then
+ echo "i386!!"
+ arch="i386"
+fi
+
# Rename utils
file_cmd=`$FIND $utils_dir -name file.*`
readelf_cmd=`$FIND $utils_dir -name readelf.*`
+execstack_cmd=`$FIND $utils_dir -name execstack.*`
if [ "$file_cmd" != "" ]; then
$MV $file_cmd $utils_dir/file
fi
if [ "$readelf_cmd" != "" ]; then
$MV $readelf_cmd $utils_dir/readelf
fi
+if [ "$execstack_cmd" != "" ]; then
+ $MV $execstack_cmd $utils_dir/execstack
+ ln -s $lib_dir/$LIBELF $lib_dir/$LIBELF_LN
+fi
#=========================================================
# [02] Make List
$MV $dep_script_dir/log.csv $log_dir/dep_test.log
fi
$MV $dep_script_dir/result $result_dir/dep_test.result
+if [ -a $lib_dir/$LIBELF_LN ]; then
+ rm $lib_dir/$LIBELF_LN
+fi
fnPrintSDone