Changeset 002f351 in rtems


Ignore:
Timestamp:
Nov 14, 2014, 1:30:36 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
acf9a8d
Parents:
6935428
git-author:
Sebastian Huber <sebastian.huber@…> (11/14/14 13:30:36)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/20/14 09:30:22)
Message:

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.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/src/pwdgrp.c

    r6935428 r002f351  
    6060   *  Initialize /etc/passwd
    6161   */
    62   init_file(
    63     "/etc/passwd",
    64     "root:*:0:0:root::/:/bin/sh\n"
    65       "rtems:*:1:1:RTEMS Application::/:/bin/sh\n"
    66       "tty:!:2:2:tty owner::/:/bin/false\n"
    67   );
     62  init_file("/etc/passwd", "root::0:0::::\n");
    6863
    6964  /*
    7065   *  Initialize /etc/group
    7166   */
    72   init_file(
    73     "/etc/group",
    74     "root:x:0:root\n"
    75       "rtems:x:1:rtems\n"
    76       "tty:x:2:tty\n"
    77   );
     67  init_file("/etc/group", "root::0:\n");
    7868}
    7969
     
    266256   * Determine number of members
    267257   */
    268   for (cp = grmem, memcount = 1 ; *cp != 0 ; cp++) {
    269     if(*cp == ',')
    270       memcount++;
     258  if (grmem[0] == '\0') {
     259    memcount = 0;
     260  } else {
     261    for (cp = grmem, memcount = 1 ; *cp != 0 ; cp++) {
     262      if(*cp == ',')
     263        memcount++;
     264    }
    271265  }
    272266
     
    281275   * Fill in pointer array
    282276   */
    283   grp->gr_mem[0] = grmem;
    284   for (cp = grmem, memcount = 1 ; *cp != 0 ; cp++) {
    285     if(*cp == ',') {
    286       *cp = '\0';
    287       grp->gr_mem[memcount++] = cp + 1;
    288     }
    289   }
     277  if (grmem[0] == '\0') {
     278    memcount = 0;
     279  } else {
     280    grp->gr_mem[0] = grmem;
     281    for (cp = grmem, memcount = 1 ; *cp != 0 ; cp++) {
     282      if(*cp == ',') {
     283        *cp = '\0';
     284        grp->gr_mem[memcount++] = cp + 1;
     285      }
     286    }
     287  }
     288
    290289  grp->gr_mem[memcount] = NULL;
    291290  return 1;
  • testsuites/psxtests/psxpasswd01/init.c

    r6935428 r002f351  
    9999  print_passwd( pw );
    100100
    101   puts( "Init - getpwent() (2) -- OK" );
    102   pw = getpwent();
    103   rtems_test_assert( pw );
    104   print_passwd( pw );
    105 
    106   puts( "Init - getpwent() (3) -- OK" );
    107   pw = getpwent();
    108   rtems_test_assert( pw );
    109   print_passwd( pw );
    110 
    111   puts( "Init - getpwent() (4) -- result should be NULL" );
     101  puts( "Init - getpwent() (2) -- result should be NULL" );
    112102  pw = getpwent();
    113103  rtems_test_assert( !pw );
     
    120110  print_group( gr );
    121111
    122   puts( "Init - getgrent() (2) -- OK" );
    123   gr = getgrent();
    124   rtems_test_assert( gr );
    125   print_group( gr );
    126 
    127   puts( "Init - getgrent() (3) -- OK" );
    128   gr = getgrent();
    129   rtems_test_assert( gr );
    130   print_group( gr );
    131 
    132   puts( "Init - getgrent() (4) -- result should be NULL" );
     112  puts( "Init - getgrent() (2) -- result should be NULL" );
    133113  gr = getgrent();
    134114  rtems_test_assert( !gr );
     
    137117  puts( "Init - getpwnam(\"root\") -- OK" );
    138118  pw = getpwnam( "root" );
    139   rtems_test_assert( pw );
    140   print_passwd( pw );
    141 
    142   puts( "Init - getpwnam(\"rtems\") -- OK" );
    143   pw = getpwnam( "rtems" );
    144119  rtems_test_assert( pw );
    145120  print_passwd( pw );
     
    155130  print_passwd( pw );
    156131
    157   puts( "Init - getpwuid(1) -- OK" );
    158   pw = getpwuid( 1 );
    159   rtems_test_assert( pw );
    160   print_passwd( pw );
     132  rtems_test_assert( strcmp(pw->pw_name, "root") == 0 );
     133  rtems_test_assert( strcmp(pw->pw_passwd, "") == 0 );
     134  rtems_test_assert( pw->pw_uid == 0 );
     135  rtems_test_assert( pw->pw_gid == 0 );
     136  rtems_test_assert( strcmp(pw->pw_comment, "") == 0 );
     137  rtems_test_assert( strcmp(pw->pw_gecos, "") == 0 );
     138  rtems_test_assert( strcmp(pw->pw_dir, "") == 0 );
     139  rtems_test_assert( strcmp(pw->pw_shell, "") == 0 );
    161140
    162141  puts( "Init - getpwuid(4) -- result should be NULL" );
     
    170149  print_group( gr );
    171150
    172   puts( "Init - getgrnam(\"rtems\") -- OK" );
    173   gr = getgrnam("rtems");
    174   rtems_test_assert( gr );
    175   print_group( gr );
    176 
    177151  /* getgrgid */
    178152  puts( "Init - getgrgid(0) -- OK" );
     
    181155  print_group( gr );
    182156
    183   puts( "Init - getgrgid(1) -- OK" );
    184   gr = getgrgid(1);
    185   rtems_test_assert( gr );
    186   print_group( gr );
     157  rtems_test_assert( strcmp(gr->gr_name, "root") == 0 );
     158  rtems_test_assert( strcmp(gr->gr_passwd, "") == 0 );
     159  rtems_test_assert( gr->gr_gid == 0 );
     160  rtems_test_assert( gr->gr_mem[0] == NULL );
    187161
    188162  puts( "Init - getgrgid(4) -- result should be NULL");
  • testsuites/psxtests/psxpasswd01/psxpasswd01.scn

    r6935428 r002f351  
    1 Initialized console on port COM1 9600-8-N-1
    2 
    3 *** PASSWORD/GROUP TEST - 01 ***
     1*** BEGIN OF TEST PSXPASSWD 1 ***
    42Init - getpwent() -- OK, result should be NULL
    53Init - getgrent() -- OK, result should be NULL
     
    86Init - getpwent() (1) -- OK
    97  username: root
    10   user password: *
     8  user password:
    119  user ID: 0
    1210  group ID: 0
    1311  real name:
    14   home directory: /
    15   shell program: /bin/sh
    16 Init - getpwent() (2) -- OK
    17   username: rtems
    18   user password: *
    19   user ID: 1
    20   group ID: 1
    21   real name:
    22   home directory: /
    23   shell program: /bin/sh
    24 Init - getpwent() (3) -- OK
    25   username: tty
    26   user password: !
    27   user ID: 2
    28   group ID: 2
    29   real name:
    30   home directory: /
    31   shell program: /bin/false
    32 Init - getpwent() (4) -- result should be NULL
     12  home directory:
     13  shell program:
     14Init - getpwent() (2) -- result should be NULL
    3315Init - getgrent() (1) -- OK
    3416  group name: root
    35   group  password: x
     17  group  password:
    3618  group  ID: 0
    37 Init - getgrent() (2) -- OK
    38   group name: rtems
    39   group  password: x
    40   group  ID: 1
    41 Init - getgrent() (3) -- OK
    42   group name: tty
    43   group  password: x
    44   group  ID: 2
    45 Init - getgrent() (4) -- result should be NULL
     19Init - getgrent() (2) -- result should be NULL
    4620Init - getpwnam("root") -- OK
    4721  username: root
    48   user password: *
     22  user password:
    4923  user ID: 0
    5024  group ID: 0
    5125  real name:
    52   home directory: /
    53   shell program: /bin/sh
    54 Init - getpwnam("rtems") -- OK
    55   username: rtems
    56   user password: *
    57   user ID: 1
    58   group ID: 1
    59   real name:
    60   home directory: /
    61   shell program: /bin/sh
     26  home directory:
     27  shell program:
    6228Init - getpwnam("suser") -- result should be NULL
    6329Init - getpwuid(0) -- OK
    6430  username: root
    65   user password: *
     31  user password:
    6632  user ID: 0
    6733  group ID: 0
    6834  real name:
    69   home directory: /
    70   shell program: /bin/sh
    71 Init - getpwuid(1) -- OK
    72   username: rtems
    73   user password: *
    74   user ID: 1
    75   group ID: 1
    76   real name:
    77   home directory: /
    78   shell program: /bin/sh
     35  home directory:
     36  shell program:
    7937Init - getpwuid(4) -- result should be NULL
    8038Init - getgrnam("root") -- OK
    8139  group name: root
    82   group  password: x
     40  group  password:
    8341  group  ID: 0
    84 Init - getgrnam("rtems") -- OK
    85   group name: rtems
    86   group  password: x
    87   group  ID: 1
    8842Init - getgrgid(0) -- OK
    8943  group name: root
    90   group  password: x
     44  group  password:
    9145  group  ID: 0
    92 Init - getgrgid(1) -- OK
    93   group name: rtems
    94   group  password: x
    95   group  ID: 1
    9646Init - getgrgid(4) -- result should be NULL
    9747Init - endpwent() -- OK
    9848Init - endgrent() -- OK
    99 *** END OF PASSWORD/GROUP TEST - 01 ***
     49*** END OF TEST PSXPASSWD 1 ***
Note: See TracChangeset for help on using the changeset viewer.