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) 1988 AT&T */
23 /* All Rights Reserved */
27 * Copyright (c) 1999 by Sun Microsystems, Inc.
28 * All rights reserved.
31 #pragma ident "%Z%%M% %I% %E% SMI"
36 * This routine does not use the getpwent(3) library routine
37 * because the latter uses the stdio package. The allocation of
38 * storage in this package destroys the integrity of the shell's
42 #include <fcntl.h> /* O_RDONLY */
49 static char line
[BUFSIZ
+1];
54 while (*p
&& *p
!= ':')
68 /* attempt to open the password file */
69 if ((pwf
= open("/etc/passwd", O_RDONLY
)) == -1)
72 /* find the matching password entry */
74 /* get the next line in the password file */
75 i
= read(pwf
, line
, BUFSIZ
);
76 for (j
= 0; j
< i
; j
++)
79 /* return a null pointer if the whole file has been read */
82 line
[++j
] = 0; /* terminate the line */
83 /* point at the next line */
84 (void) lseek(pwf
, (long)(j
- i
), 1);
85 p
= passwdfield(line
); /* get the logname */
86 } while (*name
!= *line
|| /* fast pretest */
87 strcmp(name
, line
) != 0);
90 /* skip the intervening fields */
96 /* return the login directory */
97 (void) passwdfield(p
);