From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/2] Update syscalls/bind02 to new API
Date: Mon, 23 Sep 2019 18:11:32 +0200 [thread overview]
Message-ID: <20190923161131.GA4779@dell5510> (raw)
In-Reply-To: <20190919145911.22278-2-mdoucha@suse.cz>
Hi Martin,
> Signed-off-by: Martin Doucha <mdoucha@suse.cz>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Apart from unimportant nit style formatting which can be changed
by maintainer before import this is nice.
Although it'd be perfectly safe to merge it I guess we wait after LTP release.
> testcases/kernel/syscalls/bind/bind02.c | 153 +++++++-----------------
...
> + if (!TST_RET) {
> + tst_res(TFAIL, "bind() succeeded unexpectedly.");
Please, don't use dot.
> + } else if (TST_ERR == EACCES) {
> + tst_res(TPASS, "bind() failed as expected");
> + } else {
> + tst_res(TFAIL | TERRNO, "Unexpected error");
> }
> -
> }
> -int main(int argc, char *argv[])
> +void setup(void)
> {
> - char *username = "nobody";
> -
> - tst_parse_opts(argc, argv, NULL, NULL);
> + struct passwd *pw;
> + struct group *gr;
> - tst_require_root();
> + pw = SAFE_GETPWNAM(TEST_USERNAME);
> + gr = SAFE_GETGRGID(pw->pw_gid);
> - if ((pw = getpwnam(username)) == NULL) {
> - tst_brkm(TBROK, 0, "Username - %s - not found", username);
> - }
> -
> - if ((gr = getgrgid(pw->pw_gid)) == NULL) {
> - tst_brkm(TBROK | TERRNO, 0, "getgrgid(%u) failed", pw->pw_gid);
> - }
> -
> - uid = pw->pw_uid;
> - gid = gr->gr_gid;
> -
> - tst_resm(TINFO, "Socket will try to be bind by user: %s, group: %s",
> - pw->pw_name, gr->gr_name);
> + tst_res(TINFO, "Switching credentials to user: %s, group: %s",
> + pw->pw_name, gr->gr_name);
> + SAFE_SETEGID(gr->gr_gid);
> + SAFE_SETEUID(pw->pw_uid);
> +}
> - try_bind();
> - tst_exit();
> +void cleanup(void) {
Bracket should be on separate line.
> + SAFE_SETEGID(0);
> + SAFE_SETEUID(0);
> }
Kind regards,
Petr
next prev parent reply other threads:[~2019-09-23 16:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 14:59 [LTP] [PATCH 0/2] Increase bind() converage - GH#538 Martin Doucha
2019-09-19 14:59 ` [LTP] [PATCH 1/2] Update syscalls/bind02 to new API Martin Doucha
2019-09-23 16:11 ` Petr Vorel [this message]
2019-09-19 14:59 ` [LTP] [PATCH 2/2] Add connection tests for bind() Martin Doucha
2019-09-23 17:02 ` 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=20190923161131.GA4779@dell5510 \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
/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