Go to the documentation of this file.00001
00007
00008
00009
00010 #include <stdlib.h>
00011 #include <stdio.h>
00012
00013 #include "portability.h"
00014
00022 char *gs_get_login_name() {
00023 char *name;
00024
00025 if((name = getenv("LOGNAME")))
00026 return strdup(name);
00027
00028 if((name = getenv("USER")))
00029 return strdup(name);
00030
00031 #ifdef HAVE_GETPWUID
00032 # ifdef HAVE_GETEUID
00033 if((name = ((struct passwd *)getpwuid(geteuid()))->pw_name))
00034 return strdup(name);
00035 # endif
00036 #endif
00037
00038 #ifdef HAVE_GETLOGIN
00039 if((name = getlogin()))
00040 return strdup(name);
00041 #endif
00042
00043 return strdup("unknown");
00044 }