mailing list of musl libc
 help / color / mirror / code / Atom feed
07866acf138dd232beaa5500724704977a4d5968 blob 438 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
 
#define _GNU_SOURCE
#include <pwd.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>

char *cuserid(char *buf)
{
	static char usridbuf[L_cuserid];
	struct passwd pw, *ppw;
	long pwb[256];
	getpwuid_r(geteuid(), &pw, (void *)pwb, sizeof pwb, &ppw);
	if (!ppw)
		return 0;
	size_t len = strnlen(pw.pw_name, L_cuserid);
	if (len == L_cuserid)
		return 0;
	if (!buf) buf = usridbuf;
	memcpy(buf, pw.pw_name, len+1);
	return buf;
}
debug log:

solving 07866acf ...
found 07866acf in https://git.vuxu.org/mirror/musl/

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).