Fix tests when run as root; use bin account but current directory

This commit is contained in:
Erik van der Kouwe 2010-08-06 12:33:32 +00:00
parent ac9a7f47bd
commit c8f70b8154
8 changed files with 6 additions and 46 deletions

View file

@ -18,6 +18,10 @@ tests=" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
sh1.sh sh2.sh"
tests_no=`expr 0`
# Directory must be owned by bin
[ "$USER" != root ] || chown bin .
# Count tests
for i in `echo $tests`; do
if [ -x ./test$i ]; then
tests_no=`expr $tests_no + 1`
@ -36,8 +40,8 @@ do
then
total=`expr $total + 1`
FAIL=0
if [ $USER = root -a \( $i = 11 -o $i = 33 \) ]
then su - ast -c "cd `pwd`; ./test$i" || FAIL=1
if [ "$USER" = root ]
then su - bin -c "cd `pwd`; ./test$i" || FAIL=1
else ./test$i || FAIL=1
fi
if [ $FAIL -eq 0 ]

View file

@ -129,12 +129,6 @@ char *argv[];
}
sync();
if (geteuid() == 0 || getuid() == 0) {
realpath(argv[0], buffer);
execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", buffer, NULL);
printf("Test 17 cannot run as root; test aborted\n");
exit(1);
}
#define DIR "DIR17"
system("rm -rf " DIR);

View file

@ -135,13 +135,6 @@ int main(int argc, char **argv)
}
}
if (geteuid() == 0 || getuid() == 0) {
realpath(argv[0], buffer);
execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", buffer, NULL);
printf("Test 18 cannot run as root; test aborted\n");
exit(1);
}
#define DIR "DIR18"
system("rm -rf " DIR);
if(mkdir(DIR, 0755) != 0) {

View file

@ -42,13 +42,6 @@ char *argv[];
m = (argc == 2 ? atoi(argv[1]) : 0xFFFF);
if (geteuid() == 0 || getuid() == 0) {
realpath(argv[0], buffer);
execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", buffer, NULL);
printf("Test 19 cannot run as root; test aborted\n");
exit(1);
}
system("rm -rf DIR_19; mkdir DIR_19");
chdir("DIR_19");

View file

@ -48,12 +48,6 @@ char *argv[];
int i, m = 0xFFFF;
sync();
if (geteuid() == 0 || getuid() == 0) {
realpath(argv[0], buffer);
execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", buffer, NULL);
printf("Test 21 cannot run as root; test aborted\n");
exit(1);
}
if (argc == 2) m = atoi(argv[1]);
printf("Test 21 ");

View file

@ -49,12 +49,6 @@ int main(int argc, char *argv[])
int i, m = 0xFFFF;
sync();
if (geteuid() == 0 || getuid() == 0) {
realpath(argv[0], buffer);
execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", buffer, NULL);
printf("Test 25 cannot run as root; test aborted\n");
exit(1);
}
if (argc == 2) m = atoi(argv[1]);
start(25);

View file

@ -36,12 +36,6 @@ char *argv[];
sync();
if (geteuid() == 0 || getuid() == 0) {
realpath(argv[0], buffer);
execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", buffer, NULL);
printf("Test 3 cannot run as root; test aborted\n");
exit(1);
}
if (argc == 2) m = atoi(argv[1]);

View file

@ -32,12 +32,6 @@ char *argv[];
int i, m = 0xFFFF;
sync();
if (geteuid() == 0 || getuid() == 0) {
realpath(argv[0], buffer);
execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", buffer, NULL);
printf("Test 6 cannot run as root; test aborted\n");
exit(1);
}
if (argc == 2) m = atoi(argv[1]);