source: rtems/testsuites/psxtests/psxpasswd01/init.c @ 4828ee2

4.104.11
Last change on this file since 4828ee2 was 4828ee2, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 3, 2009 at 5:15:02 PM

2009-12-03 Joel Sherrill <joel.sherrill@…>

  • Makefile.am, configure.ac: New test to exercise getgrnam and getpwnam families.
  • psxpasswd01/.cvsignore, psxpasswd01/Makefile.am, psxpasswd01/init.c, psxpasswd01/psxpasswd01.doc, psxpasswd01/psxpasswd01.scn: New files.
  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#include <bsp.h>
13#include <pmacros.h>
14#include <sys/types.h>
15#include <pwd.h>
16#include <grp.h>
17
18void print_passwd(
19  struct passwd *pw
20)
21{
22  printf( 
23    "  username: %s\n"
24    "  user password: %s\n"
25    "  user ID: %d\n"
26    "  group ID: %d\n"
27    "  real name: %s\n"
28    "  home directory: %s\n"
29    "  shell program: %s\n",
30    pw->pw_name,
31    pw->pw_passwd,
32    pw->pw_uid,
33    pw->pw_gid,
34    pw->pw_gecos,
35    pw->pw_dir,
36    pw->pw_shell
37  );
38}
39 
40void print_group(
41  struct group *gr
42)
43{
44  printf( 
45    "  group name: %s\n"
46    "  group  password: %s\n"
47    "  group  ID: %d\n",
48    gr->gr_name,
49    gr->gr_passwd,
50    gr->gr_gid
51  );
52
53  /* TBD print users in group */
54}
55 
56rtems_task Init(
57  rtems_task_argument ignored
58)
59{
60  struct passwd *pw;
61  struct group  *gr;
62
63  puts( "*** PASSWORD/GROUP TEST ***" );
64
65  /* getpwnam */
66  puts( "Init - getpwnam(\"root\") -- OK" );
67  pw = getpwnam("root");
68  rtems_test_assert( pw );
69  print_passwd( pw );
70
71  puts( "Init - getpwnam(\"rtems\") -- OK" );
72  pw = getpwnam("rtems");
73  rtems_test_assert( pw );
74  print_passwd( pw );
75
76  /* getgrnam */
77  puts( "Init - getgrnam(\"root\") -- OK" );
78  gr = getgrnam("root");
79  rtems_test_assert( gr );
80  print_group( gr );
81
82  puts( "Init - getgrnam(\"rtems\") -- OK" );
83  gr = getgrnam("rtems");
84  rtems_test_assert( gr );
85  print_group( gr );
86
87  puts( "*** END OF PASSWORD/GROUP TEST ***" );
88  rtems_test_exit( 0 );
89}
90
91/* configuration information */
92
93#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
94#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
95
96#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
97#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 6
98
99#define CONFIGURE_MAXIMUM_TASKS 1
100#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
101
102#define CONFIGURE_INIT
103#include <rtems/confdefs.h>
104/* end of file */
Note: See TracBrowser for help on using the repository browser.