* [LTP] [PATCH] syscalls/chdir03: remove dependency on bin user
@ 2018-01-10 2:05 Steve Muckle
0 siblings, 0 replies; 3+ messages in thread
From: Steve Muckle @ 2018-01-10 2:05 UTC (permalink / raw)
To: ltp
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [LTP] [PATCH] syscalls/chdir03: remove dependency on bin user
@ 2018-02-01 19:07 Steve Muckle
2018-02-06 10:44 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Steve Muckle @ 2018-02-01 19:07 UTC (permalink / raw)
To: ltp
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [LTP] [PATCH] syscalls/chdir03: remove dependency on bin user
2018-02-01 19:07 Steve Muckle
@ 2018-02-06 10:44 ` Petr Vorel
0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2018-02-06 10:44 UTC (permalink / raw)
To: ltp
Hi,
> 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 = {
Pushed, thanks.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-06 10:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-10 2:05 [LTP] [PATCH] syscalls/chdir03: remove dependency on bin user Steve Muckle
-- strict thread matches above, loose matches on Subject: below --
2018-02-01 19:07 Steve Muckle
2018-02-06 10:44 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox