source: rtems/c/src/exec/posix/src/getlogin.c @ aaf6063

4.104.114.84.9
Last change on this file since aaf6063 was aaf6063, checked in by Joel Sherrill <joel.sherrill@…>, on May 24, 2001 at 9:38:10 PM

2000-05-24 Fernando Ruiz Casas <fernando.ruiz@…>

  • src/getegid.c, src/geteuid.c, src/getgid.c, src/getlogin.c, src/getuid.c: Now save their values in private user environment.
  • Property mode set to 100644
File size: 1.0 KB
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>
[811fae1]17
[aaf6063]18#include <rtems/libio_.h>
19#include <string.h>
20#include <unistd.h>
21#include <pwd.h>
22
[811fae1]23/*PAGE
24 *
25 *  4.2.4 Get User Name, P1003.1b-1993, p. 87
26 *
27 *  NOTE:  P1003.1c/D10, p. 49 adds getlogin_r().
28 */
29
[aaf6063]30/*
31 * MACRO in libio_.h
32 *
[811fae1]33static char _POSIX_types_Getlogin_buffer[ LOGIN_NAME_MAX ];
[aaf6063]34*/
[811fae1]35
36char *getlogin( void )
37{
38  (void) getlogin_r( _POSIX_types_Getlogin_buffer, LOGIN_NAME_MAX );
39  return _POSIX_types_Getlogin_buffer;
40}
41
42/*PAGE
43 *
44 *  4.2.4 Get User Name, P1003.1b-1993, p. 87
45 *
46 *  NOTE:  P1003.1c/D10, p. 49 adds getlogin_r().
47 */
48
49int getlogin_r(
50  char   *name,
51  size_t  namesize
52)
53{
[aaf6063]54  struct passwd *pw;   
[811fae1]55  if ( namesize < LOGIN_NAME_MAX )
56    return ERANGE;
57
[aaf6063]58  pw=getpwuid(getuid());
59  if (!pw) {
60   strcpy(name,"");
61  } else {
62   strncpy(name,pw->pw_name,LOGIN_NAME_MAX);
63  };
[811fae1]64  return 0;
65}
Note: See TracBrowser for help on using the repository browser.