Skip to content
Snippets Groups Projects
Commit f3d15cc7 authored by jdh8d's avatar jdh8d
Browse files

Rearranged the precompiled examples into their own directory, edited makefiles...

Rearranged the precompiled examples into their own directory, edited makefiles to save the unprotected (stock) and protected executables.  Also adjustments to ps_analyze and makefiles to allow turning off steps of ps_analyze.
parent 2b24fd6a
No related branches found
No related tags found
No related merge requests found
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
...@@ -8,6 +8,16 @@ ...@@ -8,6 +8,16 @@
# peasoup_analyze.sh <original_binary> <new_binary> <options> # peasoup_analyze.sh <original_binary> <new_binary> <options>
# #
check_step_option()
{
echo $1|egrep "=off$|=on$" > /dev/null
if [ $? -ne 0 ]; then
echo Malformed option: $1;
exit -4;
fi
}
# #
# check that the remaining options are validly parsable, and record what they are. # check that the remaining options are validly parsable, and record what they are.
...@@ -16,11 +26,44 @@ check_options() ...@@ -16,11 +26,44 @@ check_options()
{ {
# #
# fill in better option parsing later. # loop to process options.
# #
# Note that we use `"$@"' to let each command-line parameter expand to a
# separate word. The quotes around `$@' are essential!
# We need TEMP as the `eval set --' would nuke the return value of getopt.
TEMP=`getopt -o s: --long step: -n 'ps_analyze.sh' -- "$@"`
# error check #
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit -1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true ; do
case "$1" in
-s|--step)
echo "found option --step with argument $2"
check_step_option $2
phases_off=" $phases_off $2 "
shift 2
;;
--) shift
break
;;
*) echo "Internal error!"
exit -2
;;
esac
done
# report errors if found
if [ ! -z $1 ]; then if [ ! -z $1 ]; then
echo Cannot parse option $1 echo Unparsed parameters:
exit 1 fi
for arg do echo '--> '"\`$arg'" ; done
if [ ! -z $1 ]; then
exit -3;
fi fi
} }
...@@ -31,19 +74,75 @@ check_options() ...@@ -31,19 +74,75 @@ check_options()
# #
is_step_on() is_step_on()
{ {
# for now, all steps are on step=$1
echo $phases_off|egrep "$step=off" > /dev/null
if [ $? -eq 0 ] ; then
return 0
fi
# for now, all steps are on unless explicitly set to off
return 1 return 1
} }
# #
# get_step_error_code # is_step_error decide based on the step (in $1) and the exit code (in $2) if there was a failure.
# #
is_step_error() is_step_error()
{ {
# my_step=$1
# fill in with better info later my_error=$2
#
return 0
case $my_step in
# registering the program should return the variant ID, 0 or negative is error.
pdb_register)
if [ $my_error -gt 0 ]; then
return 0;
fi
return 1;
;;
# cloning the program should return the variant ID, 0 or negative is error.
clone)
if [ $my_error -gt 0 ]; then
return 0;
fi
return 1;
;;
*)
if [ $my_error -eq 0 ]; then
# if not otherwise specified, programs should return 0
return 0;
fi
return 1;
esac
}
#
# return the severity of the error for the step in $1
#
stop_if_error()
{
my_step=$1
case $my_step in
# getting the annotation file right is necessary-ish
meds_static)
return 1;
;;
# registering the program is necessary
pdb_register)
return 2;
;;
# cloning is necessary
clone)
return 3;
;;
# other steps are optional
*)
return 0;
esac
} }
# #
...@@ -57,6 +156,7 @@ perform_step() ...@@ -57,6 +156,7 @@ perform_step()
is_step_on $step is_step_on $step
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo Skipping step $step.
return 0 return 0
fi fi
...@@ -74,11 +174,16 @@ perform_step() ...@@ -74,11 +174,16 @@ perform_step()
command_exit=$? command_exit=$?
fi fi
echo command exit status for step $step is $command_exit
is_step_error $step $command_exit is_step_error $step $command_exit
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo command failed! echo Done. Command failed!
# check if we need to exit
stop_if_error $step
if [ $? -lt $error_threshold ]; then
echo The $step step is necessary, but failed. Exiting ps_analyze early.
exit -1;
fi
else else
echo Done. Successful. echo Done. Successful.
fi fi
...@@ -174,9 +279,6 @@ check_files() ...@@ -174,9 +279,6 @@ check_files()
} }
ps_starttime=`date`
# #
# turn on debugging output if it's requested. # turn on debugging output if it's requested.
# #
...@@ -185,6 +287,18 @@ if [ ! -z "$VERBOSE" ]; then ...@@ -185,6 +287,18 @@ if [ ! -z "$VERBOSE" ]; then
fi fi
#
# set the threshold value. if a step errors with a more severe error (1=most severe, >1 lesser severe)
# than the error_threshold, we exit.
#
error_threshold=1
#
# record when we started processing:
#
ps_starttime=`date`
# #
# stepnum used for counting how many steps peasoup executes # stepnum used for counting how many steps peasoup executes
# #
...@@ -307,6 +421,10 @@ if [ -f $newname.ncexe.annot -a $varid -gt 0 ]; then ...@@ -307,6 +421,10 @@ if [ -f $newname.ncexe.annot -a $varid -gt 0 ]; then
perform_step clone $SECURITY_TRANSFORMS_HOME/libIRDB/test/clone.exe $varid perform_step clone $SECURITY_TRANSFORMS_HOME/libIRDB/test/clone.exe $varid
cloneid=$? cloneid=$?
#
# we could skip this check and simplify ps_analyze if we say that cloning is necessary in is_step_error
#
if [ $cloneid -gt 0 ]; then if [ $cloneid -gt 0 ]; then
# do the basic tranforms we're performing for peasoup # do the basic tranforms we're performing for peasoup
perform_step fix_calls $SECURITY_TRANSFORMS_HOME/libIRDB/test/fix_calls.exe $cloneid perform_step fix_calls $SECURITY_TRANSFORMS_HOME/libIRDB/test/fix_calls.exe $cloneid
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# #
for i in $* for i in $*
do do
echo $i|egrep "^-"; # check for starting with a - echo $i|egrep "^-" > /dev/null; # check for starting with a -
if [ 0 -eq $? ] ; then if [ 0 -eq $? ] ; then
echo $i|egrep "^-o" > /dev/null; # check for starting with a -o echo $i|egrep "^-o" > /dev/null; # check for starting with a -o
dasho=$? dasho=$?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment