xref: /openbsd/include/pwd.h (revision 5a122e6e)
1*5a122e6eSmillert /*	$OpenBSD: pwd.h,v 1.26 2018/09/13 12:31:15 millert Exp $	*/
24b826ba8Sderaadt /*	$NetBSD: pwd.h,v 1.9 1996/05/15 21:36:45 jtc Exp $	*/
3df930be7Sderaadt 
4df930be7Sderaadt /*-
5df930be7Sderaadt  * Copyright (c) 1989, 1993
6df930be7Sderaadt  *	The Regents of the University of California.  All rights reserved.
7df930be7Sderaadt  * (c) UNIX System Laboratories, Inc.
8df930be7Sderaadt  * All or some portions of this file are derived from material licensed
9df930be7Sderaadt  * to the University of California by American Telephone and Telegraph
10df930be7Sderaadt  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11df930be7Sderaadt  * the permission of UNIX System Laboratories, Inc.
12d77ce7d6Sdownsj  * Portions Copyright(C) 1995, 1996, Jason Downs.  All rights reserved.
13df930be7Sderaadt  *
14df930be7Sderaadt  * Redistribution and use in source and binary forms, with or without
15df930be7Sderaadt  * modification, are permitted provided that the following conditions
16df930be7Sderaadt  * are met:
17df930be7Sderaadt  * 1. Redistributions of source code must retain the above copyright
18df930be7Sderaadt  *    notice, this list of conditions and the following disclaimer.
19df930be7Sderaadt  * 2. Redistributions in binary form must reproduce the above copyright
20df930be7Sderaadt  *    notice, this list of conditions and the following disclaimer in the
21df930be7Sderaadt  *    documentation and/or other materials provided with the distribution.
22e33d3bd3Smillert  * 3. Neither the name of the University nor the names of its contributors
23df930be7Sderaadt  *    may be used to endorse or promote products derived from this software
24df930be7Sderaadt  *    without specific prior written permission.
25df930be7Sderaadt  *
26df930be7Sderaadt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27df930be7Sderaadt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28df930be7Sderaadt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29df930be7Sderaadt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30df930be7Sderaadt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31df930be7Sderaadt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32df930be7Sderaadt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33df930be7Sderaadt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34df930be7Sderaadt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35df930be7Sderaadt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36df930be7Sderaadt  * SUCH DAMAGE.
37df930be7Sderaadt  *
38df930be7Sderaadt  *	@(#)pwd.h	8.2 (Berkeley) 1/21/94
39df930be7Sderaadt  */
40df930be7Sderaadt 
41df930be7Sderaadt #ifndef _PWD_H_
42df930be7Sderaadt #define	_PWD_H_
43df930be7Sderaadt 
44df930be7Sderaadt #include <sys/types.h>
45df930be7Sderaadt 
4652a0e603Smillert #if __BSD_VISIBLE
47df930be7Sderaadt #define	_PATH_PASSWD		"/etc/passwd"
48df930be7Sderaadt #define	_PATH_MASTERPASSWD	"/etc/master.passwd"
494b826ba8Sderaadt #define	_PATH_MASTERPASSWD_LOCK	"/etc/ptmp"
50df930be7Sderaadt 
51df930be7Sderaadt #define	_PATH_MP_DB		"/etc/pwd.db"
52df930be7Sderaadt #define	_PATH_SMP_DB		"/etc/spwd.db"
53df930be7Sderaadt 
54df930be7Sderaadt #define	_PATH_PWD_MKDB		"/usr/sbin/pwd_mkdb"
55df930be7Sderaadt 
56df930be7Sderaadt #define	_PW_KEYBYNAME		'1'	/* stored by name */
57df930be7Sderaadt #define	_PW_KEYBYNUM		'2'	/* stored by entry in the "file" */
58df930be7Sderaadt #define	_PW_KEYBYUID		'3'	/* stored by uid */
59df930be7Sderaadt 
60d77ce7d6Sdownsj #define _PW_YPTOKEN		"__YP!"
61d77ce7d6Sdownsj 
62df930be7Sderaadt #define	_PASSWORD_EFMT1		'_'	/* extended encryption format */
63df930be7Sderaadt 
6418ddd217Spjanzen #define	_PASSWORD_LEN		128	/* max length, not counting NUL */
6518ddd217Spjanzen #define	_PW_NAME_LEN		31	/* max length, not counting NUL */
6618ddd217Spjanzen 					/* Should be MAXLOGNAME - 1 */
67c39c6cccSmillert #define _PW_BUF_LEN		1024	/* length of getpw*_r buffer */
68df930be7Sderaadt 
69df930be7Sderaadt #define _PASSWORD_NOUID		0x01	/* flag for no specified uid. */
70df930be7Sderaadt #define _PASSWORD_NOGID		0x02	/* flag for no specified gid. */
71df930be7Sderaadt #define _PASSWORD_NOCHG		0x04	/* flag for no specified change. */
72df930be7Sderaadt #define _PASSWORD_NOEXP		0x08	/* flag for no specified expire. */
73df930be7Sderaadt 
7400ca34bfSmillert /* Flags for pw_mkdb(3) */
7500ca34bfSmillert #define	_PASSWORD_SECUREONLY	0x01	/* only generate spwd.db file */
7600ca34bfSmillert #define	_PASSWORD_OMITV7	0x02	/* don't generate v7 passwd file */
7700ca34bfSmillert 
78df930be7Sderaadt #endif
79df930be7Sderaadt 
80df930be7Sderaadt struct passwd {
81df930be7Sderaadt 	char	*pw_name;		/* user name */
82df930be7Sderaadt 	char	*pw_passwd;		/* encrypted password */
835883413aSmillert 	uid_t	pw_uid;			/* user uid */
843a4d0b15Smillert 	gid_t	pw_gid;			/* user gid */
85df930be7Sderaadt 	time_t	pw_change;		/* password change time */
86df930be7Sderaadt 	char	*pw_class;		/* user access class */
87df930be7Sderaadt 	char	*pw_gecos;		/* Honeywell login info */
88df930be7Sderaadt 	char	*pw_dir;		/* home directory */
89df930be7Sderaadt 	char	*pw_shell;		/* default shell */
90df930be7Sderaadt 	time_t	pw_expire;		/* account expiration */
91df930be7Sderaadt };
92df930be7Sderaadt 
93df930be7Sderaadt __BEGIN_DECLS
94c72b5b24Smillert struct passwd	*getpwuid(uid_t);
95c72b5b24Smillert struct passwd	*getpwnam(const char *);
968a63353aStedu struct passwd	*getpwuid_shadow(uid_t);
978a63353aStedu struct passwd	*getpwnam_shadow(const char *);
989eb309bbSderaadt int		getpwnam_r(const char *, struct passwd *, char *, size_t,
9915afe4d6Sfcambus 		    struct passwd **);
10015afe4d6Sfcambus int		getpwuid_r(uid_t, struct passwd *, char *, size_t,
10115afe4d6Sfcambus 		    struct passwd **);
10252a0e603Smillert #if __BSD_VISIBLE || __XPG_VISIBLE
103c72b5b24Smillert struct passwd	*getpwent(void);
10452a0e603Smillert void		 setpwent(void);
10552a0e603Smillert void		 endpwent(void);
10652a0e603Smillert #endif
10752a0e603Smillert #if __BSD_VISIBLE
108c72b5b24Smillert int		 setpassent(int);
109*5a122e6eSmillert int		 uid_from_user(const char *, uid_t *);
110*5a122e6eSmillert const char	*user_from_uid(uid_t, int);
111c72b5b24Smillert char		*bcrypt_gensalt(u_int8_t);
112f8acaf4dSdjm char		*bcrypt(const char *, const char *);
1135f712945Stedu int		bcrypt_newhash(const char *, int, char *, size_t);
1145f712945Stedu int		bcrypt_checkpass(const char *, const char *);
115c72b5b24Smillert struct passwd	*pw_dup(const struct passwd *);
116df930be7Sderaadt #endif
117df930be7Sderaadt __END_DECLS
118df930be7Sderaadt 
119df930be7Sderaadt #endif /* !_PWD_H_ */
120