1*169dfff6Spooka /* $NetBSD: pwd.h,v 1.44 2012/11/26 19:53:41 pooka Exp $ */ 24d2cbfceScgd 3e6b5ddd9Scgd /*- 4e6b5ddd9Scgd * Copyright (c) 1989, 1993 5e6b5ddd9Scgd * The Regents of the University of California. All rights reserved. 6e6b5ddd9Scgd * (c) UNIX System Laboratories, Inc. 7e6b5ddd9Scgd * All or some portions of this file are derived from material licensed 8e6b5ddd9Scgd * to the University of California by American Telephone and Telegraph 9e6b5ddd9Scgd * Co. or Unix System Laboratories, Inc. and are reproduced herein with 10e6b5ddd9Scgd * the permission of UNIX System Laboratories, Inc. 11039cc956Sagc * 12039cc956Sagc * Redistribution and use in source and binary forms, with or without 13039cc956Sagc * modification, are permitted provided that the following conditions 14039cc956Sagc * are met: 15039cc956Sagc * 1. Redistributions of source code must retain the above copyright 16039cc956Sagc * notice, this list of conditions and the following disclaimer. 17039cc956Sagc * 2. Redistributions in binary form must reproduce the above copyright 18039cc956Sagc * notice, this list of conditions and the following disclaimer in the 19039cc956Sagc * documentation and/or other materials provided with the distribution. 20039cc956Sagc * 3. Neither the name of the University nor the names of its contributors 21039cc956Sagc * may be used to endorse or promote products derived from this software 22039cc956Sagc * without specific prior written permission. 23039cc956Sagc * 24039cc956Sagc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25039cc956Sagc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26039cc956Sagc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27039cc956Sagc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28039cc956Sagc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29039cc956Sagc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30039cc956Sagc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31039cc956Sagc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32039cc956Sagc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33039cc956Sagc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34039cc956Sagc * SUCH DAMAGE. 35039cc956Sagc * 36039cc956Sagc * @(#)pwd.h 8.2 (Berkeley) 1/21/94 37039cc956Sagc */ 38039cc956Sagc 39039cc956Sagc /*- 406452a2f6Sphil * Portions Copyright(C) 1995, Jason Downs. All rights reserved. 41e6b5ddd9Scgd * 42e6b5ddd9Scgd * Redistribution and use in source and binary forms, with or without 43e6b5ddd9Scgd * modification, are permitted provided that the following conditions 44e6b5ddd9Scgd * are met: 45e6b5ddd9Scgd * 1. Redistributions of source code must retain the above copyright 46e6b5ddd9Scgd * notice, this list of conditions and the following disclaimer. 47e6b5ddd9Scgd * 2. Redistributions in binary form must reproduce the above copyright 48e6b5ddd9Scgd * notice, this list of conditions and the following disclaimer in the 49e6b5ddd9Scgd * documentation and/or other materials provided with the distribution. 50e6b5ddd9Scgd * 519f1aac5bSagc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS 529f1aac5bSagc * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 539f1aac5bSagc * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 549f1aac5bSagc * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, 559f1aac5bSagc * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 569f1aac5bSagc * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 579f1aac5bSagc * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 589f1aac5bSagc * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 59e6b5ddd9Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 60e6b5ddd9Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 61e6b5ddd9Scgd * SUCH DAMAGE. 62e6b5ddd9Scgd */ 63e6b5ddd9Scgd 64*169dfff6Spooka #ifndef _PWD_H_ 65e6b5ddd9Scgd #define _PWD_H_ 66e6b5ddd9Scgd 67633b8f45Smycroft #include <sys/cdefs.h> 686ea15afcSkleink #include <sys/featuretest.h> 69e6b5ddd9Scgd #include <sys/types.h> 70e6b5ddd9Scgd 71b2f78261Sjmc #if defined(_NETBSD_SOURCE) || defined(HAVE_NBTOOL_CONFIG_H) 72e6b5ddd9Scgd #define _PATH_PASSWD "/etc/passwd" 73e6b5ddd9Scgd #define _PATH_MASTERPASSWD "/etc/master.passwd" 742a909cc6Sjtc #define _PATH_MASTERPASSWD_LOCK "/etc/ptmp" 75e6b5ddd9Scgd 76b2a1c144Slukem #define _PATH_PASSWD_CONF "/etc/passwd.conf" 77b2a1c144Slukem #define _PATH_PASSWDCONF _PATH_PASSWD_CONF /* XXX: compat */ 78b2a1c144Slukem #define _PATH_USERMGMT_CONF "/etc/usermgmt.conf" 79b2a1c144Slukem 80e6b5ddd9Scgd #define _PATH_MP_DB "/etc/pwd.db" 81e6b5ddd9Scgd #define _PATH_SMP_DB "/etc/spwd.db" 82e6b5ddd9Scgd 83e6b5ddd9Scgd #define _PATH_PWD_MKDB "/usr/sbin/pwd_mkdb" 84e6b5ddd9Scgd 85e6b5ddd9Scgd #define _PW_KEYBYNAME '1' /* stored by name */ 86e6b5ddd9Scgd #define _PW_KEYBYNUM '2' /* stored by entry in the "file" */ 87e6b5ddd9Scgd #define _PW_KEYBYUID '3' /* stored by uid */ 88e6b5ddd9Scgd 890940cdc6Sad #define _PASSWORD_EFMT1 '_' /* extended DES encryption format */ 90481a5b22Sad #define _PASSWORD_NONDES '$' /* non-DES encryption formats */ 91e6b5ddd9Scgd 92c95251a4Skleink #define _PASSWORD_LEN 128 /* max length, not counting NUL */ 936452a2f6Sphil 946452a2f6Sphil #define _PASSWORD_NOUID 0x01 /* flag for no specified uid. */ 956452a2f6Sphil #define _PASSWORD_NOGID 0x02 /* flag for no specified gid. */ 966452a2f6Sphil #define _PASSWORD_NOCHG 0x04 /* flag for no specified change. */ 976452a2f6Sphil #define _PASSWORD_NOEXP 0x08 /* flag for no specified expire. */ 986452a2f6Sphil 99986a30c8Slukem #define _PASSWORD_OLDFMT 0x10 /* flag to expect an old style entry */ 100986a30c8Slukem #define _PASSWORD_NOWARN 0x20 /* no warnings for bad entries */ 101986a30c8Slukem 102e7fb77daSlukem #define _PASSWORD_WARNDAYS 14 /* days to warn about expiry */ 10304a72f75Slukem #define _PASSWORD_CHGNOW -1 /* special day to force password 10404a72f75Slukem * change at next login */ 105e6b5ddd9Scgd #endif 106e6b5ddd9Scgd 107e6b5ddd9Scgd struct passwd { 108633b8f45Smycroft __aconst char *pw_name; /* user name */ 109633b8f45Smycroft __aconst char *pw_passwd; /* encrypted password */ 110c2219d6aSmsaitoh uid_t pw_uid; /* user uid */ 111c2219d6aSmsaitoh gid_t pw_gid; /* user gid */ 112e6b5ddd9Scgd time_t pw_change; /* password change time */ 11345a7a692Slukem __aconst char *pw_class; /* user login class */ 11445a7a692Slukem __aconst char *pw_gecos; /* general information */ 115633b8f45Smycroft __aconst char *pw_dir; /* home directory */ 116633b8f45Smycroft __aconst char *pw_shell; /* default shell */ 117e6b5ddd9Scgd time_t pw_expire; /* account expiration */ 118e6b5ddd9Scgd }; 119e6b5ddd9Scgd 120e6b5ddd9Scgd __BEGIN_DECLS 12150728e78Schristos #ifndef __LIBC12_SOURCE__ 12250728e78Schristos struct passwd *getpwuid(uid_t) __RENAME(__getpwuid50); 12350728e78Schristos struct passwd *getpwnam(const char *) __RENAME(__getpwnam50); 12450728e78Schristos #endif 125abf1d9c9Skleink #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ 126abf1d9c9Skleink defined(_REENTRANT) || defined(_NETBSD_SOURCE) 12750728e78Schristos #ifndef __LIBC12_SOURCE__ 12819b7469aSperry int getpwnam_r(const char *, struct passwd *, char *, size_t, 12950728e78Schristos struct passwd **) __RENAME(__getpwnam_r50); 13019b7469aSperry int getpwuid_r(uid_t, struct passwd *, char *, size_t, 13150728e78Schristos struct passwd **) __RENAME(__getpwuid_r50); 13250728e78Schristos #endif 133e6b5ddd9Scgd #endif 134abf1d9c9Skleink #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 13550728e78Schristos #ifndef __LIBC12_SOURCE__ 13650728e78Schristos struct passwd *getpwent(void) __RENAME(__getpwent50); 13750728e78Schristos #endif 138abf1d9c9Skleink void setpwent(void); 139abf1d9c9Skleink void endpwent(void); 140abf1d9c9Skleink #endif 141e2347743Schristos #if defined(_NETBSD_SOURCE) 14219b7469aSperry int pw_gensalt(char *, size_t, const char *, const char *); 14350728e78Schristos #ifndef __LIBC12_SOURCE__ 14450728e78Schristos int pw_scan(char *, struct passwd *, int *) __RENAME(__pw_scan50); 14550728e78Schristos int getpwent_r(struct passwd *, char *, size_t, struct passwd **) 14650728e78Schristos __RENAME(__getpwent_r50); 14750728e78Schristos #endif 14819b7469aSperry int setpassent(int); 14919b7469aSperry const char *user_from_uid(uid_t, int); 15019b7469aSperry int uid_from_user(const char *, uid_t *); 15150728e78Schristos #ifndef __LIBC12_SOURCE__ 15219b7469aSperry int pwcache_userdb(int (*)(int), void (*)(void), 15350728e78Schristos struct passwd * (*)(const char *), struct passwd * (*)(uid_t)) 15450728e78Schristos __RENAME(__pwcache_userdb50); 15550728e78Schristos #endif 1566ea15afcSkleink #endif 157e6b5ddd9Scgd __END_DECLS 158e6b5ddd9Scgd 159e6b5ddd9Scgd #endif /* !_PWD_H_ */ 160