From: zhaogongyi <zhaogongyi@huawei.com>
To: Petr Vorel <pvorel@suse.cz>, Cyril Hrubis <chrubis@suse.cz>
Cc: "ltp@lists.linux.it" <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v3 1/1] setgroups03: Fix running more iterations (-i 2)
Date: Thu, 14 Oct 2021 02:44:31 +0000 [thread overview]
Message-ID: <f8b7b489dc604bdd9a371e4a6028f693@huawei.com> (raw)
Hi,
Yes, in this testcase, the groups_list is redundant and can be removed.
I am sorry for my late reply.
Thanks so much!
> > > -int setup1(void)
> > > +void setup1(const char *uid, uid_t euid)
> > > {
> > > - struct passwd *user_info; /* struct. to hold test user info */
> > > -
> > > -/* Switch to nobody user for correct error code collection */
> > > - ltpuser = getpwnam(nobody_uid);
> > > - if (seteuid(ltpuser->pw_uid) == -1) {
> > > - tst_resm(TINFO, "setreuid failed to "
> > > - "to set the effective uid to %d", ltpuser->pw_uid);
> > > - perror("setreuid");
> > > - }
> > > + struct passwd *user_info;
>
> > > - if ((user_info = getpwnam(TESTUSER)) == NULL) {
> > > - tst_brkm(TFAIL, cleanup, "getpwnam(2) of %s Failed",
> TESTUSER);
> > > - }
> > > + SAFE_SETEUID(cleanup, euid);
> > > +
> > > + user_info = SAFE_GETPWNAM(cleanup, uid);
>
> > I still do not get why we call SAFE_GETPWNAM() here. We should do that
> > in the setup and prepare two different group_list[] lists, if that is
> > really needed.
>
> > But I guess that all we need in this test is:
>
> > * Run the EINVAL test as a root
>
> > * Run the EPERM test as a nobody
>
> > The content of the list should not matter, as a matter of a fact we
> > pass unitialized data in the EINVAL case. What matters is the size
> > argument, it should be 1 for the EPERM test and max+1 for the EINVAL
> case.
>
> Good point, thank you!
>
> @Zhao feel free to let me know you're doing to implement it.
> Otherwise I'll have look on Monday.
>
> Kind regards,
> Petr
>
> > > if (!GID_SIZE_CHECK(user_info->pw_gid)) {
> > > tst_brkm(TBROK,
> > > cleanup,
> > > "gid returned from getpwnam is too large for testing
> setgroups16");
> > > }
> > > +
> > > groups_list[0] = user_info->pw_gid;
> > > - return 0;
> > > }
>
> > > /*
> > > --
> > > 2.33.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2021-10-14 2:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-14 2:44 zhaogongyi [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-10-14 6:47 [LTP] [PATCH v3 1/1] setgroups03: Fix running more iterations (-i 2) zhaogongyi
2021-10-08 10:00 Petr Vorel
2021-10-08 10:23 ` Cyril Hrubis
2021-10-08 11:12 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f8b7b489dc604bdd9a371e4a6028f693@huawei.com \
--to=zhaogongyi@huawei.com \
--cc=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox