4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
26 #ident "%Z%%M% %I% %E% SMI" /* from SVR4 bnu:getpwinfo.c 2.8 */
31 extern struct passwd
*getpwuid(), *getpwnam();
32 extern char *getlogin();
36 * get passwd file info for logname or uid
38 * name -> address of buffer to return ascii user name
39 * This will be set to pw->pw_name.
43 * FAIL -> failure (logname and uid not found)
50 register struct passwd
*pwd
;
53 /* look for this user as logged in utmp */
54 if ((login_name
= getlogin()) != NULL
) {
55 pwd
= getpwnam(login_name
);
56 if (pwd
!= NULL
&& pwd
->pw_uid
== uid
)
60 /* no dice on utmp -- get first from passwd file */
61 if ((pwd
= getpwuid(uid
)) == NULL
) {
62 if ((pwd
= getpwuid(UUCPUID
)) == NULL
)
63 /* can not find uid in passwd file */
68 (void) strcpy(name
, pwd
->pw_name
);
73 * get passwd file info for name
74 * name -> ascii user name
75 * uid -> address of integer to return uid # in
76 * path -> address of buffer to return working directory in
82 gninfo(name
, uid
, path
)
86 register struct passwd
*pwd
;
88 if ((pwd
= getpwnam(name
)) == NULL
) {
89 /* can not find name in passwd file */
94 (void) strcpy(path
, pwd
->pw_dir
);