pwd.h revision 113596
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 113596 2003-04-17 14:15:26Z nectar $
401539Srgrimes */
411539Srgrimes
421539Srgrimes#ifndef _PWD_H_
431539Srgrimes#define	_PWD_H_
441539Srgrimes
4598070Smike#include <sys/cdefs.h>
4698070Smike#include <sys/_types.h>
471539Srgrimes
48102227Smike#ifndef _GID_T_DECLARED
49102227Smiketypedef	__gid_t		gid_t;
50102227Smike#define	_GID_T_DECLARED
5198070Smike#endif
5298070Smike
53102227Smike#ifndef _TIME_T_DECLARED
54102227Smiketypedef	__time_t	time_t;
55102227Smike#define	_TIME_T_DECLARED
5698070Smike#endif
5798070Smike
58102227Smike#ifndef _UID_T_DECLARED
59102227Smiketypedef	__uid_t		uid_t;
60102227Smike#define	_UID_T_DECLARED
6198070Smike#endif
6298070Smike
63113596Snectar#ifndef _SIZE_T_DECLARED
64113596Snectartypedef __size_t	size_t;
65113596Snectar#define _SIZE_T_DECLARED
66113596Snectar#endif
67113596Snectar
682552Sgpalmer#define _PATH_PWD		"/etc"
691539Srgrimes#define	_PATH_PASSWD		"/etc/passwd"
702552Sgpalmer#define	_PASSWD			"passwd"
711539Srgrimes#define	_PATH_MASTERPASSWD	"/etc/master.passwd"
722552Sgpalmer#define	_MASTERPASSWD		"master.passwd"
731539Srgrimes
741539Srgrimes#define	_PATH_MP_DB		"/etc/pwd.db"
752552Sgpalmer#define	_MP_DB			"pwd.db"
761539Srgrimes#define	_PATH_SMP_DB		"/etc/spwd.db"
772552Sgpalmer#define	_SMP_DB			"spwd.db"
781539Srgrimes
791539Srgrimes#define	_PATH_PWD_MKDB		"/usr/sbin/pwd_mkdb"
801539Srgrimes
81113596Snectar#define _PWD_VERSION_KEY	"\xFF" "VERSION"
82113596Snectar#define _PWD_CURRENT_VERSION	'\x04'
831539Srgrimes
84113596Snectar#define _PW_VERSION_MASK	'0xF0'
85113596Snectar#define _PW_VERSION(x)		((unsigned char)((x)<<4))
86113596Snectar
87113596Snectar#define	_PW_KEYBYNAME		'\x01'	/* stored by name */
88113596Snectar#define	_PW_KEYBYNUM		'\x02'	/* stored by entry in the "file" */
89113596Snectar#define	_PW_KEYBYUID		'\x03'	/* stored by uid */
90113596Snectar#define _PW_KEYYPENABLED	'\x04'	/* YP is enabled */
91113596Snectar#define	_PW_KEYYPBYNUM		'\x05'	/* special +@netgroup entries */
92113596Snectar
931539Srgrimes#define	_PASSWORD_EFMT1		'_'	/* extended encryption format */
941539Srgrimes
951539Srgrimes#define	_PASSWORD_LEN		128	/* max length, not counting NULL */
961539Srgrimes
971539Srgrimesstruct passwd {
981539Srgrimes	char	*pw_name;		/* user name */
991539Srgrimes	char	*pw_passwd;		/* encrypted password */
10042780Sdes	uid_t	pw_uid;			/* user uid */
10142780Sdes	gid_t	pw_gid;			/* user gid */
1021539Srgrimes	time_t	pw_change;		/* password change time */
1031539Srgrimes	char	*pw_class;		/* user access class */
1041539Srgrimes	char	*pw_gecos;		/* Honeywell login info */
1051539Srgrimes	char	*pw_dir;		/* home directory */
1061539Srgrimes	char	*pw_shell;		/* default shell */
1071539Srgrimes	time_t	pw_expire;		/* account expiration */
1082915Swollman	int	pw_fields;		/* internal: fields filled in */
1091539Srgrimes};
1101539Srgrimes
1112915Swollman/* Mapping from fields to bits for pw_fields. */
1122915Swollman#define _PWF(x)		(1 << x)
1132915Swollman#define _PWF_NAME	_PWF(0)
1142915Swollman#define _PWF_PASSWD	_PWF(1)
1152915Swollman#define _PWF_UID	_PWF(2)
1162915Swollman#define _PWF_GID	_PWF(3)
1172915Swollman#define _PWF_CHANGE	_PWF(4)
1182915Swollman#define _PWF_CLASS	_PWF(5)
1192915Swollman#define _PWF_GECOS	_PWF(6)
1202915Swollman#define _PWF_DIR	_PWF(7)
1212915Swollman#define _PWF_SHELL	_PWF(8)
1222915Swollman#define _PWF_EXPIRE	_PWF(9)
1232915Swollman
124113596Snectar/* XXX These flags are bogus.  With nsswitch, there are many
125113596Snectar * possible sources and they cannot be represented in a small integer.
126113596Snectar */
12794688Sdes#define _PWF_SOURCE	0x3000
12894688Sdes#define _PWF_FILES	0x1000
12994688Sdes#define _PWF_NIS	0x2000
13094688Sdes#define _PWF_HESIOD	0x3000
13194688Sdes
1321539Srgrimes__BEGIN_DECLS
13398070Smikestruct passwd	*getpwnam(const char *);
13493032Simpstruct passwd	*getpwuid(uid_t);
13598070Smike
13698070Smike#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
13798070Smikevoid		 endpwent(void);
13893032Simpstruct passwd	*getpwent(void);
13998070Smikevoid		 setpwent(void);
140113596Snectarint		 getpwnam_r(const char *, struct passwd *, char *, size_t,
141113596Snectar		    struct passwd **);
142113596Snectarint		 getpwuid_r(uid_t, struct passwd *, char *, size_t,
143113596Snectar		    struct passwd **);
14498070Smike#endif
14598070Smike
14698070Smike#if __BSD_VISIBLE
147113596Snectarint		 getpwent_r(struct passwd *, char *, size_t, struct passwd **);
14893032Simpint		 setpassent(int);
14993032Simpconst char	*user_from_uid(uid_t, int);
1501539Srgrimes#endif
1511539Srgrimes__END_DECLS
1521539Srgrimes
1531539Srgrimes#endif /* !_PWD_H_ */
154