From: Erik van der Kouwe Date: Fri, 4 Dec 2009 17:51:06 +0000 (+0000) Subject: Fixed tests to use the right path when run as root X-Git-Tag: v3.1.6~168 X-Git-Url: http://zhaoyanbai.com/repos/pkcs11-list.html?a=commitdiff_plain;h=91d13ae054ba31f69fd91314dbbf59def2274838;p=minix.git Fixed tests to use the right path when run as root --- diff --git a/test/test17.c b/test/test17.c index 18c3b80e3..df0afd915 100644 --- a/test/test17.c +++ b/test/test17.c @@ -119,11 +119,13 @@ int main(argc, argv) int argc; char *argv[]; { + char buffer[PATH_MAX + 1]; int n, mask; sync(); if (geteuid() == 0 || getuid() == 0) { - execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", "/usr/src/test/test17", NULL); + 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); } diff --git a/test/test18.c b/test/test18.c index 18eb0f3d1..67224b766 100644 --- a/test/test18.c +++ b/test/test18.c @@ -78,7 +78,7 @@ char *file[20] = {"f0", "f1", "f2", "f3", "f4", "f5", "f6", /* "test.c", created by Rene Montsma and Menno Wilcke */ -_PROTOTYPE(int main, (void)); +_PROTOTYPE(int main, (int argc, char **argv)); _PROTOTYPE(void test, (void)); _PROTOTYPE(void test01, (void)); _PROTOTYPE(void test02, (void)); @@ -117,12 +117,14 @@ _PROTOTYPE(void quit, (void)); /***************************************************************************** * TEST * ****************************************************************************/ -int main() +int main(int argc, char **argv) { + char buffer[PATH_MAX + 1]; int n; if (geteuid() == 0 || getuid() == 0) { - execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", "/usr/src/test/test18", NULL); + 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); } diff --git a/test/test19.c b/test/test19.c index 911540b62..e51f0b202 100644 --- a/test/test19.c +++ b/test/test19.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -36,12 +37,14 @@ int main(argc, argv) int argc; char *argv[]; { + char buffer[PATH_MAX + 1]; int i, m; m = (argc == 2 ? atoi(argv[1]) : 0xFFFF); if (geteuid() == 0 || getuid() == 0) { - execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", "/usr/src/test/test19", NULL); + 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); } diff --git a/test/test21.c b/test/test21.c index e437b8349..257382564 100644 --- a/test/test21.c +++ b/test/test21.c @@ -44,11 +44,13 @@ int argc; char *argv[]; { + char buffer[PATH_MAX + 1]; int i, m = 0xFFFF; sync(); if (geteuid() == 0 || getuid() == 0) { - execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", "/usr/src/test/test21", NULL); + 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); } diff --git a/test/test25.c b/test/test25.c index 0136bc8d7..98287ffb1 100644 --- a/test/test25.c +++ b/test/test25.c @@ -47,11 +47,13 @@ void main(argc, argv) int argc; char *argv[]; { + char buffer[PATH_MAX + 1]; int i, m = 0xFFFF; sync(); if (geteuid() == 0 || getuid() == 0) { - execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", "/usr/src/test/test25", NULL); + 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); } diff --git a/test/test3.c b/test/test3.c index 4dc847022..71a065464 100644 --- a/test/test3.c +++ b/test/test3.c @@ -31,12 +31,14 @@ int main(argc, argv) int argc; char *argv[]; { + char buffer[PATH_MAX + 1]; int i, m = 0xFFFF; sync(); if (geteuid() == 0 || getuid() == 0) { - execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", "/usr/src/test/test3", NULL); + 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); } diff --git a/test/test6.c b/test/test6.c index e0012d88f..90f3839e1 100644 --- a/test/test6.c +++ b/test/test6.c @@ -28,11 +28,13 @@ int main(argc, argv) int argc; char *argv[]; { + char buffer[PATH_MAX + 1]; int i, m = 0xFFFF; sync(); if (geteuid() == 0 || getuid() == 0) { - execl("/usr/bin/su", "/usr/bin/su", "-", "ast", "-c", "/usr/src/test/test6", NULL); + 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); }