Fixed tests to use the right path when run as root

This commit is contained in:
Erik van der Kouwe 2009-12-04 17:51:06 +00:00
parent 09939b454e
commit 91d13ae054
7 changed files with 24 additions and 9 deletions

View file

@ -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);
}

View file

@ -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);
}

View file

@ -2,6 +2,7 @@
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}