Index: c/src/exec/libcsupport/src/getgrent.c
===================================================================
--- c/src/exec/libcsupport/src/getgrent.c	(revision c51917f304dbea16877ad328da2d45512b751796)
+++ c/src/exec/libcsupport/src/getgrent.c	(revision a0a225f4aaa36461554db637edf24291acb17da6)
@@ -1,5 +1,12 @@
 /*
+ *  POSIX 1003.1b - 9.2.1 - Group Database Access Routines
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.OARcorp.com/rtems/license.html.
+ *
  *  $Id$
  */
+
 
 #include <stdio.h>
@@ -15,8 +22,17 @@
 static FILE *group_fp;
 
+/*
+ *  The size of these buffers is arbitrary and there is no provision
+ *  to protect any of them from overflowing.  The scanf patterns
+ *  need to be changed to prevent overflowing.  In addition,
+ *  the limits on these needs to be examined.
+ */
+
 static char groupname[8];
 static char password[1024];
 static char groups[1024];
 static char *gr_mem[16] = { } ;
+
+extern void init_etc_passwd_group(void);
 
 int getgrnam_r(
@@ -29,4 +45,6 @@
 {
   FILE *fp;
+
+  init_etc_passwd_group();
 
   if ((fp = fopen ("/etc/group", "r")) == NULL) {
@@ -76,4 +94,6 @@
 {
   FILE *fp;
+
+  init_etc_passwd_group();
 
   if ((fp = fopen ("/etc/group", "r")) == NULL) {
@@ -138,4 +158,6 @@
 setgrent ()
 {
+  init_etc_passwd_group();
+
   if (group_fp != NULL)
     fclose (group_fp);
Index: c/src/exec/libcsupport/src/getpwent.c
===================================================================
--- c/src/exec/libcsupport/src/getpwent.c	(revision c51917f304dbea16877ad328da2d45512b751796)
+++ c/src/exec/libcsupport/src/getpwent.c	(revision a0a225f4aaa36461554db637edf24291acb17da6)
@@ -1,2 +1,12 @@
+/*
+ *  POSIX 1003.1b - 9.2.2 - User Database Access Routines
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.OARcorp.com/rtems/license.html.
+ *
+ *  $Id$
+ */
+
 #include <stdio.h>
 #include <sys/types.h>
@@ -7,7 +17,16 @@
 #include <string.h>
 #include <limits.h>
+#include <fcntl.h>
+#include <unistd.h>
 
 static struct passwd pw_passwd;  /* password structure */
 static FILE *passwd_fp;
+
+/*
+ *  The size of these buffers is arbitrary and there is no provision
+ *  to protect any of them from overflowing.  The scanf patterns
+ *  need to be changed to prevent overflowing.  In addition,
+ *  the limits on these needs to be examined.
+ */
 
 static char logname[8];
@@ -18,4 +37,48 @@
 static char shell[1024];
 
+/*
+ *  Initialize a useable but dummy /etc/passwd
+ *
+ *  NOTE: Ignore all errors.
+ *
+ */
+
+static char etc_passwd_initted = 0;
+
+void init_etc_passwd_group(void)
+{
+  FILE *fp;
+
+  if ( etc_passwd_initted )
+    return;
+  etc_passwd_initted = 1;
+  
+  (void) mkdir( "/etc", S_IRWXU | S_IRWXG | S_IRWXO );
+
+  /*
+   *  Initialize /etc/passwd
+   */
+
+  if ((fp = fopen ("/etc/passwd", "w")) == NULL)
+    return;
+
+  fprintf( fp, "root:*:0:0:root,,,,:/tmp:/bin/false\n"
+               "rtems:*:1:1:RTEMS Application,,,,:/tmp:/bin/false\n" );
+
+  fclose( fp );
+
+  /*
+   *  Initialize /etc/group
+   */
+
+  if ((fp = fopen ("/etc/group", "w")) == NULL)
+    return;
+
+  fprintf( fp, "root::0:root\n"
+               "rtems::0:rtems\n" );
+
+  fclose( fp );
+}
+
 int getpwnam_r(
   const char     *name,
@@ -27,4 +90,6 @@
 {
   FILE *fp;
+
+  init_etc_passwd_group();
 
   if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
@@ -79,4 +144,6 @@
   FILE *fp;
 
+  init_etc_passwd_group();
+
   if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
     errno = EINVAL;
@@ -146,4 +213,6 @@
 void setpwent( void )
 {
+  init_etc_passwd_group();
+
   if (passwd_fp != NULL)
     fclose (passwd_fp);
Index: c/src/lib/libc/getgrent.c
===================================================================
--- c/src/lib/libc/getgrent.c	(revision c51917f304dbea16877ad328da2d45512b751796)
+++ c/src/lib/libc/getgrent.c	(revision a0a225f4aaa36461554db637edf24291acb17da6)
@@ -1,5 +1,12 @@
 /*
+ *  POSIX 1003.1b - 9.2.1 - Group Database Access Routines
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.OARcorp.com/rtems/license.html.
+ *
  *  $Id$
  */
+
 
 #include <stdio.h>
@@ -15,8 +22,17 @@
 static FILE *group_fp;
 
+/*
+ *  The size of these buffers is arbitrary and there is no provision
+ *  to protect any of them from overflowing.  The scanf patterns
+ *  need to be changed to prevent overflowing.  In addition,
+ *  the limits on these needs to be examined.
+ */
+
 static char groupname[8];
 static char password[1024];
 static char groups[1024];
 static char *gr_mem[16] = { } ;
+
+extern void init_etc_passwd_group(void);
 
 int getgrnam_r(
@@ -29,4 +45,6 @@
 {
   FILE *fp;
+
+  init_etc_passwd_group();
 
   if ((fp = fopen ("/etc/group", "r")) == NULL) {
@@ -76,4 +94,6 @@
 {
   FILE *fp;
+
+  init_etc_passwd_group();
 
   if ((fp = fopen ("/etc/group", "r")) == NULL) {
@@ -138,4 +158,6 @@
 setgrent ()
 {
+  init_etc_passwd_group();
+
   if (group_fp != NULL)
     fclose (group_fp);
Index: c/src/lib/libc/getpwent.c
===================================================================
--- c/src/lib/libc/getpwent.c	(revision c51917f304dbea16877ad328da2d45512b751796)
+++ c/src/lib/libc/getpwent.c	(revision a0a225f4aaa36461554db637edf24291acb17da6)
@@ -1,2 +1,12 @@
+/*
+ *  POSIX 1003.1b - 9.2.2 - User Database Access Routines
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.OARcorp.com/rtems/license.html.
+ *
+ *  $Id$
+ */
+
 #include <stdio.h>
 #include <sys/types.h>
@@ -7,7 +17,16 @@
 #include <string.h>
 #include <limits.h>
+#include <fcntl.h>
+#include <unistd.h>
 
 static struct passwd pw_passwd;  /* password structure */
 static FILE *passwd_fp;
+
+/*
+ *  The size of these buffers is arbitrary and there is no provision
+ *  to protect any of them from overflowing.  The scanf patterns
+ *  need to be changed to prevent overflowing.  In addition,
+ *  the limits on these needs to be examined.
+ */
 
 static char logname[8];
@@ -18,4 +37,48 @@
 static char shell[1024];
 
+/*
+ *  Initialize a useable but dummy /etc/passwd
+ *
+ *  NOTE: Ignore all errors.
+ *
+ */
+
+static char etc_passwd_initted = 0;
+
+void init_etc_passwd_group(void)
+{
+  FILE *fp;
+
+  if ( etc_passwd_initted )
+    return;
+  etc_passwd_initted = 1;
+  
+  (void) mkdir( "/etc", S_IRWXU | S_IRWXG | S_IRWXO );
+
+  /*
+   *  Initialize /etc/passwd
+   */
+
+  if ((fp = fopen ("/etc/passwd", "w")) == NULL)
+    return;
+
+  fprintf( fp, "root:*:0:0:root,,,,:/tmp:/bin/false\n"
+               "rtems:*:1:1:RTEMS Application,,,,:/tmp:/bin/false\n" );
+
+  fclose( fp );
+
+  /*
+   *  Initialize /etc/group
+   */
+
+  if ((fp = fopen ("/etc/group", "w")) == NULL)
+    return;
+
+  fprintf( fp, "root::0:root\n"
+               "rtems::0:rtems\n" );
+
+  fclose( fp );
+}
+
 int getpwnam_r(
   const char     *name,
@@ -27,4 +90,6 @@
 {
   FILE *fp;
+
+  init_etc_passwd_group();
 
   if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
@@ -79,4 +144,6 @@
   FILE *fp;
 
+  init_etc_passwd_group();
+
   if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
     errno = EINVAL;
@@ -146,4 +213,6 @@
 void setpwent( void )
 {
+  init_etc_passwd_group();
+
   if (passwd_fp != NULL)
     fclose (passwd_fp);
Index: cpukit/libcsupport/src/getgrent.c
===================================================================
--- cpukit/libcsupport/src/getgrent.c	(revision c51917f304dbea16877ad328da2d45512b751796)
+++ cpukit/libcsupport/src/getgrent.c	(revision a0a225f4aaa36461554db637edf24291acb17da6)
@@ -1,5 +1,12 @@
 /*
+ *  POSIX 1003.1b - 9.2.1 - Group Database Access Routines
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.OARcorp.com/rtems/license.html.
+ *
  *  $Id$
  */
+
 
 #include <stdio.h>
@@ -15,8 +22,17 @@
 static FILE *group_fp;
 
+/*
+ *  The size of these buffers is arbitrary and there is no provision
+ *  to protect any of them from overflowing.  The scanf patterns
+ *  need to be changed to prevent overflowing.  In addition,
+ *  the limits on these needs to be examined.
+ */
+
 static char groupname[8];
 static char password[1024];
 static char groups[1024];
 static char *gr_mem[16] = { } ;
+
+extern void init_etc_passwd_group(void);
 
 int getgrnam_r(
@@ -29,4 +45,6 @@
 {
   FILE *fp;
+
+  init_etc_passwd_group();
 
   if ((fp = fopen ("/etc/group", "r")) == NULL) {
@@ -76,4 +94,6 @@
 {
   FILE *fp;
+
+  init_etc_passwd_group();
 
   if ((fp = fopen ("/etc/group", "r")) == NULL) {
@@ -138,4 +158,6 @@
 setgrent ()
 {
+  init_etc_passwd_group();
+
   if (group_fp != NULL)
     fclose (group_fp);
Index: cpukit/libcsupport/src/getpwent.c
===================================================================
--- cpukit/libcsupport/src/getpwent.c	(revision c51917f304dbea16877ad328da2d45512b751796)
+++ cpukit/libcsupport/src/getpwent.c	(revision a0a225f4aaa36461554db637edf24291acb17da6)
@@ -1,2 +1,12 @@
+/*
+ *  POSIX 1003.1b - 9.2.2 - User Database Access Routines
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.OARcorp.com/rtems/license.html.
+ *
+ *  $Id$
+ */
+
 #include <stdio.h>
 #include <sys/types.h>
@@ -7,7 +17,16 @@
 #include <string.h>
 #include <limits.h>
+#include <fcntl.h>
+#include <unistd.h>
 
 static struct passwd pw_passwd;  /* password structure */
 static FILE *passwd_fp;
+
+/*
+ *  The size of these buffers is arbitrary and there is no provision
+ *  to protect any of them from overflowing.  The scanf patterns
+ *  need to be changed to prevent overflowing.  In addition,
+ *  the limits on these needs to be examined.
+ */
 
 static char logname[8];
@@ -18,4 +37,48 @@
 static char shell[1024];
 
+/*
+ *  Initialize a useable but dummy /etc/passwd
+ *
+ *  NOTE: Ignore all errors.
+ *
+ */
+
+static char etc_passwd_initted = 0;
+
+void init_etc_passwd_group(void)
+{
+  FILE *fp;
+
+  if ( etc_passwd_initted )
+    return;
+  etc_passwd_initted = 1;
+  
+  (void) mkdir( "/etc", S_IRWXU | S_IRWXG | S_IRWXO );
+
+  /*
+   *  Initialize /etc/passwd
+   */
+
+  if ((fp = fopen ("/etc/passwd", "w")) == NULL)
+    return;
+
+  fprintf( fp, "root:*:0:0:root,,,,:/tmp:/bin/false\n"
+               "rtems:*:1:1:RTEMS Application,,,,:/tmp:/bin/false\n" );
+
+  fclose( fp );
+
+  /*
+   *  Initialize /etc/group
+   */
+
+  if ((fp = fopen ("/etc/group", "w")) == NULL)
+    return;
+
+  fprintf( fp, "root::0:root\n"
+               "rtems::0:rtems\n" );
+
+  fclose( fp );
+}
+
 int getpwnam_r(
   const char     *name,
@@ -27,4 +90,6 @@
 {
   FILE *fp;
+
+  init_etc_passwd_group();
 
   if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
@@ -79,4 +144,6 @@
   FILE *fp;
 
+  init_etc_passwd_group();
+
   if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
     errno = EINVAL;
@@ -146,4 +213,6 @@
 void setpwent( void )
 {
+  init_etc_passwd_group();
+
   if (passwd_fp != NULL)
     fclose (passwd_fp);
