public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Steve Muckle <smuckle.linux@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/chdir03: remove dependency on bin user
Date: Thu,  1 Feb 2018 11:07:47 -0800	[thread overview]
Message-ID: <20180201190747.6981-1-smuckle.linux@gmail.com> (raw)

The bin user is not present on Android. Remove the dependency on it by
creating the test directory as root, since chdir03 already must be run
as root, and then attempt to chdir into it as nobody.

Signed-off-by: Steve Muckle <smuckle.linux@gmail.com>
---
 testcases/kernel/syscalls/chdir/chdir03.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/testcases/kernel/syscalls/chdir/chdir03.c b/testcases/kernel/syscalls/chdir/chdir03.c
index aa0720626ca5..12924664e682 100644
--- a/testcases/kernel/syscalls/chdir/chdir03.c
+++ b/testcases/kernel/syscalls/chdir/chdir03.c
@@ -22,10 +22,9 @@
  *	Testcase for testing that chdir(2) sets EACCES errno
  *
  * ALGORITHM
- *	1.	create a child process, sets its uid to ltpuser1
- *	2.	this child creates a directory with perm 700, and exits
- *	3.	create another child process, sets its uid to ltpuser2
- *	4.	this child attempts to chdir(2) to the directory created in 2.
+ *	1.	running as root, create a directory with perm 700
+ *	2.	create a child process, sets its uid to nobody
+ *	3.	this child attempts to chdir(2) to the directory created in 1
  *		and expects to get an EACCES.
  */
 
@@ -36,7 +35,7 @@
 
 #define DIRNAME "chdir03_dir"
 
-static uid_t nobody_uid, bin_uid;
+static uid_t nobody_uid;
 
 void verify_chdir(void)
 {
@@ -44,7 +43,7 @@ void verify_chdir(void)
 
 	pid = SAFE_FORK();
 	if (!pid) {
-		SAFE_SETUID(bin_uid);
+		SAFE_SETUID(nobody_uid);
 
 		TEST(chdir(DIRNAME));
 
@@ -66,20 +65,11 @@ void verify_chdir(void)
 void setup(void)
 {
 	struct passwd *pw;
-	pid_t pid;
 
 	pw = SAFE_GETPWNAM("nobody");
 	nobody_uid = pw->pw_uid;
-	pw = SAFE_GETPWNAM("bin");
-	bin_uid = pw->pw_uid;
 
-	pid = SAFE_FORK();
-	if (!pid) {
-		SAFE_SETEUID(nobody_uid);
-		SAFE_MKDIR(DIRNAME, 0700);
-		exit(0);
-	}
-	tst_reap_children();
+	SAFE_MKDIR(DIRNAME, 0700);
 }
 
 static struct tst_test test = {
-- 
2.13.6


             reply	other threads:[~2018-02-01 19:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-01 19:07 Steve Muckle [this message]
2018-02-06 10:44 ` [LTP] [PATCH] syscalls/chdir03: remove dependency on bin user Petr Vorel
  -- strict thread matches above, loose matches on Subject: below --
2018-01-10  2:05 Steve Muckle

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=20180201190747.6981-1-smuckle.linux@gmail.com \
    --to=smuckle.linux@gmail.com \
    --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