aboutsummaryrefslogtreecommitdiff
path: root/src/lib9/getuser.c
blob: b53a3892ea57cc897b447af11b7fb56a53cd70dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <pwd.h>

#include <u.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;
}