summaryrefslogtreecommitdiff
path: root/minix/lib/libc/sys/__getlogin.c
blob: 4194db6246c0b798794e307cca1833dc7237260f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*  getlogin(3)
 *
 *  Author: Terrence W. Holm          Aug. 1988
 */

#include <sys/cdefs.h>
#include "namespace.h"
#include <lib.h>

#include <pwd.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include "extern.h"



int __getlogin(char *logname, size_t sz)
{
  struct passwd *pw_entry;

  pw_entry = getpwuid(getuid());

  if (pw_entry == (struct passwd *)NULL)
    return 0; 
    
  strncpy(logname, pw_entry->pw_name, sz);
  return sz;
}