mirror of
https://git.suckless.org/9base
synced 2025-08-28 19:03:48 -07:00
initial import
This commit is contained in:
16
lib9/getuser.c
Normal file
16
lib9/getuser.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <u.h>
|
||||
#include <pwd.h>
|
||||
#include <libc.h>
|
||||
|
||||
char*
|
||||
getuser(void)
|
||||
{
|
||||
static char user[64];
|
||||
struct passwd *pw;
|
||||
|
||||
pw = getpwuid(getuid());
|
||||
if(pw == nil)
|
||||
return "none";
|
||||
strecpy(user, user+sizeof user, pw->pw_name);
|
||||
return user;
|
||||
}
|
Reference in New Issue
Block a user