diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-11-14 14:30:36 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-11-20 10:30:22 +0100 |
commit | 002f351e152dd9495f678e6f761c7bfb421814aa (patch) | |
tree | 47fc3444a504d2d9490802f991350ca1ef542a61 /cpukit/libcsupport/src/pwdgrp.c | |
parent | libcsupport: Avoid TOCTOU and format errors (diff) | |
download | rtems-002f351e152dd9495f678e6f761c7bfb421814aa.tar.bz2 |
libcsupport: Minimal /etc/passwd and /etc/group
Create a minimal /etc/passwd and /etc/group with user root and group
root only with no passwords.
Diffstat (limited to 'cpukit/libcsupport/src/pwdgrp.c')
-rw-r--r-- | cpukit/libcsupport/src/pwdgrp.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/cpukit/libcsupport/src/pwdgrp.c b/cpukit/libcsupport/src/pwdgrp.c index a531b8b2ff..ea240975b4 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::::\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:\n"); } void _libcsupport_pwdgrp_init(void) @@ -265,9 +255,13 @@ int _libcsupport_scangr( /* * Determine number of members */ - for (cp = grmem, memcount = 1 ; *cp != 0 ; cp++) { - if(*cp == ',') - memcount++; + if (grmem[0] == '\0') { + memcount = 0; + } else { + for (cp = grmem, memcount = 1 ; *cp != 0 ; cp++) { + if(*cp == ',') + memcount++; + } } /* @@ -280,13 +274,18 @@ int _libcsupport_scangr( /* * Fill in pointer array */ - grp->gr_mem[0] = grmem; - for (cp = grmem, memcount = 1 ; *cp != 0 ; cp++) { - if(*cp == ',') { - *cp = '\0'; - grp->gr_mem[memcount++] = cp + 1; + if (grmem[0] == '\0') { + memcount = 0; + } else { + grp->gr_mem[0] = grmem; + for (cp = grmem, memcount = 1 ; *cp != 0 ; cp++) { + if(*cp == ',') { + *cp = '\0'; + grp->gr_mem[memcount++] = cp + 1; + } } } + grp->gr_mem[memcount] = NULL; return 1; } |