source: rtems/cpukit/posix/src/getlogin.c @ 089abb6d

4.104.114.84.95
Last change on this file since 089abb6d was 089abb6d, checked in by Joel Sherrill <joel.sherrill@…>, on 01/16/02 at 22:52:27

2002-02-09 Ralf Corsepius <corsepiu@…>

  • src/getegid.c: Add #include <rtems/userenv.h>. Remove #include <rtems/libio_.h>.
  • src/geteuid.c: Ditto.
  • src/getgid.c: Ditto.
  • src/getlogin.c: Ditto.
  • src/getuid.c: Ditto.
  • Property mode set to 100644
File size: 1018 bytes
RevLine 
[811fae1]1/*
2 *  $Id$
3 */
4
[f42b726]5#if HAVE_CONFIG_H
6#include "config.h"
7#endif
8
[811fae1]9#include <limits.h>
10#include <errno.h>
11#include <string.h>
12#include <sys/types.h>
13
14#include <rtems/system.h>
15#include <rtems/score/object.h>
[188c82b]16#include <rtems/seterr.h>
[089abb6d]17#include <rtems/userenv.h>
[811fae1]18
[aaf6063]19#include <unistd.h>
20#include <pwd.h>
21
[811fae1]22/*PAGE
23 *
24 *  4.2.4 Get User Name, P1003.1b-1993, p. 87
25 *
26 *  NOTE:  P1003.1c/D10, p. 49 adds getlogin_r().
27 */
28
[aaf6063]29/*
[089abb6d]30 * MACRO in userenv.h
[aaf6063]31 *
[811fae1]32static char _POSIX_types_Getlogin_buffer[ LOGIN_NAME_MAX ];
[aaf6063]33*/
[811fae1]34
35char *getlogin( void )
36{
37  (void) getlogin_r( _POSIX_types_Getlogin_buffer, LOGIN_NAME_MAX );
38  return _POSIX_types_Getlogin_buffer;
39}
40
41/*PAGE
42 *
43 *  4.2.4 Get User Name, P1003.1b-1993, p. 87
44 *
45 *  NOTE:  P1003.1c/D10, p. 49 adds getlogin_r().
46 */
47
48int getlogin_r(
49  char   *name,
50  size_t  namesize
51)
52{
[aaf6063]53  struct passwd *pw;   
[811fae1]54  if ( namesize < LOGIN_NAME_MAX )
55    return ERANGE;
56
[aaf6063]57  pw=getpwuid(getuid());
58  if (!pw) {
59   strcpy(name,"");
60  } else {
61   strncpy(name,pw->pw_name,LOGIN_NAME_MAX);
62  };
[811fae1]63  return 0;
64}
Note: See TracBrowser for help on using the repository browser.