1/*-
  2 * Copyright (c) 1989, 1993
  3 *	The Regents of the University of California.  All rights reserved.
  4 * (c) UNIX System Laboratories, Inc.
  5 * All or some portions of this file are derived from material licensed
  6 * to the University of California by American Telephone and Telegraph
  7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  8 * the permission of UNIX System Laboratories, Inc.
  9 * Portions Copyright(C) 1995, Jason Downs.  All rights reserved.
 10 *
 11 * Redistribution and use in source and binary forms, with or without
 12 * modification, are permitted provided that the following conditions
 13 * are met:
 14 * 1. Redistributions of source code must retain the above copyright
 15 *    notice, this list of conditions and the following disclaimer.
 16 * 2. Redistributions in binary form must reproduce the above copyright
 17 *    notice, this list of conditions and the following disclaimer in the
 18 *    documentation and/or other materials provided with the distribution.
 19 * 3. All advertising materials mentioning features or use of this software
 20 *    must display the following acknowledgement:
 21 *	This product includes software developed by the University of
 22 *	California, Berkeley and its contributors.
 23 * 4. Neither the name of the University nor the names of its contributors
 24 *    may be used to endorse or promote products derived from this software
 25 *    without specific prior written permission.
 26 *
 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 30 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 37 * SUCH DAMAGE.
 38 *
 39 *	@(#)pwd.h	8.2 (Berkeley) 1/21/94
 40 */
 41/* Portions copyright (c) 2000-2011 Apple Inc. All rights reserved. */
 42
 43#ifndef _PWD_H_
 44#define	_PWD_H_
 45
 46#include <_types.h>
 47#include <sys/_types/_gid_t.h>
 48#include <sys/_types/_size_t.h>
 49#include <sys/_types/_uid_t.h>
 50
 51#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
 52#define	_PATH_PWD		"/etc"
 53#define	_PATH_PASSWD		"/etc/passwd"
 54#define	_PASSWD			"passwd"
 55#define	_PATH_MASTERPASSWD	"/etc/master.passwd"
 56#define	_PATH_MASTERPASSWD_LOCK	"/etc/ptmp"
 57#define	_MASTERPASSWD		"master.passwd"
 58
 59#define	_PATH_MP_DB		"/etc/pwd.db"
 60#define	_MP_DB			"pwd.db"
 61#define	_PATH_SMP_DB		"/etc/spwd.db"
 62#define	_SMP_DB			"spwd.db"
 63
 64#define	_PATH_PWD_MKDB		"/usr/sbin/pwd_mkdb"
 65
 66#define	_PW_KEYBYNAME		'1'	/* stored by name */
 67#define	_PW_KEYBYNUM		'2'	/* stored by entry in the "file" */
 68#define	_PW_KEYBYUID		'3'	/* stored by uid */
 69
 70#define	_PASSWORD_EFMT1		'_'	/* extended encryption format */
 71
 72#define	_PASSWORD_LEN		128	/* max length, not counting NULL */
 73
 74#define _PASSWORD_NOUID		0x01	/* flag for no specified uid. */
 75#define _PASSWORD_NOGID		0x02	/* flag for no specified gid. */
 76#define _PASSWORD_NOCHG		0x04	/* flag for no specified change. */
 77#define _PASSWORD_NOEXP		0x08	/* flag for no specified expire. */
 78
 79#define _PASSWORD_WARNDAYS	14	/* days to warn about expiry */
 80#define _PASSWORD_CHGNOW	-1	/* special day to force password
 81					 * change at next login */
 82#endif
 83
 84struct passwd {
 85	char	*pw_name;		/* user name */
 86	char	*pw_passwd;		/* encrypted password */
 87	uid_t	pw_uid;			/* user uid */
 88	gid_t	pw_gid;			/* user gid */
 89	__darwin_time_t pw_change;		/* password change time */
 90	char	*pw_class;		/* user access class */
 91	char	*pw_gecos;		/* Honeywell login info */
 92	char	*pw_dir;		/* home directory */
 93	char	*pw_shell;		/* default shell */
 94	__darwin_time_t pw_expire;		/* account expiration */
 95};
 96
 97#include <sys/cdefs.h>
 98
 99__BEGIN_DECLS
100struct passwd	*getpwuid(uid_t);
101struct passwd	*getpwnam(const char *);
102int		 getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **);
103int		 getpwnam_r(const char *, struct passwd *, char *, size_t, struct passwd **);
104struct passwd	*getpwent(void);
105void		 setpwent(void);
106void		 endpwent(void);
107__END_DECLS
108
109#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
110#include <uuid/uuid.h>
111__BEGIN_DECLS
112int		 setpassent(int);
113char 		*user_from_uid(uid_t, int);
114struct passwd	*getpwuuid(uuid_t);
115int		 getpwuuid_r(uuid_t, struct passwd *, char *, size_t, struct passwd **);
116__END_DECLS
117#endif
118
119#endif /* !_PWD_H_ */