getuser.c (238B)
1 #include <u.h> 2 #include <pwd.h> 3 #include <libc.h> 4 5 char* 6 getuser(void) 7 { 8 static char user[64]; 9 struct passwd *pw; 10 11 pw = getpwuid(getuid()); 12 if(pw == nil) 13 return "none"; 14 strecpy(user, user+sizeof user, pw->pw_name); 15 return user; 16 }