All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhangjin Wu <falcon@tinylab.org>
To: w@1wt.eu
Cc: thomas@t-8ch.de, arnd@arndb.de, falcon@tinylab.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH v1 10/17] selftests/nolibc: rename euid0 variable to is_root
Date: Wed, 21 Jun 2023 21:05:49 +0800	[thread overview]
Message-ID: <9547ea8320074269751eb4e54bcbd1395e66c5f5.1687344643.git.falcon@tinylab.org> (raw)
In-Reply-To: <cover.1687344643.git.falcon@tinylab.org>

More conditional variables will be added, let's rename them with more
meaningful 'has_' or 'is_' prefix.

euid0 is converted to is_root to indicate whether or not running as
root.

Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
 tools/testing/selftests/nolibc/nolibc-test.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 929d43b95acc..69f59a395746 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -543,7 +543,7 @@ int run_syscall(int min, int max)
 	struct timeval tv;
 	struct timezone tz;
 	struct stat stat_buf;
-	int euid0;
+	int is_root;
 	int has_proc;
 	int test;
 	int tmp;
@@ -555,7 +555,7 @@ int run_syscall(int min, int max)
 	has_proc = stat("/proc", &stat_buf) == 0;
 
 	/* this will be used to skip certain tests that can't be run unprivileged */
-	euid0 = geteuid() == 0;
+	is_root = geteuid() == 0;
 
 	/* from 2.30, glibc provides gettid() */
 #if defined(__GLIBC_MINOR__) && defined(__GLIBC__)
@@ -585,7 +585,7 @@ int run_syscall(int min, int max)
 		CASE_TEST(chmod_net);         EXPECT_SYSZR(has_proc, chmod("/proc/self/net", 0555)); break;
 		CASE_TEST(chmod_self);        EXPECT_SYSER(has_proc, chmod("/proc/self", 0555), -1, EPERM); break;
 		CASE_TEST(chown_self);        EXPECT_SYSER(has_proc, chown("/proc/self", 0, 0), -1, EPERM); break;
-		CASE_TEST(chroot_root);       EXPECT_SYSZR(euid0, chroot("/")); break;
+		CASE_TEST(chroot_root);       EXPECT_SYSZR(is_root, chroot("/")); break;
 		CASE_TEST(chroot_blah);       EXPECT_SYSER(1, chroot("/proc/self/blah"), -1, ENOENT); break;
 		CASE_TEST(chroot_exe);        EXPECT_SYSER(has_proc, chroot("/proc/self/exe"), -1, ENOTDIR); break;
 		CASE_TEST(close_m1);          EXPECT_SYSER(1, close(-1), -1, EBADF); break;
@@ -607,7 +607,7 @@ int run_syscall(int min, int max)
 		CASE_TEST(ioctl_tiocinq);     EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break;
 		CASE_TEST(link_root1);        EXPECT_SYSER(1, link("/", "/"), -1, EEXIST); break;
 		CASE_TEST(link_blah);         EXPECT_SYSER(1, link("/proc/self/blah", "/blah"), -1, ENOENT); break;
-		CASE_TEST(link_dir);          EXPECT_SYSER(euid0, link("/", "/blah"), -1, EPERM); break;
+		CASE_TEST(link_dir);          EXPECT_SYSER(is_root, link("/", "/blah"), -1, EPERM); break;
 		CASE_TEST(link_cross);        EXPECT_SYSER(has_proc, link("/proc/self/net", "/blah"), -1, EXDEV); break;
 		CASE_TEST(lseek_m1);          EXPECT_SYSER(1, lseek(-1, 0, SEEK_SET), -1, EBADF); break;
 		CASE_TEST(lseek_0);           EXPECT_SYSER(1, lseek(0, 0, SEEK_SET), -1, ESPIPE); break;
-- 
2.25.1


  parent reply	other threads:[~2023-06-21 13:06 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-21 12:52 [PATCH v1 00/17] selftests/nolibc: allow run with minimal kernel config Zhangjin Wu
2023-06-21 12:53 ` [PATCH v1 01/17] selftests/nolibc: stat_fault: silence NULL argument warning with glibc Zhangjin Wu
2023-06-21 12:54 ` [PATCH v1 02/17] selftests/nolibc: gettid: restore for glibc and musl Zhangjin Wu
2023-06-21 12:56 ` [PATCH v1 03/17] selftests/nolibc: add _LARGEFILE64_SOURCE for musl Zhangjin Wu
2023-06-21 12:57 ` [PATCH v1 04/17] selftests/nolibc: fix up kernel parameters support Zhangjin Wu
2023-06-21 12:58 ` [PATCH v1 05/17] selftests/nolibc: stat_timestamps: remove procfs dependency Zhangjin Wu
2023-06-28 13:59   ` Zhangjin Wu
2023-06-29 16:56     ` Thomas Weißschuh
2023-06-29 21:23       ` Zhangjin Wu
2023-06-29 21:44         ` Thomas Weißschuh
2023-06-21 13:00 ` [PATCH v1 06/17] tools/nolibc: add rmdir() support Zhangjin Wu
2023-06-21 13:01 ` [PATCH v1 07/17] selftests/nolibc: add a new rmdir() test case Zhangjin Wu
2023-06-21 13:03 ` [PATCH v1 08/17] selftests/nolibc: fix up failures when there is no procfs Zhangjin Wu
2023-06-21 13:04 ` [PATCH v1 09/17] selftests/nolibc: rename proc variable to has_proc Zhangjin Wu
2023-06-21 13:05 ` Zhangjin Wu [this message]
2023-06-21 13:07 ` [PATCH v1 11/17] selftests/nolibc: prepare tmpfs and hugetlbfs Zhangjin Wu
2023-06-21 13:09 ` [PATCH v1 12/17] selftests/nolibc: rename chmod_net to chmod_good Zhangjin Wu
2023-06-21 13:11 ` [PATCH v1 13/17] selftests/nolibc: link_cross: support tmpfs Zhangjin Wu
2023-06-21 13:13 ` [PATCH v1 14/17] selftests/nolibc: rename chroot_exe to chroot_file Zhangjin Wu
2023-06-21 13:17 ` [PATCH v1 15/17] selftests/nolibc: vfprintf: silence memfd_create() warning Zhangjin Wu
2023-06-21 13:18 ` [PATCH v1 16/17] selftests/nolibc: vfprintf: skip if neither tmpfs nor hugetlbfs Zhangjin Wu
2023-06-21 13:21 ` [PATCH v1 17/17] selftests/nolibc: vfprintf: support tmpfs and hugetlbfs Zhangjin Wu
2023-06-21 19:21 ` [PATCH v1 00/17] selftests/nolibc: allow run with minimal kernel config Thomas Weißschuh
2023-06-22 18:45   ` Zhangjin Wu
2023-06-24  6:52     ` Thomas Weißschuh
2023-06-24  7:29       ` Thomas Weißschuh
2023-06-24  8:39       ` Zhangjin Wu
2023-06-24  8:54     ` Zhangjin Wu

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=9547ea8320074269751eb4e54bcbd1395e66c5f5.1687344643.git.falcon@tinylab.org \
    --to=falcon@tinylab.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=thomas@t-8ch.de \
    --cc=w@1wt.eu \
    /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.