[PATCH 8/9] libcsupport: Minimal /etc/passwd and /etc/group
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Nov 14 13:46:34 UTC 2014
Create a minimal /etc/passwd and /etc/group with user root and group
root only with no passwords.
---
cpukit/libcsupport/src/pwdgrp.c | 14 +----
testsuites/psxtests/psxpasswd01/init.c | 44 +------------
testsuites/psxtests/psxpasswd01/psxpasswd01.scn | 82 +++++--------------------
3 files changed, 20 insertions(+), 120 deletions(-)
diff --git a/cpukit/libcsupport/src/pwdgrp.c b/cpukit/libcsupport/src/pwdgrp.c
index a531b8b..ab5e65b 100644
--- a/cpukit/libcsupport/src/pwdgrp.c
+++ b/cpukit/libcsupport/src/pwdgrp.c
@@ -59,22 +59,12 @@ static void pwdgrp_init(void)
/*
* Initialize /etc/passwd
*/
- init_file(
- "/etc/passwd",
- "root:*:0:0:root::/:/bin/sh\n"
- "rtems:*:1:1:RTEMS Application::/:/bin/sh\n"
- "tty:!:2:2:tty owner::/:/bin/false\n"
- );
+ init_file("/etc/passwd", "root::0:0:root:::\n");
/*
* Initialize /etc/group
*/
- init_file(
- "/etc/group",
- "root:x:0:root\n"
- "rtems:x:1:rtems\n"
- "tty:x:2:tty\n"
- );
+ init_file("/etc/group", "root::0:root\n");
}
void _libcsupport_pwdgrp_init(void)
diff --git a/testsuites/psxtests/psxpasswd01/init.c b/testsuites/psxtests/psxpasswd01/init.c
index cc618a5..3d877ea 100644
--- a/testsuites/psxtests/psxpasswd01/init.c
+++ b/testsuites/psxtests/psxpasswd01/init.c
@@ -98,17 +98,7 @@ rtems_task Init(
rtems_test_assert( pw );
print_passwd( pw );
- puts( "Init - getpwent() (2) -- OK" );
- pw = getpwent();
- rtems_test_assert( pw );
- print_passwd( pw );
-
- puts( "Init - getpwent() (3) -- OK" );
- pw = getpwent();
- rtems_test_assert( pw );
- print_passwd( pw );
-
- puts( "Init - getpwent() (4) -- result should be NULL" );
+ puts( "Init - getpwent() (2) -- result should be NULL" );
pw = getpwent();
rtems_test_assert( !pw );
@@ -119,17 +109,7 @@ rtems_task Init(
rtems_test_assert( gr );
print_group( gr );
- puts( "Init - getgrent() (2) -- OK" );
- gr = getgrent();
- rtems_test_assert( gr );
- print_group( gr );
-
- puts( "Init - getgrent() (3) -- OK" );
- gr = getgrent();
- rtems_test_assert( gr );
- print_group( gr );
-
- puts( "Init - getgrent() (4) -- result should be NULL" );
+ puts( "Init - getgrent() (2) -- result should be NULL" );
gr = getgrent();
rtems_test_assert( !gr );
@@ -139,11 +119,6 @@ rtems_task Init(
rtems_test_assert( pw );
print_passwd( pw );
- puts( "Init - getpwnam(\"rtems\") -- OK" );
- pw = getpwnam( "rtems" );
- rtems_test_assert( pw );
- print_passwd( pw );
-
puts( "Init - getpwnam(\"suser\") -- result should be NULL" );
pw = getpwnam( "suser" );
rtems_test_assert( !pw );
@@ -154,11 +129,6 @@ rtems_task Init(
rtems_test_assert( pw );
print_passwd( pw );
- puts( "Init - getpwuid(1) -- OK" );
- pw = getpwuid( 1 );
- rtems_test_assert( pw );
- print_passwd( pw );
-
puts( "Init - getpwuid(4) -- result should be NULL" );
pw = getpwuid( 4 );
rtems_test_assert( !pw );
@@ -169,22 +139,12 @@ rtems_task Init(
rtems_test_assert( gr );
print_group( gr );
- puts( "Init - getgrnam(\"rtems\") -- OK" );
- gr = getgrnam("rtems");
- rtems_test_assert( gr );
- print_group( gr );
-
/* getgrgid */
puts( "Init - getgrgid(0) -- OK" );
gr = getgrgid(0);
rtems_test_assert( gr );
print_group( gr );
- puts( "Init - getgrgid(1) -- OK" );
- gr = getgrgid(1);
- rtems_test_assert( gr );
- print_group( gr );
-
puts( "Init - getgrgid(4) -- result should be NULL");
gr = getgrgid( 4 );
rtems_test_assert( !gr );
diff --git a/testsuites/psxtests/psxpasswd01/psxpasswd01.scn b/testsuites/psxtests/psxpasswd01/psxpasswd01.scn
index a0d0a64..3a39643 100644
--- a/testsuites/psxtests/psxpasswd01/psxpasswd01.scn
+++ b/testsuites/psxtests/psxpasswd01/psxpasswd01.scn
@@ -1,99 +1,49 @@
-Initialized console on port COM1 9600-8-N-1
-
-*** PASSWORD/GROUP TEST - 01 ***
+*** BEGIN OF TEST PSXPASSWD 1 ***
Init - getpwent() -- OK, result should be NULL
Init - getgrent() -- OK, result should be NULL
Init - setpwent() -- OK
Init - setgrent() -- OK
Init - getpwent() (1) -- OK
username: root
- user password: *
+ user password:
user ID: 0
group ID: 0
real name:
- home directory: /
- shell program: /bin/sh
-Init - getpwent() (2) -- OK
- username: rtems
- user password: *
- user ID: 1
- group ID: 1
- real name:
- home directory: /
- shell program: /bin/sh
-Init - getpwent() (3) -- OK
- username: tty
- user password: !
- user ID: 2
- group ID: 2
- real name:
- home directory: /
- shell program: /bin/false
-Init - getpwent() (4) -- result should be NULL
+ home directory:
+ shell program:
+Init - getpwent() (2) -- result should be NULL
Init - getgrent() (1) -- OK
group name: root
- group password: x
+ group password:
group ID: 0
-Init - getgrent() (2) -- OK
- group name: rtems
- group password: x
- group ID: 1
-Init - getgrent() (3) -- OK
- group name: tty
- group password: x
- group ID: 2
-Init - getgrent() (4) -- result should be NULL
+Init - getgrent() (2) -- result should be NULL
Init - getpwnam("root") -- OK
username: root
- user password: *
+ user password:
user ID: 0
group ID: 0
real name:
- home directory: /
- shell program: /bin/sh
-Init - getpwnam("rtems") -- OK
- username: rtems
- user password: *
- user ID: 1
- group ID: 1
- real name:
- home directory: /
- shell program: /bin/sh
+ home directory:
+ shell program:
Init - getpwnam("suser") -- result should be NULL
Init - getpwuid(0) -- OK
username: root
- user password: *
+ user password:
user ID: 0
group ID: 0
real name:
- home directory: /
- shell program: /bin/sh
-Init - getpwuid(1) -- OK
- username: rtems
- user password: *
- user ID: 1
- group ID: 1
- real name:
- home directory: /
- shell program: /bin/sh
+ home directory:
+ shell program:
Init - getpwuid(4) -- result should be NULL
Init - getgrnam("root") -- OK
group name: root
- group password: x
+ group password:
group ID: 0
-Init - getgrnam("rtems") -- OK
- group name: rtems
- group password: x
- group ID: 1
Init - getgrgid(0) -- OK
group name: root
- group password: x
+ group password:
group ID: 0
-Init - getgrgid(1) -- OK
- group name: rtems
- group password: x
- group ID: 1
Init - getgrgid(4) -- result should be NULL
Init - endpwent() -- OK
Init - endgrent() -- OK
-*** END OF PASSWORD/GROUP TEST - 01 ***
+*** END OF TEST PSXPASSWD 1 ***
--
1.8.4.5
More information about the devel
mailing list