Esempio n. 1
0
File: rename09.c Progetto: 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());
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
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");
}
Esempio n. 4
0
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;
}
Esempio n. 5
0
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;
}
Esempio n. 6
0
File: acct01.c Progetto: 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;
}
Esempio n. 7
0
File: access03.c Progetto: 1587/ltp
static void setup(void)
{
	struct passwd *pw;

	pw = SAFE_GETPWNAM("nobody");

	uid = pw->pw_uid;
}
Esempio n. 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();
}
Esempio n. 9
0
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);
}
Esempio n. 10
0
File: mkdir04.c Progetto: 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);
}
Esempio n. 11
0
static void setup(void)
{
	struct passwd *pw;

	tst_require_root(NULL);

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

	TEST_PAUSE;
}
Esempio n. 12
0
File: shmat02.c Progetto: 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");
}
Esempio n. 13
0
static void setup(void)
{
	tst_require_root(NULL);

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	tst_tmpdir();

	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
}
Esempio n. 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);
}
Esempio n. 15
0
File: acct01.c Progetto: 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);
	}
}
Esempio n. 16
0
File: mkdir04.c Progetto: 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);
}
Esempio n. 17
0
File: access05.c Progetto: 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);
}
Esempio n. 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;
}
Esempio n. 19
0
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);
}
Esempio n. 20
0
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);
}
Esempio n. 21
0
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());
}
Esempio n. 22
0
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)
}
Esempio n. 23
0
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");
}
Esempio n. 24
0
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");
}
Esempio n. 25
0
File: access04.c Progetto: 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);
}
Esempio n. 26
0
File: access01.c Progetto: 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);
}
Esempio n. 27
0
File: setuid04.c Progetto: 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);
	}
}
Esempio n. 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);
}
Esempio n. 29
0
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");
}
Esempio n. 30
0
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);
}