BE CAREFUL! THIS SCRIPT IS INVOKED FROM A SETUID ROOT BINARY

0_kwFwNhQfllA0DKC4_ (1)
#!/bin/bash
#

BE CAREFUL! THIS SCRIPT IS INVOKED FROM A SETUID ROOT BINARY

#

function printhelp () {
echo “Usage: sys_uname [-h] [OPTION] [ — mod_path … ]”
echo “Prints kernel version string for modules”
echo
echo ” -h Print this help”
echo ” -f Choose closest kernel”
echo ” -l List available kernels”
echo ” -e Try to find an exact match”
echo ” -p Print version string for the running kernel”
exit 1
}
[ “$1” == “–help” ] && printhelp 1>&2

###########################################################

Parse options

###########################################################

while getopts “hflep” x ; do
WORKED=1
case “$x” in
p) PRINT_THIS_UNAME=Y ;;
f) FIND_CLOSEST=Y ;;
l) FIND_AVAIL=Y ;;
e) FIND_EXACT=Y ;;
h|*) printhelp ; exit 1 ;;
esac
done
[ “$WORKED” != 1 ] && PRINT_THIS_UNAME=Y

shift expr $OPTIND - 1

[ $# == 0 -a “$FIND_CLOSEST$FIND_AVAIL$FIND_EXACT” ] && {
printhelp 1>&2 ; exit 1;
}

MOD_PATHS=””
for x in $* ; do
# Only include a directory once
for y in $MOD_PATHS ; do
[ $x = $y -o $x -ef $y ] && x=”” ; break
break;
done
MOD_PATHS=”$MOD_PATHS $x”
done

###########################################################

Determine the version string of the running kernel

###########################################################

KVER=uname -r | cut -d "." -f 2;
if [ ${KVER} -eq 4 ]; then
unset SMP ALTIVEC
cat /proc/version | grep SMP > /dev/null
[ $? == 0 ] && SMP=”-smp”

if [ -f /proc/ksyms ]; then
    grep altivec /proc/ksyms
    [ $? != 0 ] && ALTIVEC="-noav"
fi
THIS_UNAME=`uname -r`$SMP$ALTIVEC

else
THIS_UNAME=uname -r
fi

###########################################################

Find all…

###########################################################

function find_avail () {
for x in $MOD_PATHS ; do
test -d $x || continue;
cd $x || continue;

_AVAIL=`find $x -maxdepth 1 -type d -exec test -f '{}/mol.o' -o -f '{}/mol.ko' \; -print`

for x in $_AVAIL ; do
    echo $x
done
done

}

###########################################################

Do it…

###########################################################

[ “$PRINT_THIS_UNAME” ] && {
echo $THIS_UNAME
exit 0
}
[ “$FIND_EXACT” ] && {
for x in $MOD_PATHS ; do
[ -f $x/$THIS_UNAME/mol.o -o -f $x/$THIS_UNAME/mol.ko ] && {
echo $x/$THIS_UNAME
exit 0
}
done
exit 1
}
[ “$FIND_AVAIL” ] && {
find_avail
}
[ “$FIND_CLOSEST” ] && {
AVAIL=find_avail
unset AVAIL_UNAMES
for x in $AVAIL ; do
AVAIL_UNAMES=”$AVAIL_UNAMES echo $x | sed s/.*modules[/]//
done
MATCH=$BIN_DIR/kver_approx $THIS_UNAME $AVAIL_UNAMES || exit $?

for x in $AVAIL ; do
s=`echo $x | sed s/.*modules[/]//`
[ "$s" = "$MATCH" ] && { echo $x ; exit 0 ; }
done

}

exit 0

Published by Michael Jones

One love, I want to further illustrate the importance of idenity and communication to me. I understand communication to drive and act as a catalyst for diversifying pros. This in the context of being about me proves to me the necessary ambiguity and of course the "leader intensive" roles of communication. During my undergrad I had a chance further education for a blog, and one thing I remember is it told me that writing is intensive and requires communication. Amid it as it is to be when projected to describe communication as the corner stone for the better evolution. With this being said, I am communication as gorged is important and Techrepublic similar, states this by saying, maintaining regular and open communication smooths the flow of instructions. Sparking this conscious recedes from an early assessment or preparation to become a person. This in-part was presented by researching about writers and my understanding of compliance and leading as the "Leader", but more importantly communication, because the essential progress is the indicator anything is being communicated. In ways communication needs to be received and understood. This proactive approach to communication ensures the success of the Communication in all talks. The relation an at many levels a great importance, because it inhibits the ability to address goals, objectives, and again flow. Rather the documented writing address aspects and topics: Keyed, results, quality reviews, etc. I am the plan, is the concern, which sets a reasonable expectation for speech in regards to project communication.