From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 3/3] syscalls/fchown: Convert fchown03 to the new API
Date: Tue, 25 May 2021 16:58:31 +0200 [thread overview]
Message-ID: <YK0Qlxbtyfci5b2z@pevik> (raw)
In-Reply-To: <20210506130950.110267-4-xieziyao@huawei.com>
Hi Ziyao,
Merged with these changes below. Thanks!
Kind regards,
Petr
diff --git testcases/kernel/syscalls/fchown/fchown03.c testcases/kernel/syscalls/fchown/fchown03.c
index a69ec86ae..752d9c394 100644
--- testcases/kernel/syscalls/fchown/fchown03.c
+++ testcases/kernel/syscalls/fchown/fchown03.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
+ * Copyright (c) Linux Test Project, 2001-2021
* Copyright (c) International Business Machines Corp., 2001
* 07/2001 Ported by Wayne Boyer
*/
@@ -10,7 +11,7 @@
* Verify that, fchown(2) succeeds to change the group of a file specified
* by path when called by non-root user with the following constraints:
*
- * - euid of the process is equal to the owner of the file;
+ * - euid of the process is equal to the owner of the file
* - the intended gid is either egid, or one of the supplementary gids
* of the process.
*
@@ -36,8 +37,7 @@ static struct passwd *ltpuser;
static void check_owner(struct stat *s, uid_t exp_uid, gid_t exp_gid)
{
if (s->st_uid != exp_uid || s->st_gid != exp_gid)
- tst_res(TFAIL, "%s: wrong owner set to (uid=%d, gid=%d),"
- " expected (uid=%d, gid=%d)",
+ tst_res(TFAIL, "%s: wrong owner set to (uid=%d, gid=%d), expected (uid=%d, gid=%d)",
FILENAME, s->st_uid, s->st_gid, exp_uid, exp_gid);
}
@@ -50,17 +50,18 @@ static void check_mode(struct stat *s, mode_t exp_mode)
static void run(void)
{
+ uid_t uid;
+ gid_t gid;
+ struct stat stat_buf;
+
SAFE_SETEUID(0);
SAFE_FCHOWN(fd, -1, 0);
SAFE_FCHMOD(fd, NEW_PERMS);
SAFE_SETEUID(ltpuser->pw_uid);
- uid_t uid;
- gid_t gid;
UID16_CHECK((uid = geteuid()), "fchown");
GID16_CHECK((gid = getegid()), "fchown");
- struct stat stat_buf;
SAFE_STAT(FILENAME, &stat_buf);
check_owner(&stat_buf, uid, 0);
check_mode(&stat_buf, NEW_PERMS);
prev parent reply other threads:[~2021-05-25 14:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-06 13:09 [LTP] [PATCH 0/3] syscalls/fchown: Convert fchown{01, 02, 03} to the new API Xie Ziyao
2021-05-06 13:09 ` [LTP] [PATCH 1/3] syscalls/fchown: Convert fchown01 " Xie Ziyao
2021-05-25 14:56 ` Petr Vorel
2021-05-06 13:09 ` [LTP] [PATCH 2/3] syscalls/fchown: Convert fchown02 " Xie Ziyao
2021-05-25 14:57 ` Petr Vorel
2021-05-06 13:09 ` [LTP] [PATCH 3/3] syscalls/fchown: Convert fchown03 " Xie Ziyao
2021-05-25 14:58 ` Petr Vorel [this message]
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=YK0Qlxbtyfci5b2z@pevik \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.