static void setup(void) { SAFE_TOUCH(filename[0], 0644, NULL); SAFE_TOUCH(filename[1], 0644, NULL); SAFE_LSETXATTR(filename[1], SECURITY_KEY, VALUE, VALUE_SIZE, XATTR_CREATE); }
static void setup(void) { int i; const char *fs_type; tst_require_root(); 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 acquire device"); tst_mkfs(cleanup, device, fs_type, NULL, 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); } SAFE_MKDIR(cleanup, TESTDIR5, DIR_MODE); if (mount(device, MNTPOINT, fs_type, MS_REMOUNT | MS_RDONLY, NULL) == -1) { tst_brkm(TBROK | TERRNO, cleanup, "mount device:%s failed", device); } mount_flag = 1; SAFE_MKDIR(cleanup, TESTDIR, DIR_MODE); SAFE_TOUCH(cleanup, TESTFILE, FILE_MODE, NULL); memset(longpathname, 'a', PATH_MAX + 1); SAFE_TOUCH(cleanup, TESTFILE2, FILE_MODE, NULL); #if !defined(UCLINUX) test_cases[4].dir = SAFE_MMAP(cleanup, 0, 1, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); #endif /* * NOTE: the ELOOP test is written based on that the * consecutive symlinks limit in kernel is hardwired * to 40. */ SAFE_MKDIR(cleanup, "loopdir", DIR_MODE); SAFE_SYMLINK(cleanup, "../loopdir", "loopdir/loopdir"); for (i = 0; i < 43; i++) strcat(looppathname, TESTDIR4); }
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); }
static void do_test(void) { int fd, ret, status; pid_t child; char buf[FS_BLOCKSIZE]; SAFE_TOUCH(cleanup, "testfilep", 0644, NULL); SAFE_TOUCH(cleanup, "testfilec", 0644, NULL); child = tst_fork(); switch (child) { case -1: tst_brkm(TBROK | TERRNO, cleanup, "fork failed"); case 0: do_child(); default: fd = SAFE_OPEN(cleanup, "testfilep", O_RDWR); memset(buf, 'a', FS_BLOCKSIZE); TST_SAFE_CHECKPOINT_WAIT(cleanup, 0); while (1) { ret = write(fd, buf, FS_BLOCKSIZE); if (ret < 0) { if (errno == ENOSPC) { break; } else { tst_brkm(TBROK | TERRNO, cleanup, "write failed unexpectedly"); } } } SAFE_CLOSE(cleanup, fd); TST_SAFE_CHECKPOINT_WAKE(cleanup, 0); } wait(&status); if (WIFEXITED(status) && WEXITSTATUS(status) == 1) { bug_reproduced = 1; } else { /* * If child process was killed by SIGBUS, bug is not reproduced. */ if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGBUS) { tst_brkm(TBROK | TERRNO, cleanup, "child process terminate unexpectedly"); } } SAFE_UNLINK(cleanup, "testfilep"); SAFE_UNLINK(cleanup, "testfilec"); }
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"); }
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); }
static void setup(void) { tst_sig(FORK, DEF_HANDLER, cleanup); tst_require_root(NULL); tst_tmpdir(); SAFE_TOUCH(cleanup, file, FILE_MODE, NULL); 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); memset(path, 'a', PATH_MAX + 1); if (mknod(char_dev, S_IFCHR | FILE_MODE, 0)) { tst_brkm(TBROK | TERRNO, cleanup, "failed to mknod(char_dev, S_IFCHR | FILE_MODE, 0)"); } TEST_PAUSE; }
static void setup(void) { struct stat c_buf, l_buf; 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); TEST_PAUSE; tst_tmpdir(); dirfd = SAFE_OPEN(cleanup, "./", O_DIRECTORY); SAFE_TOUCH(cleanup, TESTFILE, 0600, NULL); SAFE_SYMLINK(cleanup, TESTFILE, TESTFILE_LINK); SAFE_STAT(cleanup, TESTFILE_LINK, &c_buf); SAFE_LSTAT(cleanup, TESTFILE_LINK, &l_buf); if (l_buf.st_uid == set_uid || l_buf.st_gid == set_gid) { tst_brkm(TBROK | TERRNO, cleanup, "link_uid(%d) == set_uid(%d) or link_gid(%d) == " "set_gid(%d)", l_buf.st_uid, set_uid, l_buf.st_gid, set_gid); } }
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); }
static void setup(void) { SAFE_TOUCH(FILENAME, 0644, NULL); fd = SAFE_OPEN(FILENAME, O_RDONLY, NULL); SAFE_FSETXATTR(fd, XATTR_TEST_KEY, XATTR_TEST_VALUE, XATTR_TEST_VALUE_SIZE, XATTR_CREATE); }
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"); }
static void setup(void) { SAFE_TOUCH("testfile", 0644, NULL); SAFE_SYMLINK("testfile", "symlink"); set_xattr("testfile", SECURITY_KEY1); set_xattr("symlink", SECURITY_KEY2); }
static void setup(void) { tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; tst_tmpdir(); sprintf(fname, "%s_%d", BASENAME, getpid()); SAFE_TOUCH(cleanup, fname, 0700, NULL); }
static void setup(void) { if ((tst_kvercmp(3, 15, 0)) < 0) { tst_brkm(TCONF, NULL, "This test can only run on kernels that are 3.15. and higher"); } tst_tmpdir(); fs_type = tst_fs_type(cleanup, "."); SAFE_MKDIR(cleanup, TEST_DIR, 0700); SAFE_MKDIR(cleanup, TEST_DIR2, 0700); SAFE_TOUCH(cleanup, TEST_DIR TEST_FILE, 0600, NULL); SAFE_TOUCH(cleanup, TEST_DIR2 TEST_FILE2, 0600, NULL); SAFE_TOUCH(cleanup, TEST_DIR TEST_FILE3, 0600, NULL); olddirfd = SAFE_OPEN(cleanup, TEST_DIR, O_DIRECTORY); newdirfd = SAFE_OPEN(cleanup, TEST_DIR2, O_DIRECTORY); }
static void setup(void) { int i; const char *fs_type; tst_require_root(NULL); tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_EXP_ENOS(exp_enos); TEST_PAUSE; tst_tmpdir(); fs_type = tst_dev_fs_type(); device = tst_acquire_device(cleanup); if (!device) tst_brkm(TCONF, cleanup, "Failed to acquire device"); memset(long_dir, 'a', PATH_MAX+1); SAFE_TOUCH(cleanup, TST_EEXIST, MODE, NULL); SAFE_TOUCH(cleanup, "tst_enotdir", MODE, NULL); SAFE_MKDIR(cleanup, "test_eloop", DIR_MODE); SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop"); for (i = 0; i < 43; i++) strcat(loop_dir, "/test_eloop"); tst_mkfs(cleanup, device, fs_type, NULL); 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; }
static void do_child(void) { unsigned int i = 0; char c_name[PATH_MAX] = "testfile", n_name[PATH_MAX]; SAFE_TOUCH(NULL, c_name, 0644, NULL); while (1) { snprintf(n_name, PATH_MAX, "testfile%u", i++); SAFE_RENAME(NULL, c_name, n_name); strncpy(c_name, n_name, PATH_MAX); } }
void setup(void) { struct passwd *ltpuser; char *bad_addr; tst_sig(NOFORK, DEF_HANDLER, cleanup); tst_require_root(NULL); 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); }
void setup(void) { struct passwd *ltpuser; int i; tst_require_root(NULL); tst_sig(NOFORK, DEF_HANDLER, cleanup); ltpuser = SAFE_GETPWNAM(cleanup, "nobody"); SAFE_SETEUID(cleanup, ltpuser->pw_uid); TEST_PAUSE; tst_tmpdir(); SAFE_MKDIR(cleanup, DIR_TEMP, MODE_RWX); SAFE_TOUCH(cleanup, TEST_FILE1, 0666, NULL); SAFE_SYMLINK(cleanup, TEST_FILE1, SYM_FILE1); SAFE_CHMOD(cleanup, DIR_TEMP, FILE_MODE); SAFE_TOUCH(cleanup, TEST_FILE2, 0666, NULL); SAFE_SYMLINK(cleanup, TEST_FILE2, SYM_FILE2); memset(longpathname, 'a', PATH_MAX + 1); SAFE_TOUCH(cleanup, TEST_FILE3, 0666, NULL); /* * NOTE: the ELOOP test is written based on that the consecutive * symlinks limit in kernel is hardwired to 40. */ SAFE_MKDIR(cleanup, "test_eloop", MODE_RWX); SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop"); for (i = 0; i < 43; i++) strcat(elooppathname, ELOOPFILE); }
static void setup(void) { if ((tst_kvercmp(2, 6, 39)) < 0) { tst_brkm(TCONF, NULL, "This test can only run on kernels " "that are 2.6.39 or higher"); } tst_sig(NOFORK, DEF_HANDLER, cleanup); tst_tmpdir(); SAFE_TOUCH(cleanup, TESTFILE, FILE_MODE, NULL); TEST_PAUSE; }
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_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; tst_tmpdir(); dir_fd = SAFE_OPEN(cleanup, "./", O_DIRECTORY); SAFE_TOUCH(cleanup, TESTFILE, 0600, NULL); fd = SAFE_OPEN(cleanup, "testfile2", O_CREAT | O_RDWR, 0600); }
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); } }
/* * setup() - performs all ONE TIME setup for this test. */ void setup(void) { tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; /* Create a temporary directory and make it current. */ tst_tmpdir(); sprintf(fdir, "./tdir_%d", getpid()); sprintf(mdir, "./rndir_%d", getpid()); sprintf(tstfile, "%s/tstfile_%d", mdir, getpid()); /* create "old" directory */ if (mkdir(fdir, 00770) == -1) { tst_brkm(TBROK, cleanup, "Could not create directory %s", fdir); } if (stat(fdir, &buf1) == -1) { tst_brkm(TBROK, cleanup, "failed to stat directory %s" "in rename()", fdir); } /* save "old"'s dev and ino */ olddev = buf1.st_dev; oldino = buf1.st_ino; /* create another directory */ if (mkdir(mdir, 00770) == -1) { tst_brkm(TBROK, cleanup, "Could not create directory %s", mdir); } SAFE_TOUCH(cleanup, tstfile, 0700, NULL); if (stat(mdir, &buf2) == -1) { tst_brkm(TBROK, cleanup, "failed to stat directory %s " "in rename()", mdir); } /* save "new"'s dev and ino */ olddev1 = buf2.st_dev; oldino1 = buf2.st_ino; }
static void setup(void) { tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; tst_tmpdir(); SAFE_SYMLINK(cleanup, TEST_SYMLINK, "statfs_symlink_2"); SAFE_SYMLINK(cleanup, "statfs_symlink_2", TEST_SYMLINK); memset(nametoolong, 'a', PATH_MAX+1); SAFE_TOUCH(cleanup, TEST_FILE, 0644, NULL); test_cases[0].path = SAFE_MMAP(cleanup, NULL, 1, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 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); }
static void setup(void) { int i; tst_sig(NOFORK, DEF_HANDLER, cleanup); tst_require_root(NULL); tst_tmpdir(); TEST_EXP_ENOS(exp_enos); TEST_PAUSE; 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, 0755); if (mount(device, MNTPOINT, fs_type, 0, NULL) < 0) { tst_brkm(TBROK | TERRNO, cleanup, "mount device:%s failed", device); } mount_flag = 1; SAFE_TOUCH(cleanup, TEST_EROFS, 0644, NULL); SAFE_MKDIR(cleanup, TEST_EMLINK, 0755); max_subdirs = tst_fs_fill_subdirs(cleanup, "emlink_dir"); /* * NOTE: the ELOOP test is written based on that the consecutive * symlinks limits in kernel is hardwired to 40. */ SAFE_MKDIR(cleanup, "test_eloop", 0644); SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop"); for (i = 0; i < 43; i++) strcat(elooppathname, ELOPFILE); }
static void setup(void) { int i; const char *fs_type; tst_require_root(); 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 acquire device"); SAFE_MKDIR(cleanup, TEST_FILE1, DIR_MODE); SAFE_MKDIR(cleanup, "test_eloop", DIR_MODE); SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop"); for (i = 0; i < 43; i++) strcat(test_file4, "/test_eloop"); tst_mkfs(cleanup, device, fs_type, NULL); SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE); if (mount(device, MNT_POINT, fs_type, 0, NULL) < 0) { tst_brkm(TBROK | TERRNO, cleanup, "mount device:%s failed", device); } mount_flag = 1; SAFE_TOUCH(cleanup, TEST_FILE2, 0644, NULL); if (mount(device, MNT_POINT, fs_type, MS_REMOUNT | MS_RDONLY, NULL) < 0) { tst_brkm(TBROK | TERRNO, cleanup, "mount device:%s failed", device); } }
static void setup(void) { tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; tst_tmpdir(); switch ((type = tst_fs_type(cleanup, "."))) { case TST_NFS_MAGIC: case TST_RAMFS_MAGIC: case TST_TMPFS_MAGIC: tst_brkm(TCONF, cleanup, "Cannot do fcntl(F_SETLEASE, F_WRLCK) " "on %s filesystem", tst_fs_type_name(type)); default: break; } SAFE_TOUCH(cleanup, "file", FILE_MODE, NULL); }
static void setup(void) { ltpuser = SAFE_GETPWNAM("nobody"); SAFE_MKDIR(TEST_FILE, MODE2); memset(long_name, 'a', PATH_MAX+1); SAFE_TOUCH("file1", MODE1, NULL); SAFE_MKDIR("dir6", MODE2); SAFE_SYMLINK(TEST7_FILE, "test_file_eloop2"); SAFE_SYMLINK("test_file_eloop2", TEST7_FILE); SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, NULL); SAFE_MKDIR("mntpoint", 0777); SAFE_MOUNT(tst_device->dev, "mntpoint", tst_device->fs_type, MS_RDONLY, NULL); mount_flag = 1; }
static void setresgid_verify(void) { struct stat buf; TEST(SETRESGID(cleanup, -1, ltpuser->pw_gid, -1)); if (TEST_RETURN != 0) { tst_resm(TFAIL | TTERRNO, "setresgid failed unexpectedly"); return; } SAFE_TOUCH(cleanup, "test_file", 0644, NULL); SAFE_STAT(cleanup, "test_file", &buf); if (ltpuser->pw_gid == buf.st_gid) { tst_resm(TPASS, "setresgid succeeded as expected"); } else { tst_resm(TFAIL, "setresgid failed unexpectedly; egid(%d) - st_gid(%d)", ltpuser->pw_gid, buf.st_gid); } }
static void setup(void) { tst_sig(FORK, DEF_HANDLER, cleanup); tst_require_root(); tst_timer_check(CLOCK_MONOTONIC); /* Backup and set the lease-break-time. */ SAFE_FILE_SCANF(NULL, PATH_LS_BRK_T, "%d", &ls_brk_t); SAFE_FILE_PRINTF(NULL, PATH_LS_BRK_T, "%d", 45); tst_tmpdir(); switch ((type = tst_fs_type(cleanup, "."))) { case TST_NFS_MAGIC: case TST_RAMFS_MAGIC: case TST_TMPFS_MAGIC: tst_brkm(TCONF, cleanup, "Cannot do fcntl(F_SETLEASE, F_WRLCK) " "on %s filesystem", tst_fs_type_name(type)); default: break; } SAFE_TOUCH(cleanup, "file", FILE_MODE, NULL); sigemptyset(&newset); sigaddset(&newset, SIGIO); if (sigprocmask(SIG_SETMASK, &newset, &oldset) < 0) tst_brkm(TBROK | TERRNO, cleanup, "sigprocmask() failed"); TEST_PAUSE; }