From: Cyril Hrubis <chrubis@suse.cz>
To: tangmeng <tangmeng@uniontech.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 2/2] getuid/getuid03: Convert to new API
Date: Wed, 10 Nov 2021 12:06:17 +0100 [thread overview]
Message-ID: <YYunqaGXPcPfPvNc@yuki> (raw)
In-Reply-To: <20211109085745.21531-2-tangmeng@uniontech.com>
Hi!
> +static void verify_getuid(void)
> {
> struct passwd *pwent;
> - int lc;
> uid_t uid;
>
> - tst_parse_opts(ac, av, NULL, NULL);
> -
> - setup();
> + TEST(GETUID());
>
> - for (lc = 0; TEST_LOOPING(lc); lc++) {
> + if (TST_RET == -1)
> + tst_brk(TBROK | TTERRNO, "getuid failed");
>
> - tst_count = 0;
> + uid = getuid();
We have the return from getuid() stored in TST_RET at this point, why do
we call it again here?
> + pwent = getpwuid(uid);
>
> - TEST(GETUID(cleanup));
> + if (pwent == NULL)
> + tst_res(TFAIL | TERRNO, "getpwuid failed");
I guess that we should exit the test here, otherwise it will segfault,
so this should be tst_brk(TBROK | TERRNO, ...);
Also I do wonder if comparing the return from getuid() to the return
from getpwuid(getguid()) makes any sense. We lookup password entry given
an uid then check that the password entry uid matches. That sounds like
a test for getpwuid() more than anything else.
I wonder what would be better check. We should rather than this check
the return value against the /proc/self/status where all the UIDs are
listed as well.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2021-11-10 11:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-09 8:57 [LTP] [PATCH 1/2] getuid/getuid01: Convert to new API tangmeng
2021-11-09 8:57 ` [LTP] [PATCH 2/2] getuid/getuid03: " tangmeng
2021-11-10 11:06 ` Cyril Hrubis [this message]
2021-11-10 10:44 ` [LTP] [PATCH 1/2] getuid/getuid01: " Cyril Hrubis
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=YYunqaGXPcPfPvNc@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=tangmeng@uniontech.com \
/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