xref: /minix3/include/pwd.h (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc /*	$NetBSD: pwd.h,v 1.44 2012/11/26 19:53:41 pooka Exp $	*/
29865aeaaSBen Gras 
32fe8fb19SBen Gras /*-
42fe8fb19SBen Gras  * Copyright (c) 1989, 1993
52fe8fb19SBen Gras  *	The Regents of the University of California.  All rights reserved.
62fe8fb19SBen Gras  * (c) UNIX System Laboratories, Inc.
72fe8fb19SBen Gras  * All or some portions of this file are derived from material licensed
82fe8fb19SBen Gras  * to the University of California by American Telephone and Telegraph
92fe8fb19SBen Gras  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
102fe8fb19SBen Gras  * the permission of UNIX System Laboratories, Inc.
112fe8fb19SBen Gras  *
122fe8fb19SBen Gras  * Redistribution and use in source and binary forms, with or without
132fe8fb19SBen Gras  * modification, are permitted provided that the following conditions
142fe8fb19SBen Gras  * are met:
152fe8fb19SBen Gras  * 1. Redistributions of source code must retain the above copyright
162fe8fb19SBen Gras  *    notice, this list of conditions and the following disclaimer.
172fe8fb19SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
182fe8fb19SBen Gras  *    notice, this list of conditions and the following disclaimer in the
192fe8fb19SBen Gras  *    documentation and/or other materials provided with the distribution.
202fe8fb19SBen Gras  * 3. Neither the name of the University nor the names of its contributors
212fe8fb19SBen Gras  *    may be used to endorse or promote products derived from this software
222fe8fb19SBen Gras  *    without specific prior written permission.
232fe8fb19SBen Gras  *
242fe8fb19SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
252fe8fb19SBen Gras  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
262fe8fb19SBen Gras  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
272fe8fb19SBen Gras  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
282fe8fb19SBen Gras  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
292fe8fb19SBen Gras  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
302fe8fb19SBen Gras  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
312fe8fb19SBen Gras  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
322fe8fb19SBen Gras  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
332fe8fb19SBen Gras  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
342fe8fb19SBen Gras  * SUCH DAMAGE.
352fe8fb19SBen Gras  *
362fe8fb19SBen Gras  *	@(#)pwd.h	8.2 (Berkeley) 1/21/94
372fe8fb19SBen Gras  */
389865aeaaSBen Gras 
392fe8fb19SBen Gras /*-
402fe8fb19SBen Gras  * Portions Copyright(C) 1995, Jason Downs.  All rights reserved.
412fe8fb19SBen Gras  *
422fe8fb19SBen Gras  * Redistribution and use in source and binary forms, with or without
432fe8fb19SBen Gras  * modification, are permitted provided that the following conditions
442fe8fb19SBen Gras  * are met:
452fe8fb19SBen Gras  * 1. Redistributions of source code must retain the above copyright
462fe8fb19SBen Gras  *    notice, this list of conditions and the following disclaimer.
472fe8fb19SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
482fe8fb19SBen Gras  *    notice, this list of conditions and the following disclaimer in the
492fe8fb19SBen Gras  *    documentation and/or other materials provided with the distribution.
502fe8fb19SBen Gras  *
512fe8fb19SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
522fe8fb19SBen Gras  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
532fe8fb19SBen Gras  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
542fe8fb19SBen Gras  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
552fe8fb19SBen Gras  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
562fe8fb19SBen Gras  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
572fe8fb19SBen Gras  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
582fe8fb19SBen Gras  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
592fe8fb19SBen Gras  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
602fe8fb19SBen Gras  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
612fe8fb19SBen Gras  * SUCH DAMAGE.
622fe8fb19SBen Gras  */
632fe8fb19SBen Gras 
642fe8fb19SBen Gras #ifndef _PWD_H_
652fe8fb19SBen Gras #define	_PWD_H_
662fe8fb19SBen Gras 
672fe8fb19SBen Gras #include <sys/cdefs.h>
682fe8fb19SBen Gras #include <sys/featuretest.h>
692fe8fb19SBen Gras #include <sys/types.h>
702fe8fb19SBen Gras 
712fe8fb19SBen Gras #if defined(_NETBSD_SOURCE) || defined(HAVE_NBTOOL_CONFIG_H)
722fe8fb19SBen Gras #define	_PATH_PASSWD		"/etc/passwd"
732fe8fb19SBen Gras #define	_PATH_MASTERPASSWD	"/etc/master.passwd"
742fe8fb19SBen Gras #define	_PATH_MASTERPASSWD_LOCK	"/etc/ptmp"
752fe8fb19SBen Gras 
762fe8fb19SBen Gras #define	_PATH_PASSWD_CONF	"/etc/passwd.conf"
772fe8fb19SBen Gras #define	_PATH_PASSWDCONF	_PATH_PASSWD_CONF	/* XXX: compat */
782fe8fb19SBen Gras #define	_PATH_USERMGMT_CONF	"/etc/usermgmt.conf"
792fe8fb19SBen Gras 
802fe8fb19SBen Gras #define	_PATH_MP_DB		"/etc/pwd.db"
812fe8fb19SBen Gras #define	_PATH_SMP_DB		"/etc/spwd.db"
822fe8fb19SBen Gras 
832fe8fb19SBen Gras #define	_PATH_PWD_MKDB		"/usr/sbin/pwd_mkdb"
842fe8fb19SBen Gras 
852fe8fb19SBen Gras #define	_PW_KEYBYNAME		'1'	/* stored by name */
862fe8fb19SBen Gras #define	_PW_KEYBYNUM		'2'	/* stored by entry in the "file" */
872fe8fb19SBen Gras #define	_PW_KEYBYUID		'3'	/* stored by uid */
882fe8fb19SBen Gras 
892fe8fb19SBen Gras #define	_PASSWORD_EFMT1		'_'	/* extended DES encryption format */
902fe8fb19SBen Gras #define	_PASSWORD_NONDES	'$'	/* non-DES encryption formats */
912fe8fb19SBen Gras 
922fe8fb19SBen Gras #define	_PASSWORD_LEN		128	/* max length, not counting NUL */
932fe8fb19SBen Gras 
942fe8fb19SBen Gras #define _PASSWORD_NOUID		0x01	/* flag for no specified uid. */
952fe8fb19SBen Gras #define _PASSWORD_NOGID		0x02	/* flag for no specified gid. */
962fe8fb19SBen Gras #define _PASSWORD_NOCHG		0x04	/* flag for no specified change. */
972fe8fb19SBen Gras #define _PASSWORD_NOEXP		0x08	/* flag for no specified expire. */
982fe8fb19SBen Gras 
992fe8fb19SBen Gras #define _PASSWORD_OLDFMT	0x10	/* flag to expect an old style entry */
1002fe8fb19SBen Gras #define _PASSWORD_NOWARN	0x20	/* no warnings for bad entries */
1012fe8fb19SBen Gras 
1022fe8fb19SBen Gras #define _PASSWORD_WARNDAYS	14	/* days to warn about expiry */
1032fe8fb19SBen Gras #define _PASSWORD_CHGNOW	-1	/* special day to force password
1042fe8fb19SBen Gras 					 * change at next login */
1059865aeaaSBen Gras #endif
1069865aeaaSBen Gras 
1079865aeaaSBen Gras struct passwd {
1082fe8fb19SBen Gras 	__aconst char *pw_name;		/* user name */
1092fe8fb19SBen Gras 	__aconst char *pw_passwd;	/* encrypted password */
1102fe8fb19SBen Gras 	uid_t	       pw_uid;		/* user uid */
1112fe8fb19SBen Gras 	gid_t	       pw_gid;		/* user gid */
1122fe8fb19SBen Gras 	time_t	       pw_change;	/* password change time */
1132fe8fb19SBen Gras 	__aconst char *pw_class;	/* user login class */
1142fe8fb19SBen Gras 	__aconst char *pw_gecos;	/* general information */
1152fe8fb19SBen Gras 	__aconst char *pw_dir;		/* home directory */
1162fe8fb19SBen Gras 	__aconst char *pw_shell;	/* default shell */
1172fe8fb19SBen Gras 	time_t 	       pw_expire;	/* account expiration */
1189865aeaaSBen Gras };
1199865aeaaSBen Gras 
1202fe8fb19SBen Gras __BEGIN_DECLS
1212fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
1222fe8fb19SBen Gras struct passwd	*getpwuid(uid_t) __RENAME(__getpwuid50);
1232fe8fb19SBen Gras struct passwd	*getpwnam(const char *) __RENAME(__getpwnam50);
1249865aeaaSBen Gras #endif
1252fe8fb19SBen Gras #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
1262fe8fb19SBen Gras     defined(_REENTRANT) || defined(_NETBSD_SOURCE)
1272fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
1282fe8fb19SBen Gras int		 getpwnam_r(const char *, struct passwd *, char *, size_t,
1292fe8fb19SBen Gras     struct passwd **) __RENAME(__getpwnam_r50);
1302fe8fb19SBen Gras int		 getpwuid_r(uid_t, struct passwd *, char *, size_t,
1312fe8fb19SBen Gras     struct passwd **) __RENAME(__getpwuid_r50);
1322fe8fb19SBen Gras #endif
1332fe8fb19SBen Gras #endif
1342fe8fb19SBen Gras #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
1352fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
1362fe8fb19SBen Gras struct passwd	*getpwent(void) __RENAME(__getpwent50);
1372fe8fb19SBen Gras #endif
1382fe8fb19SBen Gras void		 setpwent(void);
1392fe8fb19SBen Gras void		 endpwent(void);
1402fe8fb19SBen Gras #endif
1412fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
1422fe8fb19SBen Gras int		 pw_gensalt(char *, size_t, const char *, const char *);
1432fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
1442fe8fb19SBen Gras int		 pw_scan(char *, struct passwd *, int *) __RENAME(__pw_scan50);
1452fe8fb19SBen Gras int		 getpwent_r(struct passwd *, char *, size_t, struct passwd **)
1462fe8fb19SBen Gras     __RENAME(__getpwent_r50);
1472fe8fb19SBen Gras #endif
1482fe8fb19SBen Gras int		 setpassent(int);
1492fe8fb19SBen Gras const char	*user_from_uid(uid_t, int);
1502fe8fb19SBen Gras int		 uid_from_user(const char *, uid_t *);
1512fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
1522fe8fb19SBen Gras int		 pwcache_userdb(int (*)(int), void (*)(void),
1532fe8fb19SBen Gras     struct passwd * (*)(const char *), struct passwd * (*)(uid_t))
1542fe8fb19SBen Gras     __RENAME(__pwcache_userdb50);
1552fe8fb19SBen Gras #endif
1562fe8fb19SBen Gras #endif
1572fe8fb19SBen Gras __END_DECLS
1589865aeaaSBen Gras 
1592fe8fb19SBen Gras #endif /* !_PWD_H_ */
160