Beispiel #1
0
static void setup(void)
{
	char cur_dir_path[512];

	check_execveat();

	SAFE_MKDIR(TESTDIR, 0777);
	SAFE_CP(TEST_APP, TEST_REL_APP);

	SAFE_GETCWD(cur_dir_path, sizeof(cur_dir_path));
	sprintf(app_abs_path, "%s/%s", cur_dir_path, TEST_REL_APP);

	fd1 = SAFE_OPEN(TESTDIR, O_DIRECTORY);
	fd4 = SAFE_OPEN(TEST_REL_APP, O_PATH);
}
Beispiel #2
0
static void setup(void)
{
	tst_sig(FORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	if (tst_ncpus() == 1)
		tst_brkm(TCONF, NULL, "This test needs two cpus at least");

	tst_tmpdir();

	if (signal(SIGALRM, sigproc) == SIG_ERR)
		tst_brkm(TBROK | TERRNO, cleanup, "signal(SIGALRM) failed");

	alarm(TIMEOUT);

	SAFE_GETCWD(cleanup, init_cwd, PATH_MAX);
}
Beispiel #3
0
key_t getipckey(const char *file, const int lineno)
{
    char buf[BUFSIZE];
    key_t key;
    int id;
    static int count;

    SAFE_GETCWD(buf, BUFSIZE);

    id = count % 26 + (int) 'a';
    count++;

    key = ftok(buf, id);
    if (key == -1) {
        tst_brk(TBROK | TERRNO,
                "ftok() failed at %s:%d", file, lineno);
    }

    return key;
}
Beispiel #4
0
int main(int ac, char **av)
{
	int status;
	char cur_cwd[PATH_MAX];
	pid_t child;

	tst_parse_opts(ac, av, NULL, NULL);

	setup();

	child = tst_fork();
	if (child < 0)
		tst_brkm(TBROK | TERRNO, cleanup, "fork failed");

	if (child == 0)
		do_child();

	 while (1) {
		SAFE_GETCWD(cleanup, cur_cwd, PATH_MAX);
		if (strncmp(init_cwd, cur_cwd, PATH_MAX)) {
			tst_resm(TFAIL, "initial current work directory is "
				 "%s, now is %s. Bug is reproduced!",
				 init_cwd, cur_cwd);
			break;
		}

		if (end) {
			tst_resm(TPASS, "Bug is not reproduced!");
			break;
		}
	}

	SAFE_KILL(cleanup, child, SIGKILL);
	SAFE_WAITPID(cleanup, child, &status, 0);

	cleanup();
	tst_exit();
}
Beispiel #5
0
void setup(void)
{
	char *cwdname = NULL;
	int fd;

	umask(0);

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	ltpuser = SAFE_GETPWNAM(NULL, nobody_uid);

	SAFE_SETGID(NULL, ltpuser->pw_gid);

	tst_tmpdir();

	cwdname = SAFE_GETCWD(cleanup, cwdname, 0);

	sprintf(test_name5, "%s/fake.%d", cwdname, getpid());

	fileHandle = SAFE_CREAT(cleanup, test_name5, 0444);

	sprintf(test_name3, "%s/fake.%d", test_name5, getpid());

	/* creat() and close a zero length file with executeable permission */
	sprintf(test_name6, "%s/execve03.%d", cwdname, getpid());

	fd = SAFE_CREAT(cleanup, test_name6, 0755);
	fd = SAFE_CLOSE(cleanup, fd);
#ifndef UCLINUX
	bad_addr = SAFE_MMAP(cleanup, NULL, 1, PROT_NONE,
			     MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0);
	TC[3].tname = bad_addr;
#endif
}