예제 #1
0
파일: rename09.c 프로젝트: kraj/ltp
/*
 * setup() - performs all ONE TIME setup for this test.
 */
void setup(void)
{
	struct passwd *pw;

	tst_require_root();

	pw = SAFE_GETPWNAM(NULL, "nobody");
	nobody_uid = pw->pw_uid;
	pw = SAFE_GETPWNAM(NULL, "bin");
	bin_uid = pw->pw_uid;

	tst_sig(FORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	/* Create a temporary directory and make it current. */
	tst_tmpdir();

	umask(0);

	sprintf(fdir, "tdir_%d", getpid());
	sprintf(mdir, "rndir_%d", getpid());
	sprintf(fname, "%s/tfile_%d", fdir, getpid());
	sprintf(mname, "%s/rnfile_%d", mdir, getpid());
}
예제 #2
0
파일: utimes01.c 프로젝트: MohdVara/ltp
static void setup(void)
{
	struct passwd *ltpuser;
	const char *fs_type;

	tst_require_root(NULL);

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to obtain block device");

	SAFE_TOUCH(cleanup, TESTFILE1, FILE_MODE, NULL);
	ltpuser = SAFE_GETPWNAM(cleanup, LTPUSER1);
	SAFE_CHOWN(cleanup, TESTFILE1, ltpuser->pw_uid,
		ltpuser->pw_gid);

	SAFE_TOUCH(cleanup, TESTFILE2, FILE_MODE, NULL);
	ltpuser = SAFE_GETPWNAM(cleanup, LTPUSER2);
	SAFE_CHOWN(cleanup, TESTFILE2, ltpuser->pw_uid,
		ltpuser->pw_gid);

	tst_mkfs(cleanup, device, fs_type, NULL);
	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
	if (mount(device, MNTPOINT, fs_type, 0, NULL) == -1) {
		tst_brkm(TBROK | TERRNO, cleanup,
			"mount device:%s failed", device);
	}
	mount_flag = 1;
	SAFE_TOUCH(cleanup, TESTFILE3, FILE_MODE, NULL);
	ltpuser = SAFE_GETPWNAM(cleanup, LTPUSER1);
	SAFE_CHOWN(cleanup, TESTFILE3, ltpuser->pw_uid,
		ltpuser->pw_gid);
	if (mount(device, MNTPOINT, fs_type,
			MS_REMOUNT | MS_RDONLY, NULL) == -1) {
		tst_brkm(TBROK | TERRNO, cleanup,
			"mount device:%s failed", device);
	}

	ltpuser = SAFE_GETPWNAM(cleanup, LTPUSER1);
	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
}
예제 #3
0
파일: swapoff02.c 프로젝트: MohdVara/ltp
static void setup(void)
{
	long type;
	struct passwd *nobody;

	tst_sig(FORK, DEF_HANDLER, cleanup);

	TEST_EXP_ENOS(exp_enos);

	tst_require_root(NULL);

	nobody = SAFE_GETPWNAM(NULL, "nobody");
	nobody_uid = nobody->pw_uid;

	TEST_PAUSE;

	tst_tmpdir();

	switch ((type = tst_fs_type(cleanup, "."))) {
	case TST_NFS_MAGIC:
	case TST_TMPFS_MAGIC:
		tst_brkm(TCONF, cleanup,
			 "Cannot do swapoff on a file on %s filesystem",
			 tst_fs_type_name(type));
	break;
	}

	if (!tst_fs_has_free(NULL, ".", 1, TST_KB)) {
		tst_brkm(TBROK, cleanup,
			 "Insufficient disk space to create swap file");
	}

	if (tst_fill_file("./swapfile01", 0x00, 1024, 1))
		tst_brkm(TBROK, cleanup, "Failed to create swapfile");
}
예제 #4
0
파일: umount03.c 프로젝트: AbhiramiP/ltp
static void setup(void)
{
	const char *fs_type;
	struct passwd *ltpuser;

	tst_sig(FORK, DEF_HANDLER, cleanup);

	tst_require_root(NULL);

	ltpuser = SAFE_GETPWNAM(NULL, "nobody");

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);
	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to obtain block device");

	tst_mkfs(cleanup, device, fs_type, NULL);

	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);

	if (mount(device, MNTPOINT, fs_type, 0, NULL))
		tst_brkm(TBROK | TERRNO, cleanup, "mount() failed");
	mount_flag = 1;

	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
	TEST_PAUSE;
}
예제 #5
0
파일: mount04.c 프로젝트: JanyHuang/ltp
static void setup(void)
{
	char nobody_uid[] = "nobody";
	struct passwd *ltpuser;

	tst_sig(FORK, DEF_HANDLER, cleanup);

	tst_require_root();

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to obtain block device");

	tst_mkfs(cleanup, device, fs_type, NULL);

	ltpuser = SAFE_GETPWNAM(cleanup, nobody_uid);
	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
	SAFE_MKDIR(cleanup, mntpoint, DIR_MODE);

	TEST_PAUSE;
}
예제 #6
0
파일: acct01.c 프로젝트: disdi/ltp
static void setup(void)
{
	int fd;

	tst_require_root(NULL);

	tst_tmpdir();

	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");

	fd = SAFE_CREAT(cleanup, TEST_FILE5, 0777);
	SAFE_CLOSE(cleanup, fd);

	if (acct(TEST_FILE5) == -1) {
		if (errno == ENOSYS) {
			tst_brkm(TCONF, cleanup,
				 "BSD process accounting is not configured in "
				 "this kernel");
		} else {
			tst_brkm(TBROK | TERRNO, cleanup, "acct failed unexpectedly");
		}
	}

	/* turn off acct, so we are in a known state */
	if (acct(NULL) == -1) {
		if (errno == ENOSYS) {
			tst_brkm(TCONF, cleanup,
				 "BSD process accounting is not configured in "
				 "this kernel");
		} else {
			tst_brkm(TBROK | TERRNO, cleanup, "acct(NULL) failed");
		}
	}

	/* ELOOP SETTING */
	SAFE_SYMLINK(cleanup, TEST_FILE6, "test_file_eloop2");
	SAFE_SYMLINK(cleanup, "test_file_eloop2", TEST_FILE6);

	/* ENAMETOOLONG SETTING */
	memset(nametoolong, 'a', PATH_MAX+1);

	/* EROFS SETTING */
	tst_mkfs(NULL, device, fstype, NULL);
	SAFE_MKDIR(cleanup, "mntpoint", DIR_MODE);
	if (mount(device, "mntpoint", fstype, 0, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag = 1;
	/* Create a file in the file system, then remount it as read-only */
	fd = SAFE_CREAT(cleanup, TEST_FILE8, 0644);
	SAFE_CLOSE(cleanup, fd);
	if (mount(device, "mntpoint", fstype,
		  MS_REMOUNT | MS_RDONLY, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag = 1;
}
예제 #7
0
파일: access03.c 프로젝트: 1587/ltp
static void setup(void)
{
	struct passwd *pw;

	pw = SAFE_GETPWNAM("nobody");

	uid = pw->pw_uid;
}
예제 #8
0
int main(int argc, char *argv[])
{
	struct passwd *pwent;

	setup();

	/* EISDIR */
	if (acct("/") == -1 && errno == EISDIR)
		tst_resm(TPASS, "Failed with EISDIR as expected");
	else
		tst_brkm(TFAIL | TERRNO, cleanup,
			 "didn't fail as expected; expected EISDIR");

	/* EACCES */
	if (acct("/dev/null") == -1 && errno == EACCES)
		tst_resm(TPASS, "Failed with EACCES as expected");
	else
		tst_brkm(TFAIL | TERRNO, cleanup,
			 "didn't fail as expected; expected EACCES");

	/* ENOENT */
	if (acct("/tmp/does/not/exist") == -1 && errno == ENOENT)
		tst_resm(TPASS, "Failed with ENOENT as expected");
	else
		tst_brkm(TBROK | TERRNO, cleanup,
			 "didn't fail as expected; expected ENOENT");

	/* ENOTDIR */
	if (acct("/etc/fstab/") == -1 && errno == ENOTDIR)
		tst_resm(TPASS, "Failed with ENOTDIR as expected");
	else
		tst_brkm(TFAIL | TERRNO, cleanup,
			 "didn't fail as expected; expected ENOTDIR");

	/* EPERM */
	sprintf(tmpbuf, "./%s.%d", TCID, getpid());
	fd = SAFE_CREAT(cleanup, tmpbuf, 0777);
	SAFE_CLOSE(cleanup, fd);

	if (acct(tmpbuf) == -1)
		tst_brkm(TBROK | TERRNO, cleanup, "acct failed unexpectedly");

	pwent = SAFE_GETPWNAM(cleanup, "nobody");
	SAFE_SETEUID(cleanup, pwent->pw_uid);

	if (acct(tmpbuf) == -1 && errno == EPERM)
		tst_resm(TPASS, "Failed with EPERM as expected");
	else
		tst_brkm(TBROK | TERRNO, cleanup,
			 "didn't fail as expected; expected EPERM");

	SAFE_SETEUID(cleanup, 0);
	SAFE_UNLINK(cleanup, tmpbuf);

	cleanup();
	tst_exit();
}
예제 #9
0
파일: fchdir03.c 프로젝트: sathnaga/ltp
void setup(void)
{
	struct passwd *pw;

	pw = SAFE_GETPWNAM("nobody");
	SAFE_SETEUID(pw->pw_uid);
	SAFE_MKDIR(DIRNAME, 0400);

	fd = SAFE_OPEN(DIRNAME, O_RDONLY);
}
예제 #10
0
파일: mkdir04.c 프로젝트: Nan619/ltp
/*
 * setup() - performs all ONE TIME setup for this test.
 */
void setup(void)
{
	struct passwd *pw;

	tst_require_root();

	pw = SAFE_GETPWNAM(NULL, "nobody");
	nobody_uid = pw->pw_uid;
	pw = SAFE_GETPWNAM(NULL, "bin");
	bin_uid = pw->pw_uid;

	tst_sig(FORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	/* Create a temporary directory and make it current. */
	tst_tmpdir();

	umask(0);
}
예제 #11
0
파일: vhangup01.c 프로젝트: AbhiramiP/ltp
static void setup(void)
{
	struct passwd *pw;

	tst_require_root(NULL);

	pw = SAFE_GETPWNAM(NULL, "nobody");
	nobody_uid = pw->pw_uid;

	TEST_PAUSE;
}
예제 #12
0
파일: shmat02.c 프로젝트: kraj/ltp
static void setup(void)
{
	aligned_addr = PROBE_FREE_ADDR();
	unaligned_addr = aligned_addr + SHMLBA - 1;

	shm_key1 = GETIPCKEY();

	shm_id2 = SAFE_SHMGET(shm_key1, INT_SIZE, SHM_RW | IPC_CREAT | IPC_EXCL);

	pw = SAFE_GETPWNAM("nobody");
}
예제 #13
0
파일: setresuid05.c 프로젝트: MohdVara/ltp
static void setup(void)
{
	tst_require_root(NULL);

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	tst_tmpdir();

	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
}
예제 #14
0
static void setup(void)
{
	struct passwd *pw;

	SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, NULL);
	SAFE_MKDIR(MNTPOINT, 0775);
	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
	mount_flag = 1;

	pw = SAFE_GETPWNAM("nobody");
	SAFE_SETEUID(pw->pw_uid);
}
예제 #15
0
파일: acct01.c 프로젝트: heluxie/LTP
static void setup(void)
{
	int fd;

	tst_require_root(NULL);

	check_acct_in_kernel();

	tst_tmpdir();

	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");

	fd = SAFE_CREAT(cleanup, TEST_FILE5, 0777);
	SAFE_CLOSE(cleanup, fd);

	if (acct(TEST_FILE5) == -1)
		tst_brkm(TBROK | TERRNO, cleanup, "acct failed unexpectedly");

	/* turn off acct, so we are in a known state */
	if (acct(NULL) == -1)
		tst_brkm(TBROK | TERRNO, cleanup, "acct(NULL) failed");

	/* ELOOP SETTING */
	SAFE_SYMLINK(cleanup, TEST_FILE6, "test_file_eloop2");
	SAFE_SYMLINK(cleanup, "test_file_eloop2", TEST_FILE6);

	/* ENAMETOOLONG SETTING */
	memset(nametoolong, 'a', PATH_MAX+1);

	/* EROFS SETTING */
	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to obtain block device");

	tst_mkfs(cleanup, device, fs_type, NULL);
	SAFE_MKDIR(cleanup, "mntpoint", DIR_MODE);
	if (mount(device, "mntpoint", fs_type, 0, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag = 1;

	/* Create a file in the file system, then remount it as read-only */
	fd = SAFE_CREAT(cleanup, TEST_FILE8, 0644);
	SAFE_CLOSE(cleanup, fd);
	if (mount(device, "mntpoint", fs_type,
		  MS_REMOUNT | MS_RDONLY, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
}
예제 #16
0
파일: mkdir04.c 프로젝트: kraj/ltp
static void setup(void)
{
	struct passwd *pw;
	pid_t pid;

	pw = SAFE_GETPWNAM("nobody");
	nobody_uid = pw->pw_uid;
	pw = SAFE_GETPWNAM("bin");
	bin_uid = pw->pw_uid;

	pid = SAFE_FORK();
	if (pid == 0) {
		SAFE_SETREUID(nobody_uid, nobody_uid);
		SAFE_MKDIR(TESTDIR, 0700);
		exit(0);
	}

	tst_reap_children();

	SAFE_SETREUID(bin_uid, bin_uid);
}
예제 #17
0
파일: access05.c 프로젝트: disdi/ltp
static void setup(void)
{
	int fd;

	tst_sig(NOFORK, DEF_HANDLER, cleanup);
	tst_require_root(NULL);

	ltpuser = SAFE_GETPWNAM(cleanup, nobody_uid);
	SAFE_SETUID(cleanup, ltpuser->pw_uid);
	TEST_PAUSE;

#if !defined(UCLINUX)
	bad_addr = mmap(0, 1, PROT_NONE,
			MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0);
	if (bad_addr == MAP_FAILED)
		tst_brkm(TBROK | TERRNO, NULL, "mmap failed");
	test_cases[4].pathname = bad_addr;

	test_cases[5].pathname = get_high_address();
#endif

	tst_tmpdir();

	/*
	 * create TEST_FILE1 to test R_OK EACCESS
	 */
	fd = SAFE_CREAT(cleanup, TEST_FILE1, 0333);
	SAFE_CLOSE(cleanup, fd);

	/*
	 * create TEST_FILE2 to test W_OK EACCESS
	 */
	fd = SAFE_CREAT(cleanup, TEST_FILE2, 0555);
	SAFE_CLOSE(cleanup, fd);

	/*
	 * create TEST_FILE3 to test X_OK EACCESS
	 */
	fd = SAFE_CREAT(cleanup, TEST_FILE3, 0666);
	SAFE_CLOSE(cleanup, fd);

	/*
	 * create TEST_FILE4 to test EINVAL
	 */
	fd = SAFE_CREAT(cleanup, TEST_FILE4, 0333);
	SAFE_CLOSE(cleanup, fd);

	/*
	 *setup to create a node with a name length exceeding
	 *the MAX length of PATH_MAX.
	 */
	memset(longpathname, 'a', sizeof(longpathname) - 1);
}
예제 #18
0
/*
 * setup() - performs all ONE TIME setup for this test.
 */
void setup(void)
{
	struct passwd *pw;

	tst_require_root();

	pw = SAFE_GETPWNAM(NULL, "nobody");
	nobody_uid = pw->pw_uid;

	tst_sig(FORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;
}
예제 #19
0
파일: access01.c 프로젝트: Havner/ltp
static void setup(void)
{
	struct passwd *pw;

	pw = SAFE_GETPWNAM("nobody");

	uid = pw->pw_uid;

	SAFE_TOUCH(FNAME_RWX, 0777, NULL);
	SAFE_TOUCH(FNAME_R, 0444, NULL);
	SAFE_TOUCH(FNAME_W, 0222, NULL);
	SAFE_TOUCH(FNAME_X, 0111, NULL);
}
예제 #20
0
파일: setegid02.c 프로젝트: MohdVara/ltp
static void setup(void)
{
	tst_require_root(NULL);

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");

	SAFE_SETEUID(cleanup, ltpuser->pw_uid);

	TEST_EXP_ENOS(exp_enos);
}
예제 #21
0
파일: chdir03.c 프로젝트: HackLinux/ltp
void setup(void)
{
    struct passwd *pw;
    char *cur_dir = NULL;

    tst_require_root(NULL);

    pw = SAFE_GETPWNAM(NULL, "nobody");
    nobody_uid = pw->pw_uid;
    pw = SAFE_GETPWNAM(NULL, "bin");
    bin_uid = pw->pw_uid;

    tst_sig(FORK, DEF_HANDLER, cleanup);

    TEST_PAUSE;

    tst_tmpdir();

    if ((cur_dir = getcwd(cur_dir, 0)) == NULL)
        tst_brkm(TBROK | TERRNO, cleanup, "getcwd failed");

    sprintf(good_dir, "%s/%d", cur_dir, getpid());
}
예제 #22
0
파일: setresgid04.c 프로젝트: AbhiramiP/ltp
static void setup(void)
{
	tst_require_root(NULL);

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	tst_tmpdir();

	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");

	GID16_CHECK(ltpuser->pw_gid, "setresgid", cleanup)
}
예제 #23
0
파일: semop02.c 프로젝트: Semihalf/ltp
void setup(void)
{
	char nobody_uid[] = "nobody";
	struct passwd *ltpuser;
	key_t semkey2;
	struct seminfo ipc_buf;
	union semun arr;

	tst_require_root(NULL);

	ltpuser = SAFE_GETPWNAM(NULL, nobody_uid);
	SAFE_SETUID(NULL, ltpuser->pw_uid);

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	tst_tmpdir();

	/* get an IPC resource key */
	semkey = getipckey();

	/* create a semaphore set with read and alter permissions */
	sem_id_1 = semget(semkey, PSEMS, IPC_CREAT | IPC_EXCL | SEM_RA);
	if (sem_id_1 == -1) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "couldn't create semaphore in setup");
	}

	/* Get an new IPC resource key. */
	semkey2 = getipckey();

	/* create a semaphore set without read and alter permissions */
	sem_id_2 = semget(semkey2, PSEMS, IPC_CREAT | IPC_EXCL);
	if (sem_id_2 == -1) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "couldn't create semaphore in setup");
	}

	arr.ipc_buf = &ipc_buf;
	if (semctl(sem_id_1, 0, IPC_INFO, arr) == -1)
		tst_brkm(TBROK | TERRNO, cleanup, "semctl() IPC_INFO failed");

	/* for ERANGE errno test */
	arr.val = 1;
	s_buf[0].sem_op = ipc_buf.semvmx;
	if (semctl(sem_id_1, 0, SETVAL, arr) == -1)
		tst_brkm(TBROK | TERRNO, cleanup, "semctl() SETVAL failed");
}
예제 #24
0
파일: truncate03.c 프로젝트: 1587/ltp
void setup(void)
{
	struct passwd *ltpuser;
	char *bad_addr;
	struct rlimit rlim;
	sigset_t signalset;

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	tst_require_root();

	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
	SAFE_SETEUID(cleanup, ltpuser->pw_uid);

	TEST_PAUSE;

	tst_tmpdir();

	SAFE_TOUCH(cleanup, TEST_FILE1, NEW_MODE, NULL);

	SAFE_TOUCH(cleanup, "t_file", FILE_MODE, NULL);

#if !defined(UCLINUX)
	test_cases[2].pathname = (char *)get_high_address();

	bad_addr = SAFE_MMAP(cleanup, 0, 1, PROT_NONE,
			MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0);
	test_cases[3].pathname = bad_addr;
#endif

	memset(long_pathname, 'a', PATH_MAX + 1);

	SAFE_MKDIR(cleanup, TEST_DIR1, DIR_MODE);

	SAFE_TOUCH(cleanup, TEST_FILE3, FILE_MODE, NULL);

	SAFE_SYMLINK(cleanup, TEST_SYM1, TEST_SYM2);
	SAFE_SYMLINK(cleanup, TEST_SYM2, TEST_SYM1);

	rlim.rlim_cur = MAX_FSIZE;
	rlim.rlim_max = MAX_FSIZE;
	SAFE_SETRLIMIT(cleanup, RLIMIT_FSIZE, &rlim);

	sigemptyset(&signalset);
	sigaddset(&signalset, SIGXFSZ);
	TEST(sigprocmask(SIG_BLOCK, &signalset, NULL));
	if (TEST_RETURN != 0)
		tst_brkm(TBROK | TTERRNO, cleanup, "sigprocmask");
}
예제 #25
0
파일: access04.c 프로젝트: kraj/ltp
static void setup(void)
{
	struct passwd *pw;

	pw = SAFE_GETPWNAM("nobody");

	uid = pw->pw_uid;

	memset(longpathname, 'a', sizeof(longpathname) - 1);

	SAFE_TOUCH(FNAME1, 0333, NULL);
	SAFE_TOUCH(DNAME, 0644, NULL);

	SAFE_SYMLINK(SNAME1, SNAME2);
	SAFE_SYMLINK(SNAME2, SNAME1);
}
예제 #26
0
파일: access01.c 프로젝트: kraj/ltp
static void setup(void)
{
	struct passwd *pw;

	umask(0022);

	pw = SAFE_GETPWNAM("nobody");

	uid = pw->pw_uid;

	SAFE_TOUCH(FNAME_RWX, 0777, NULL);
	SAFE_TOUCH(FNAME_R, 0444, NULL);
	SAFE_TOUCH(FNAME_W, 0222, NULL);
	SAFE_TOUCH(FNAME_X, 0111, NULL);

	SAFE_MKDIR(DNAME_R, 0444);
	SAFE_MKDIR(DNAME_W, 0222);
	SAFE_MKDIR(DNAME_X, 0111);
	SAFE_MKDIR(DNAME_RW, 0666);
	SAFE_MKDIR(DNAME_RX, 0555);
	SAFE_MKDIR(DNAME_WX, 0333);

	SAFE_TOUCH(DNAME_R"/"FNAME_R, 0444, NULL);
	SAFE_TOUCH(DNAME_R"/"FNAME_W, 0222, NULL);
	SAFE_TOUCH(DNAME_R"/"FNAME_X, 0111, NULL);

	SAFE_TOUCH(DNAME_W"/"FNAME_R, 0444, NULL);
	SAFE_TOUCH(DNAME_W"/"FNAME_W, 0222, NULL);
	SAFE_TOUCH(DNAME_W"/"FNAME_X, 0111, NULL);

	SAFE_TOUCH(DNAME_X"/"FNAME_R, 0444, NULL);
	SAFE_TOUCH(DNAME_X"/"FNAME_W, 0222, NULL);
	SAFE_TOUCH(DNAME_X"/"FNAME_X, 0111, NULL);

	SAFE_TOUCH(DNAME_RW"/"FNAME_R, 0444, NULL);
	SAFE_TOUCH(DNAME_RW"/"FNAME_W, 0222, NULL);
	SAFE_TOUCH(DNAME_RW"/"FNAME_X, 0111, NULL);

	SAFE_TOUCH(DNAME_RX"/"FNAME_R, 0444, NULL);
	SAFE_TOUCH(DNAME_RX"/"FNAME_W, 0222, NULL);
	SAFE_TOUCH(DNAME_RX"/"FNAME_X, 0111, NULL);

	SAFE_TOUCH(DNAME_WX"/"FNAME_R, 0444, NULL);
	SAFE_TOUCH(DNAME_WX"/"FNAME_W, 0222, NULL);
	SAFE_TOUCH(DNAME_WX"/"FNAME_X, 0111, NULL);
}
예제 #27
0
파일: setuid04.c 프로젝트: kraj/ltp
static void setup(void)
{
	struct passwd *pw;
	uid_t uid;

	pw = SAFE_GETPWNAM("nobody");
	uid = pw->pw_uid;

	UID16_CHECK(uid, setuid);
	/* Create test file */
	SAFE_TOUCH(FILENAME, 0644, NULL);

	if (SETUID(uid) == -1) {
		tst_brk(TBROK,
			"setuid() failed to set the effective uid to %d", uid);
	}
}
예제 #28
0
static void setup(void)
{
    struct passwd *ltpuser;

    tst_require_root();

    tst_sig(NOFORK, DEF_HANDLER, cleanup);

    TEST_PAUSE;

    tst_tmpdir();

    SAFE_TOUCH(cleanup, TEST_FILE2, 0644, NULL);

    ltpuser = SAFE_GETPWNAM(cleanup, "nobody");

    SAFE_SETEUID(cleanup, ltpuser->pw_uid);
}
예제 #29
0
파일: linkat02.c 프로젝트: AbhiramiP/ltp
static void setup(void)
{
	if ((tst_kvercmp(2, 6, 16)) < 0)
		tst_brkm(TCONF, NULL, "This test needs kernel 2.6.16 or newer");

	tst_require_root(NULL);

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to acquire device");

	TEST_PAUSE;

	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");

	SAFE_TOUCH(cleanup, TEST_FILE, 0644, NULL);

	memset(nametoolong, 'a', PATH_MAX+1);

	SAFE_TOUCH(cleanup, TEST_EXIST, 0644, NULL);

	SAFE_SYMLINK(cleanup, TEST_ELOOP, "test_file_eloop2");
	SAFE_SYMLINK(cleanup, "test_file_eloop2", TEST_ELOOP);

	SAFE_MKDIR(cleanup, "./tmp", DIR_MODE);
	SAFE_TOUCH(cleanup, TEST_EACCES, 0666, NULL);

	tst_mkfs(cleanup, device, fs_type, NULL);
	SAFE_MKDIR(cleanup, "mntpoint", DIR_MODE);

	if (mount(device, "mntpoint", fs_type, 0, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag = 1;

	max_hardlinks = tst_fs_fill_hardlinks(cleanup, "emlink_dir");
}
예제 #30
0
파일: mknod07.c 프로젝트: AbhiramiP/ltp
static void setup(void)
{
	int i;
	struct passwd *ltpuser;
	const char *fs_type;

	tst_require_root(NULL);

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to acquire device");

	tst_mkfs(cleanup, device, fs_type, NULL);

	TEST_PAUSE;

	/* mount a read-only file system for EROFS test */
	SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);
	if (mount(device, MNT_POINT, fs_type, MS_RDONLY, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag = 1;

	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
	SAFE_SETEUID(cleanup, ltpuser->pw_uid);

	SAFE_MKDIR(cleanup, DIR_TEMP, DIR_TEMP_MODE);

	/*
	 * NOTE: the ELOOP test is written based on that the consecutive
	 * symlinks limits in kernel is hardwired to 40.
	 */
	SAFE_MKDIR(cleanup, "test_eloop", DIR_MODE);
	SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop");
	for (i = 0; i < 43; i++)
		strcat(elooppathname, ELOPFILE);
}