Changeset a0a225f in rtems


Ignore:
Timestamp:
Jul 2, 1999, 6:50:40 PM (21 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
c8d9183
Parents:
c51917f
Message:

Added code to initialize the /etc/group and /etc/passwd files.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/libcsupport/src/getgrent.c

    rc51917f ra0a225f  
    11/*
     2 *  POSIX 1003.1b - 9.2.1 - Group Database Access Routines
     3 *
     4 *  The license and distribution terms for this file may be
     5 *  found in the file LICENSE in this distribution or at
     6 *  http://www.OARcorp.com/rtems/license.html.
     7 *
    28 *  $Id$
    39 */
     10
    411
    512#include <stdio.h>
     
    1522static FILE *group_fp;
    1623
     24/*
     25 *  The size of these buffers is arbitrary and there is no provision
     26 *  to protect any of them from overflowing.  The scanf patterns
     27 *  need to be changed to prevent overflowing.  In addition,
     28 *  the limits on these needs to be examined.
     29 */
     30
    1731static char groupname[8];
    1832static char password[1024];
    1933static char groups[1024];
    2034static char *gr_mem[16] = { } ;
     35
     36extern void init_etc_passwd_group(void);
    2137
    2238int getgrnam_r(
     
    2945{
    3046  FILE *fp;
     47
     48  init_etc_passwd_group();
    3149
    3250  if ((fp = fopen ("/etc/group", "r")) == NULL) {
     
    7694{
    7795  FILE *fp;
     96
     97  init_etc_passwd_group();
    7898
    7999  if ((fp = fopen ("/etc/group", "r")) == NULL) {
     
    138158setgrent ()
    139159{
     160  init_etc_passwd_group();
     161
    140162  if (group_fp != NULL)
    141163    fclose (group_fp);
  • c/src/exec/libcsupport/src/getpwent.c

    rc51917f ra0a225f  
     1/*
     2 *  POSIX 1003.1b - 9.2.2 - User Database Access Routines
     3 *
     4 *  The license and distribution terms for this file may be
     5 *  found in the file LICENSE in this distribution or at
     6 *  http://www.OARcorp.com/rtems/license.html.
     7 *
     8 *  $Id$
     9 */
     10
    111#include <stdio.h>
    212#include <sys/types.h>
     
    717#include <string.h>
    818#include <limits.h>
     19#include <fcntl.h>
     20#include <unistd.h>
    921
    1022static struct passwd pw_passwd;  /* password structure */
    1123static FILE *passwd_fp;
     24
     25/*
     26 *  The size of these buffers is arbitrary and there is no provision
     27 *  to protect any of them from overflowing.  The scanf patterns
     28 *  need to be changed to prevent overflowing.  In addition,
     29 *  the limits on these needs to be examined.
     30 */
    1231
    1332static char logname[8];
     
    1837static char shell[1024];
    1938
     39/*
     40 *  Initialize a useable but dummy /etc/passwd
     41 *
     42 *  NOTE: Ignore all errors.
     43 *
     44 */
     45
     46static char etc_passwd_initted = 0;
     47
     48void init_etc_passwd_group(void)
     49{
     50  FILE *fp;
     51
     52  if ( etc_passwd_initted )
     53    return;
     54  etc_passwd_initted = 1;
     55 
     56  (void) mkdir( "/etc", S_IRWXU | S_IRWXG | S_IRWXO );
     57
     58  /*
     59   *  Initialize /etc/passwd
     60   */
     61
     62  if ((fp = fopen ("/etc/passwd", "w")) == NULL)
     63    return;
     64
     65  fprintf( fp, "root:*:0:0:root,,,,:/tmp:/bin/false\n"
     66               "rtems:*:1:1:RTEMS Application,,,,:/tmp:/bin/false\n" );
     67
     68  fclose( fp );
     69
     70  /*
     71   *  Initialize /etc/group
     72   */
     73
     74  if ((fp = fopen ("/etc/group", "w")) == NULL)
     75    return;
     76
     77  fprintf( fp, "root::0:root\n"
     78               "rtems::0:rtems\n" );
     79
     80  fclose( fp );
     81}
     82
    2083int getpwnam_r(
    2184  const char     *name,
     
    2790{
    2891  FILE *fp;
     92
     93  init_etc_passwd_group();
    2994
    3095  if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
     
    79144  FILE *fp;
    80145
     146  init_etc_passwd_group();
     147
    81148  if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
    82149    errno = EINVAL;
     
    146213void setpwent( void )
    147214{
     215  init_etc_passwd_group();
     216
    148217  if (passwd_fp != NULL)
    149218    fclose (passwd_fp);
  • c/src/lib/libc/getgrent.c

    rc51917f ra0a225f  
    11/*
     2 *  POSIX 1003.1b - 9.2.1 - Group Database Access Routines
     3 *
     4 *  The license and distribution terms for this file may be
     5 *  found in the file LICENSE in this distribution or at
     6 *  http://www.OARcorp.com/rtems/license.html.
     7 *
    28 *  $Id$
    39 */
     10
    411
    512#include <stdio.h>
     
    1522static FILE *group_fp;
    1623
     24/*
     25 *  The size of these buffers is arbitrary and there is no provision
     26 *  to protect any of them from overflowing.  The scanf patterns
     27 *  need to be changed to prevent overflowing.  In addition,
     28 *  the limits on these needs to be examined.
     29 */
     30
    1731static char groupname[8];
    1832static char password[1024];
    1933static char groups[1024];
    2034static char *gr_mem[16] = { } ;
     35
     36extern void init_etc_passwd_group(void);
    2137
    2238int getgrnam_r(
     
    2945{
    3046  FILE *fp;
     47
     48  init_etc_passwd_group();
    3149
    3250  if ((fp = fopen ("/etc/group", "r")) == NULL) {
     
    7694{
    7795  FILE *fp;
     96
     97  init_etc_passwd_group();
    7898
    7999  if ((fp = fopen ("/etc/group", "r")) == NULL) {
     
    138158setgrent ()
    139159{
     160  init_etc_passwd_group();
     161
    140162  if (group_fp != NULL)
    141163    fclose (group_fp);
  • c/src/lib/libc/getpwent.c

    rc51917f ra0a225f  
     1/*
     2 *  POSIX 1003.1b - 9.2.2 - User Database Access Routines
     3 *
     4 *  The license and distribution terms for this file may be
     5 *  found in the file LICENSE in this distribution or at
     6 *  http://www.OARcorp.com/rtems/license.html.
     7 *
     8 *  $Id$
     9 */
     10
    111#include <stdio.h>
    212#include <sys/types.h>
     
    717#include <string.h>
    818#include <limits.h>
     19#include <fcntl.h>
     20#include <unistd.h>
    921
    1022static struct passwd pw_passwd;  /* password structure */
    1123static FILE *passwd_fp;
     24
     25/*
     26 *  The size of these buffers is arbitrary and there is no provision
     27 *  to protect any of them from overflowing.  The scanf patterns
     28 *  need to be changed to prevent overflowing.  In addition,
     29 *  the limits on these needs to be examined.
     30 */
    1231
    1332static char logname[8];
     
    1837static char shell[1024];
    1938
     39/*
     40 *  Initialize a useable but dummy /etc/passwd
     41 *
     42 *  NOTE: Ignore all errors.
     43 *
     44 */
     45
     46static char etc_passwd_initted = 0;
     47
     48void init_etc_passwd_group(void)
     49{
     50  FILE *fp;
     51
     52  if ( etc_passwd_initted )
     53    return;
     54  etc_passwd_initted = 1;
     55 
     56  (void) mkdir( "/etc", S_IRWXU | S_IRWXG | S_IRWXO );
     57
     58  /*
     59   *  Initialize /etc/passwd
     60   */
     61
     62  if ((fp = fopen ("/etc/passwd", "w")) == NULL)
     63    return;
     64
     65  fprintf( fp, "root:*:0:0:root,,,,:/tmp:/bin/false\n"
     66               "rtems:*:1:1:RTEMS Application,,,,:/tmp:/bin/false\n" );
     67
     68  fclose( fp );
     69
     70  /*
     71   *  Initialize /etc/group
     72   */
     73
     74  if ((fp = fopen ("/etc/group", "w")) == NULL)
     75    return;
     76
     77  fprintf( fp, "root::0:root\n"
     78               "rtems::0:rtems\n" );
     79
     80  fclose( fp );
     81}
     82
    2083int getpwnam_r(
    2184  const char     *name,
     
    2790{
    2891  FILE *fp;
     92
     93  init_etc_passwd_group();
    2994
    3095  if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
     
    79144  FILE *fp;
    80145
     146  init_etc_passwd_group();
     147
    81148  if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
    82149    errno = EINVAL;
     
    146213void setpwent( void )
    147214{
     215  init_etc_passwd_group();
     216
    148217  if (passwd_fp != NULL)
    149218    fclose (passwd_fp);
  • cpukit/libcsupport/src/getgrent.c

    rc51917f ra0a225f  
    11/*
     2 *  POSIX 1003.1b - 9.2.1 - Group Database Access Routines
     3 *
     4 *  The license and distribution terms for this file may be
     5 *  found in the file LICENSE in this distribution or at
     6 *  http://www.OARcorp.com/rtems/license.html.
     7 *
    28 *  $Id$
    39 */
     10
    411
    512#include <stdio.h>
     
    1522static FILE *group_fp;
    1623
     24/*
     25 *  The size of these buffers is arbitrary and there is no provision
     26 *  to protect any of them from overflowing.  The scanf patterns
     27 *  need to be changed to prevent overflowing.  In addition,
     28 *  the limits on these needs to be examined.
     29 */
     30
    1731static char groupname[8];
    1832static char password[1024];
    1933static char groups[1024];
    2034static char *gr_mem[16] = { } ;
     35
     36extern void init_etc_passwd_group(void);
    2137
    2238int getgrnam_r(
     
    2945{
    3046  FILE *fp;
     47
     48  init_etc_passwd_group();
    3149
    3250  if ((fp = fopen ("/etc/group", "r")) == NULL) {
     
    7694{
    7795  FILE *fp;
     96
     97  init_etc_passwd_group();
    7898
    7999  if ((fp = fopen ("/etc/group", "r")) == NULL) {
     
    138158setgrent ()
    139159{
     160  init_etc_passwd_group();
     161
    140162  if (group_fp != NULL)
    141163    fclose (group_fp);
  • cpukit/libcsupport/src/getpwent.c

    rc51917f ra0a225f  
     1/*
     2 *  POSIX 1003.1b - 9.2.2 - User Database Access Routines
     3 *
     4 *  The license and distribution terms for this file may be
     5 *  found in the file LICENSE in this distribution or at
     6 *  http://www.OARcorp.com/rtems/license.html.
     7 *
     8 *  $Id$
     9 */
     10
    111#include <stdio.h>
    212#include <sys/types.h>
     
    717#include <string.h>
    818#include <limits.h>
     19#include <fcntl.h>
     20#include <unistd.h>
    921
    1022static struct passwd pw_passwd;  /* password structure */
    1123static FILE *passwd_fp;
     24
     25/*
     26 *  The size of these buffers is arbitrary and there is no provision
     27 *  to protect any of them from overflowing.  The scanf patterns
     28 *  need to be changed to prevent overflowing.  In addition,
     29 *  the limits on these needs to be examined.
     30 */
    1231
    1332static char logname[8];
     
    1837static char shell[1024];
    1938
     39/*
     40 *  Initialize a useable but dummy /etc/passwd
     41 *
     42 *  NOTE: Ignore all errors.
     43 *
     44 */
     45
     46static char etc_passwd_initted = 0;
     47
     48void init_etc_passwd_group(void)
     49{
     50  FILE *fp;
     51
     52  if ( etc_passwd_initted )
     53    return;
     54  etc_passwd_initted = 1;
     55 
     56  (void) mkdir( "/etc", S_IRWXU | S_IRWXG | S_IRWXO );
     57
     58  /*
     59   *  Initialize /etc/passwd
     60   */
     61
     62  if ((fp = fopen ("/etc/passwd", "w")) == NULL)
     63    return;
     64
     65  fprintf( fp, "root:*:0:0:root,,,,:/tmp:/bin/false\n"
     66               "rtems:*:1:1:RTEMS Application,,,,:/tmp:/bin/false\n" );
     67
     68  fclose( fp );
     69
     70  /*
     71   *  Initialize /etc/group
     72   */
     73
     74  if ((fp = fopen ("/etc/group", "w")) == NULL)
     75    return;
     76
     77  fprintf( fp, "root::0:root\n"
     78               "rtems::0:rtems\n" );
     79
     80  fclose( fp );
     81}
     82
    2083int getpwnam_r(
    2184  const char     *name,
     
    2790{
    2891  FILE *fp;
     92
     93  init_etc_passwd_group();
    2994
    3095  if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
     
    79144  FILE *fp;
    80145
     146  init_etc_passwd_group();
     147
    81148  if ((fp = fopen ("/etc/passwd", "r")) == NULL) {
    82149    errno = EINVAL;
     
    146213void setpwent( void )
    147214{
     215  init_etc_passwd_group();
     216
    148217  if (passwd_fp != NULL)
    149218    fclose (passwd_fp);
Note: See TracChangeset for help on using the changeset viewer.