Пример #1
0
int main(int ac, char **av)
{
	int lc;
	const char *msg;

	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

	setup();

	TEST_EXP_ENOS(exp_enos);

	for (lc = 0; TEST_LOOPING(lc); lc++) {
		tst_count = 0;

		TEST(SETGID(cleanup, gid));

		if (TEST_RETURN == -1) {
			TEST_ERROR_LOG(TEST_ERRNO);
			tst_resm(TFAIL, "setgid(%d) Failed, errno=%d : %s", gid,
				 TEST_ERRNO, strerror(TEST_ERRNO));
		} else {
			tst_resm(TPASS, "setgid(%d) returned %ld", gid,
				 TEST_RETURN);
		}

	}

	cleanup();
	tst_exit();
}
Пример #2
0
int main(int ac, char **av)
{
	int lc;

	tst_parse_opts(ac, av, NULL, NULL);

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {
		tst_count = 0;

		TEST(SETGID(cleanup, gid));

		if (TEST_RETURN == -1) {
			tst_resm(TFAIL, "setgid(%d) Failed, errno=%d : %s", gid,
				 TEST_ERRNO, strerror(TEST_ERRNO));
		} else {
			tst_resm(TPASS, "setgid(%d) returned %ld", gid,
				 TEST_RETURN);
		}

	}

	cleanup();
	tst_exit();
}
Пример #3
0
int main(int ac, char **av)
{
	int lc;
	char *msg;

    /***************************************************************
     * parse standard options
     ***************************************************************/
	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

    /***************************************************************
     * perform global setup for test
     ***************************************************************/
	setup();

	/* set the expected errnos... */
	TEST_EXP_ENOS(exp_enos);

    /***************************************************************
     * check looping state if -c option given
     ***************************************************************/
	for (lc = 0; TEST_LOOPING(lc); lc++) {

		Tst_count = 0;

		/*
		 * Call setgid(2)
		 */
		TEST(SETGID(gid));

		/* check return code */
		if (TEST_RETURN == -1) {
			TEST_ERROR_LOG(TEST_ERRNO);
			tst_resm(TFAIL, "setgid(%d) Failed, errno=%d : %s", gid,
				 TEST_ERRNO, strerror(TEST_ERRNO));
		} else {
	    /***************************************************************
	     * only perform functional verification if flag set (-f not given)
	     ***************************************************************/
			if (STD_FUNCTIONAL_TEST) {
				/* No Verification test, yet... */
				tst_resm(TPASS, "setgid(%d) returned %ld", gid,
					 TEST_RETURN);
			}
		}

	}

    /***************************************************************
     * cleanup and exit
     ***************************************************************/
	cleanup();
	tst_exit();
	tst_exit();

}
Пример #4
0
int main(int ac, char **av)
{
	struct passwd *getpwnam(), *rootpwent;

	int lc;			/* loop counter */
	char *msg;		/* message returned by parse_opts */

	/* parse standard options */
	if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *)NULL) {
		tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
	 /*NOTREACHED*/}

	setup();

	TEST_EXP_ENOS(exp_enos);

	/* check looping state if -i option is given */
	for (lc = 0; TEST_LOOPING(lc); lc++) {
		/* reset Tst_count in case we are looping */
		Tst_count = 0;

		if ((rootpwent = getpwnam(root)) == NULL) {
			tst_brkm(TBROK, cleanup, "getpwnam failed for user id "
				 "%s", root);
		}

		if (!GID_SIZE_CHECK(rootpwent->pw_gid)) {
			tst_brkm(TBROK,
				 cleanup,
				 "gid for `%s' is too large for testing setgid16",
				 root);
		}

		TEST(SETGID(rootpwent->pw_gid));

		if (TEST_RETURN != -1) {
			tst_resm(TFAIL, "call succeeded unexpectedly");
			continue;
		}

		TEST_ERROR_LOG(TEST_ERRNO);

		if (TEST_ERRNO != EPERM) {
			tst_resm(TFAIL, "setgid set invalid errno, expected: "
				 "EPERM, got: %d\n", TEST_ERRNO);
		} else {
			tst_resm(TPASS, "setgid returned EPERM");
		}
	}
	cleanup();

	 /*NOTREACHED*/ return 0;
}
Пример #5
0
int main(int ac, char **av)
{
	struct passwd *getpwnam(), *rootpwent;
	int lc;
	const char *msg;

	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

	setup();

	TEST_EXP_ENOS(exp_enos);

	for (lc = 0; TEST_LOOPING(lc); lc++) {
		tst_count = 0;

		if ((rootpwent = getpwnam(root)) == NULL) {
			tst_brkm(TBROK, cleanup, "getpwnam failed for user id "
				 "%s", root);
		}

		GID16_CHECK(rootpwent->pw_gid, setgid, cleanup);

		TEST(SETGID(cleanup, rootpwent->pw_gid));

		if (TEST_RETURN != -1) {
			tst_resm(TFAIL, "call succeeded unexpectedly");
			continue;
		}

		TEST_ERROR_LOG(TEST_ERRNO);

		if (TEST_ERRNO != EPERM) {
			tst_resm(TFAIL, "setgid set invalid errno, expected: "
				 "EPERM, got: %d\n", TEST_ERRNO);
		} else {
			tst_resm(TPASS, "setgid returned EPERM");
		}
	}

	cleanup();
	tst_exit();
}