aboutsummaryrefslogtreecommitdiffstats
path: root/ports/linux/guts/getpw.c
blob: 62b44da97f77748cd07d5377f241ada0e51e3a26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* 
 * Copyright (c) 2010 Wind River Systems; see
 * guts/COPYRIGHT for information.
 *
 * static int
 * wrap_getpw(uid_t uid, char *buf) {
 *	int rc = -1;
 */
	static struct passwd pwd;
	static char pwbuf[PSEUDO_PWD_MAX];
	struct passwd *pwp;

	pseudo_diag("warning: unsafe getpw() called.  hoping buf has at least %d chars.\n",
		PSEUDO_PWD_MAX);
	rc = wrap_getpwuid_r(uid, &pwd, pwbuf, PSEUDO_PWD_MAX, &pwp);
	/* different error return conventions */
	if (rc != 0) {
		errno = rc;
		rc = -1;
	} else {
		snprintf(buf, PSEUDO_PWD_MAX, "%s:%s:%d:%d:%s:%s:%s",
			pwd.pw_name,
			pwd.pw_passwd,
			pwd.pw_uid,
			pwd.pw_gid,
			pwd.pw_gecos,
			pwd.pw_dir,
			pwd.pw_shell);
	}

/*	return rc;
 * }
 */