sl@0: /*-
sl@0:  * Copyright (c) 1989, 1993
sl@0:  *	The Regents of the University of California.  All rights reserved.
sl@0:  * (c) UNIX System Laboratories, Inc.
sl@0:  * All or some portions of this file are derived from material licensed
sl@0:  * to the University of California by American Telephone and Telegraph
sl@0:  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
sl@0:  * the permission of UNIX System Laboratories, Inc.
sl@0:  *
sl@0:  * Redistribution and use in source and binary forms, with or without
sl@0:  * modification, are permitted provided that the following conditions
sl@0:  * are met:
sl@0:  * 1. Redistributions of source code must retain the above copyright
sl@0:  *    notice, this list of conditions and the following disclaimer.
sl@0:  * 2. Redistributions in binary form must reproduce the above copyright
sl@0:  *    notice, this list of conditions and the following disclaimer in the
sl@0:  *    documentation and/or other materials provided with the distribution.
sl@0:  * 4. Neither the name of the University nor the names of its contributors
sl@0:  *    may be used to endorse or promote products derived from this software
sl@0:  *    without specific prior written permission.
sl@0:  *
sl@0:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
sl@0:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
sl@0:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0:  * SUCH DAMAGE.
sl@0:  *
sl@0:  *	@(#)pwd.h	8.2 (Berkeley) 1/21/94
sl@0:  * $FreeBSD: src/include/pwd.h,v 1.16 2005/01/26 17:26:54 nectar Exp $
sl@0:  * © Portions copyright (c) 2005-2006 Nokia Corporation.  All rights reserved.
sl@0:  */
sl@0: 
sl@0: #ifndef _PWD_H_
sl@0: #define	_PWD_H_
sl@0: 
sl@0: #include <sys/cdefs.h>
sl@0: #include <sys/_types.h>
sl@0: 
sl@0: #ifndef _GID_T_DECLARED
sl@0: typedef	__gid_t		gid_t;
sl@0: #define	_GID_T_DECLARED
sl@0: #endif
sl@0: 
sl@0: #ifndef _TIME_T_DECLARED
sl@0: typedef	__time_t	time_t;
sl@0: #define	_TIME_T_DECLARED
sl@0: #endif
sl@0: 
sl@0: #ifndef _UID_T_DECLARED
sl@0: typedef	__uid_t		uid_t;
sl@0: #define	_UID_T_DECLARED
sl@0: #endif
sl@0: 
sl@0: #ifndef _SIZE_T_DECLARED
sl@0: typedef __size_t	size_t;
sl@0: #define _SIZE_T_DECLARED
sl@0: #endif
sl@0: 
sl@0: #define _PATH_PWD		"/etc"
sl@0: #define	_PATH_PASSWD		"/etc/passwd"
sl@0: #define	_PASSWD			"passwd"
sl@0: #define	_PATH_MASTERPASSWD	"/etc/master.passwd"
sl@0: #define	_MASTERPASSWD		"master.passwd"
sl@0: 
sl@0: #define	_PATH_MP_DB		"/etc/pwd.db"
sl@0: #define	_MP_DB			"pwd.db"
sl@0: #define	_PATH_SMP_DB		"/etc/spwd.db"
sl@0: #define	_SMP_DB			"spwd.db"
sl@0: 
sl@0: #define	_PATH_PWD_MKDB		"/usr/sbin/pwd_mkdb"
sl@0: 
sl@0: /* Historically, the keys in _PATH_MP_DB/_PATH_SMP_DB had the format
sl@0:  * `1 octet tag | key', where the tag is one of the _PW_KEY* values
sl@0:  * listed below.  These values happen to be ASCII digits.  Starting
sl@0:  * with FreeBSD 5.1, the tag is now still a single octet, but the
sl@0:  * upper 4 bits are interpreted as a version.  Pre-FreeBSD 5.1 format
sl@0:  * entries are version `3' -- this conveniently results in the same
sl@0:  * key values as before.  The new, architecture-independent entries
sl@0:  * are version `4'.
sl@0:  * As it happens, some applications read the database directly.
sl@0:  * (Bad app, no cookie!)  Thus, we leave the _PW_KEY* symbols at their
sl@0:  * old pre-FreeBSD 5.1 values so these apps still work.  Consequently
sl@0:  * we have to muck around a bit more to get the correct, versioned
sl@0:  * tag, and that is what the _PW_VERSIONED macro is about.
sl@0:  */
sl@0: 
sl@0: #define _PW_VERSION_MASK	'\xF0'
sl@0: #define _PW_VERSIONED(x, v)	((unsigned char)(((x) & 0xCF) | ((v)<<4)))
sl@0: 
sl@0: #define	_PW_KEYBYNAME		'\x31'	/* stored by name */
sl@0: #define	_PW_KEYBYNUM		'\x32'	/* stored by entry in the "file" */
sl@0: #define	_PW_KEYBYUID		'\x33'	/* stored by uid */
sl@0: #define _PW_KEYYPENABLED	'\x34'	/* YP is enabled */
sl@0: #define	_PW_KEYYPBYNUM		'\x35'	/* special +  @ netgroup entries */
sl@0: 
sl@0: /* The database also contains a key to indicate the format version of
sl@0:  * the entries therein.  There may be other, older versioned entries
sl@0:  * as well.
sl@0:  */
sl@0: #define _PWD_VERSION_KEY	"\xFF" "VERSION"
sl@0: #define _PWD_CURRENT_VERSION	'\x04'
sl@0: 
sl@0: #define	_PASSWORD_EFMT1		'_'	/* extended encryption format */
sl@0: 
sl@0: #define	_PASSWORD_LEN		128	/* max length, not counting NULL */
sl@0: 
sl@0: struct passwd {
sl@0: 	char	*pw_name;		/* user name */
sl@0: 	char	*pw_passwd;		/* encrypted password */
sl@0: 	uid_t	pw_uid;			/* user uid */
sl@0: 	gid_t	pw_gid;			/* user gid */
sl@0: 	time_t	pw_change;		/* password change time */
sl@0: 	char	*pw_class;		/* user access class */
sl@0: 	char	*pw_gecos;		/* Honeywell login info */
sl@0: 	char	*pw_dir;		/* home directory */
sl@0: 	char	*pw_shell;		/* default shell */
sl@0: 	time_t	pw_expire;		/* account expiration */
sl@0: 	int	pw_fields;		/* internal: fields filled in */
sl@0: };
sl@0: 
sl@0: /* Mapping from fields to bits for pw_fields. */
sl@0: #define _PWF(x)		(1 << x)
sl@0: #define _PWF_NAME	_PWF(0)
sl@0: #define _PWF_PASSWD	_PWF(1)
sl@0: #define _PWF_UID	_PWF(2)
sl@0: #define _PWF_GID	_PWF(3)
sl@0: #define _PWF_CHANGE	_PWF(4)
sl@0: #define _PWF_CLASS	_PWF(5)
sl@0: #define _PWF_GECOS	_PWF(6)
sl@0: #define _PWF_DIR	_PWF(7)
sl@0: #define _PWF_SHELL	_PWF(8)
sl@0: #define _PWF_EXPIRE	_PWF(9)
sl@0: 
sl@0: /* XXX These flags are bogus.  With nsswitch, there are many
sl@0:  * possible sources and they cannot be represented in a small integer.
sl@0:  */                           
sl@0: #define _PWF_SOURCE	0x3000
sl@0: #define _PWF_FILES	0x1000
sl@0: #define _PWF_NIS	0x2000
sl@0: #define _PWF_HESIOD	0x3000
sl@0: 
sl@0: __BEGIN_DECLS
sl@0: IMPORT_C struct passwd	*getpwnam(const char *);
sl@0: IMPORT_C struct passwd	*getpwuid(uid_t);
sl@0: 
sl@0: #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
sl@0: IMPORT_C void		 endpwent(void);
sl@0: IMPORT_C struct passwd	*getpwent(void);
sl@0: IMPORT_C void		 setpwent(void);
sl@0: IMPORT_C int		 getpwnam_r(const char *, struct passwd *, char *, size_t,
sl@0: 		    struct passwd **);
sl@0: IMPORT_C int		 getpwuid_r(uid_t, struct passwd *, char *, size_t,
sl@0: 		    struct passwd **);
sl@0: #endif
sl@0: 
sl@0: __END_DECLS
sl@0: 
sl@0: #endif /* !_PWD_H_ */