Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One of the mq_unlink01 testcase is failing #1092

Open
Mona-Bagare opened this issue Oct 9, 2023 · 1 comment
Open

One of the mq_unlink01 testcase is failing #1092

Mona-Bagare opened this issue Oct 9, 2023 · 1 comment

Comments

@Mona-Bagare
Copy link

Mona-Bagare commented Oct 9, 2023

In testcase 1:

void setup(void)
{
	euid = geteuid();
	pw = SAFE_GETPWNAM("nobody");
}
static void do_test(unsigned int i)
{
	struct test_case *tc = &tcase[i];
	mqd_t fd;

	tst_res(TINFO, "queue name %s", tc->qname);

	/*
	 * When test ended with SIGTERM etc, mq descriptor is left remains.
	 * So we delete it first.
	 */
	mq_unlink(QUEUE_NAME);

	/* prepare */
	fd = SAFE_MQ_OPEN(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, S_IRWXU, NULL);

	if (tc->as_nobody && seteuid(pw->pw_uid)) {
		tst_res(TFAIL | TERRNO, "seteuid failed");
		goto EXIT;
	}


seteuid(pw->pw_uid) is supposed to change the owner to "nobody", but still "root" is executing as owner and as a result testcase is failing.
Below is the snapshot of execution record:

tst.c:1558: TINFO: Timeout per run is 0h 20m 00s
mq_unlink01.c:76: TINFO: queue name /test_mqueue
mq_unlink01.c:99: TPASS: mq_unlink returned 0: SUCCESS (0)
mq_unlink01.c:76: TINFO: queue name /test_mqueue
mq_unlink01.c:95: TFAIL: mq_unlink returned 0, expected -1, expected errno EACCES (13): SUCCESS (0)
mq_unlink01.c:76: TINFO: queue name /aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
mq_unlink01.c:99: TPASS: mq_unlink returned -1: ENOENT (2)
mq_unlink01.c:76: TINFO: queue name /aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
mq_unlink01.c:99: TPASS: mq_unlink returned -1: ENAMETOOLONG (36)
Summary:
passed 3
failed 1
broken 0
skipped 0
warnings 0
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=exited termination_id=1 corefile=no
cutime=0 cstime=0
<<<test_end>>>
INFO: ltp-pan reported some tests FAIL
LTP Version: 20230127

Please suggest the solution

@Martchus
Copy link
Contributor

Martchus commented Oct 9, 2023

I can't reproduce the problem on my Tumbleweed system.

seteuid(pw->pw_uid) is supposed to change the owner to "nobody"

This call is supposed to change the effective user to "nobody". This should provoke an access error when trying to unlink the message queue that is still owned by root (although maybe the permissions/ownership of the parent directory might be relevant as well).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants