9base

revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log | Files | Refs | README | LICENSE

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 }