libdl: first execute all destructors, then munmap library
[uclibc-ng.git] / libc / unistd / getlogin.c
blob8cdbd96ac94ac97924cace5e9b5fd9d31ef1b133
1 /*
2 * getlogin for uClibc
3 * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5 */
7 #include <stdlib.h>
8 #include <string.h>
9 #include <unistd.h>
10 #include <stdio.h>
13 /* uClibc makes it policy to not mess with the utmp file whenever
14 * possible, since I consider utmp a complete waste of time. Since
15 * getlogin() should never be used for security purposes, we kindly let
16 * the user specify whatever they want via the LOGNAME environment
17 * variable, or we return NULL if getenv() fails to find anything */
19 char * getlogin(void)
21 return (getenv("LOGNAME"));
23 libc_hidden_def(getlogin)
25 int getlogin_r(char *name, size_t len)
27 char * foo = getenv("LOGNAME");
29 if (! foo)
30 return -1;
32 strncpy(name, foo, len);
33 name[len-1] = '\0';
34 return 0;
37 char *cuserid(char *s)
39 char *name = getlogin();
40 if (s) {
41 return(strcpy(s, name ? name : ""));
43 return name;