Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip harden link and setuid tests on EL5
- Loading branch information
Corey Henderson
committed
Aug 27, 2014
1 parent
e2b59f2
commit bbadc0f
Showing
6 changed files
with
92 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
|
||
int main(int argc, char *argv[]) { | ||
|
||
int ret = setuid(0); | ||
|
||
if (0 == ret) | ||
return 0; | ||
else | ||
return 1; | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
uid=$1 | ||
|
||
kversion=$(uname -r | cut -d - -f 1) | ||
kmajor=$(echo $kversion | cut -d . -f 1) | ||
kminor=$(echo $kversion | cut -d . -f 2) | ||
krel=$(echo $kversion | cut -d . -f 3) | ||
|
||
# no harden support in EL5 | ||
if [ $kmajor -lt 3 ] && [ $krel -lt 19 ]; then | ||
echo "setuid protection not supported in this kernel" | ||
exit -1 | ||
fi | ||
|
||
# make sure it's off | ||
sysctl tpe.extras.restrict_setuid=0 | ||
|
||
cp $(dirname $0)/../scripts/setuid-test /bin/tpebintest | ||
chown root:root /bin/tpebintest | ||
chmod 4755 /bin/tpebintest | ||
|
||
# exec should work | ||
|
||
sudo -u "#$uid" /bin/tpebintest | ||
|
||
if [ $? != 0 ]; then | ||
echo "/bin/tpebintest could NOT setuid" | ||
ret=1 | ||
fi | ||
|
||
# now turn it on | ||
|
||
sysctl tpe.extras.restrict_setuid=1 | ||
|
||
# exec should'nt work now | ||
|
||
sudo -u "#$uid" /bin/tpebintest | ||
|
||
if [ $? == 0 ]; then | ||
echo "/bin/tpebintest could setuid" | ||
ret=1 | ||
fi | ||
|
||
# now turn it back off | ||
|
||
sysctl tpe.extras.restrict_setuid=0 | ||
|
||
rm -rf /bin/tpebintest | ||
|
||
exit $ret | ||
|