pwd.h revision 98070
11539Srgrimes/*-
21539Srgrimes * Copyright (c) 1989, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes * (c) UNIX System Laboratories, Inc.
51539Srgrimes * All or some portions of this file are derived from material licensed
61539Srgrimes * to the University of California by American Telephone and Telegraph
71539Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with
81539Srgrimes * the permission of UNIX System Laboratories, Inc.
91539Srgrimes *
101539Srgrimes * Redistribution and use in source and binary forms, with or without
111539Srgrimes * modification, are permitted provided that the following conditions
121539Srgrimes * are met:
131539Srgrimes * 1. Redistributions of source code must retain the above copyright
141539Srgrimes *    notice, this list of conditions and the following disclaimer.
151539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
161539Srgrimes *    notice, this list of conditions and the following disclaimer in the
171539Srgrimes *    documentation and/or other materials provided with the distribution.
181539Srgrimes * 3. All advertising materials mentioning features or use of this software
191539Srgrimes *    must display the following acknowledgement:
201539Srgrimes *	This product includes software developed by the University of
211539Srgrimes *	California, Berkeley and its contributors.
221539Srgrimes * 4. Neither the name of the University nor the names of its contributors
231539Srgrimes *    may be used to endorse or promote products derived from this software
241539Srgrimes *    without specific prior written permission.
251539Srgrimes *
261539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
271539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
281539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
291539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
301539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
311539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
321539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
331539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
341539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
361539Srgrimes * SUCH DAMAGE.
371539Srgrimes *
381539Srgrimes *	@(#)pwd.h	8.2 (Berkeley) 1/21/94
3990644Simp * $FreeBSD: head/include/pwd.h 98070 2002-06-09 19:39:18Z mike $
401539Srgrimes */
411539Srgrimes
421539Srgrimes#ifndef _PWD_H_
431539Srgrimes#define	_PWD_H_
441539Srgrimes
4598070Smike#include <sys/cdefs.h>
4698070Smike#include <sys/_types.h>
471539Srgrimes
4898070Smike#ifdef _BSD_GID_T_
4998070Smiketypedef	_BSD_GID_T_	gid_t;
5098070Smike#undef _BSD_GID_T_
5198070Smike#endif
5298070Smike
5398070Smike#ifdef _BSD_TIME_T_
5498070Smiketypedef	_BSD_TIME_T_	time_t;
5598070Smike#undef _BSD_TIME_T_
5698070Smike#endif
5798070Smike
5898070Smike#ifdef _BSD_UID_T_
5998070Smiketypedef	_BSD_UID_T_	uid_t;
6098070Smike#undef _BSD_UID_T_
6198070Smike#endif
6298070Smike
632552Sgpalmer#define _PATH_PWD		"/etc"
641539Srgrimes#define	_PATH_PASSWD		"/etc/passwd"
652552Sgpalmer#define	_PASSWD			"passwd"
661539Srgrimes#define	_PATH_MASTERPASSWD	"/etc/master.passwd"
672552Sgpalmer#define	_MASTERPASSWD		"master.passwd"
681539Srgrimes
691539Srgrimes#define	_PATH_MP_DB		"/etc/pwd.db"
702552Sgpalmer#define	_MP_DB			"pwd.db"
711539Srgrimes#define	_PATH_SMP_DB		"/etc/spwd.db"
722552Sgpalmer#define	_SMP_DB			"spwd.db"
731539Srgrimes
741539Srgrimes#define	_PATH_PWD_MKDB		"/usr/sbin/pwd_mkdb"
751539Srgrimes
761539Srgrimes#define	_PW_KEYBYNAME		'1'	/* stored by name */
771539Srgrimes#define	_PW_KEYBYNUM		'2'	/* stored by entry in the "file" */
781539Srgrimes#define	_PW_KEYBYUID		'3'	/* stored by uid */
792915Swollman#define _PW_KEYYPENABLED	'4'	/* YP is enabled */
8015267Swpaul#define	_PW_KEYYPBYNUM		'5'	/* special +@netgroup entries */
811539Srgrimes
821539Srgrimes#define	_PASSWORD_EFMT1		'_'	/* extended encryption format */
831539Srgrimes
841539Srgrimes#define	_PASSWORD_LEN		128	/* max length, not counting NULL */
851539Srgrimes
861539Srgrimesstruct passwd {
871539Srgrimes	char	*pw_name;		/* user name */
881539Srgrimes	char	*pw_passwd;		/* encrypted password */
8942780Sdes	uid_t	pw_uid;			/* user uid */
9042780Sdes	gid_t	pw_gid;			/* user gid */
911539Srgrimes	time_t	pw_change;		/* password change time */
921539Srgrimes	char	*pw_class;		/* user access class */
931539Srgrimes	char	*pw_gecos;		/* Honeywell login info */
941539Srgrimes	char	*pw_dir;		/* home directory */
951539Srgrimes	char	*pw_shell;		/* default shell */
961539Srgrimes	time_t	pw_expire;		/* account expiration */
972915Swollman	int	pw_fields;		/* internal: fields filled in */
981539Srgrimes};
991539Srgrimes
1002915Swollman/* Mapping from fields to bits for pw_fields. */
1012915Swollman#define _PWF(x)		(1 << x)
1022915Swollman#define _PWF_NAME	_PWF(0)
1032915Swollman#define _PWF_PASSWD	_PWF(1)
1042915Swollman#define _PWF_UID	_PWF(2)
1052915Swollman#define _PWF_GID	_PWF(3)
1062915Swollman#define _PWF_CHANGE	_PWF(4)
1072915Swollman#define _PWF_CLASS	_PWF(5)
1082915Swollman#define _PWF_GECOS	_PWF(6)
1092915Swollman#define _PWF_DIR	_PWF(7)
1102915Swollman#define _PWF_SHELL	_PWF(8)
1112915Swollman#define _PWF_EXPIRE	_PWF(9)
1122915Swollman
11394688Sdes#define _PWF_SOURCE	0x3000
11494688Sdes#define _PWF_FILES	0x1000
11594688Sdes#define _PWF_NIS	0x2000
11694688Sdes#define _PWF_HESIOD	0x3000
11794688Sdes
1181539Srgrimes__BEGIN_DECLS
11998070Smikestruct passwd	*getpwnam(const char *);
12093032Simpstruct passwd	*getpwuid(uid_t);
12198070Smike
12298070Smike#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
12398070Smikevoid		 endpwent(void);
12493032Simpstruct passwd	*getpwent(void);
12598070Smikevoid		 setpwent(void);
12698070Smike/*
12798070Smike * XXX missing getpwnam_r() and getpwuid_r().
12898070Smike */
12998070Smike#endif
13098070Smike
13198070Smike#if __BSD_VISIBLE
13293032Simpint		 setpassent(int);
13393032Simpconst char	*user_from_uid(uid_t, int);
1341539Srgrimes#endif
1351539Srgrimes__END_DECLS
1361539Srgrimes
1371539Srgrimes#endif /* !_PWD_H_ */
138