4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
33 #include <sys/types.h>
35 #include <crypt.h> /* CRYPT_MAXCIPHERTEXTLEN max crypt length */
37 /* DAY_NOW_32 is a 32-bit value, independent of the architecture */
39 #include <sys/types32.h>
40 #define DAY_NOW_32 ((time32_t)DAY_NOW)
42 #define DAY_NOW_32 ((time_t)DAY_NOW)
46 /* from plain passwd */
64 /* special operations */
65 ATTR_LOCK_ACCOUNT
= 0x10000,
66 ATTR_EXPIRE_PASSWORD
= 0x20000,
67 ATTR_NOLOGIN_ACCOUNT
= 0x40000,
68 ATTR_UNLOCK_ACCOUNT
= 0x80000,
69 /* Query operations */
70 /* to obtain repository name that contained the info */
71 ATTR_REP_NAME
= 0x100000,
72 /* special attribute */
73 /* to set password following server policy */
74 ATTR_PASSWD_SERVER_POLICY
= 0x200000,
75 /* get history entry from supporting repositories */
76 ATTR_HISTORY
= 0x400000,
77 /* Failed login bookkeeping */
78 ATTR_FAILED_LOGINS
= 0x800000, /* get # of failed logins */
79 ATTR_INCR_FAILED_LOGINS
= 0x1000000, /* increment + lock if needed */
80 ATTR_RST_FAILED_LOGINS
= 0x2000000 /* reset failed logins */
83 typedef struct attrlist_s
{
89 struct attrlist_s
*next
;
98 #define PWU_DEFAULT_REP (pwu_repository_t *)NULL
100 #define REP_NOREP 0 /* Can't find suitable repository */
101 #define REP_FILES 0x0001 /* /etc/passwd, /etc/shadow */
102 #define REP_NIS 0x0002
103 #define REP_LDAP 0x0004
104 #define REP_NSS 0x0008
105 #define REP_LAST REP_NSS
106 #define REP_ERANGE 0x8000 /* Unknown repository specified */
108 #define REP_COMPAT_NIS 0x1000
109 #define REP_COMPAT_LDAP 0x2000
111 /* For the time being, these are also defined in pam_*.h */
116 #define IS_FILES(r) (r.type != NULL && strcmp(r.type, "files") == 0)
117 #define IS_NIS(r) (r.type != NULL && strcmp(r.type, "nis") == 0)
118 #define IS_LDAP(r) (r.type != NULL && strcmp(r.type, "ldap") == 0)
124 typedef struct repops
{
125 int (*checkhistory
)(char *, char *, pwu_repository_t
*);
126 int (*getattr
)(char *, attrlist
*, pwu_repository_t
*);
127 int (*getpwnam
)(char *, attrlist
*, pwu_repository_t
*, void **);
128 int (*update
)(attrlist
*, pwu_repository_t
*, void *);
129 int (*putpwnam
)(char *, char *, pwu_repository_t
*, void *);
130 int (*user_to_authenticate
)(char *, pwu_repository_t
*, char **, int *);
135 extern repops_t files_repops
, nis_repops
, ldap_repops
, nss_repops
;
137 extern repops_t
*rops
[];
142 void turn_on_default_aging(struct spwd
*);
143 int def_getint(char *name
, int defvalue
);
148 void debug_init(void);
149 void debug(char *, ...);
154 #define PWU_READ 0 /* Read access to the repository */
155 #define PWU_WRITE 1 /* Write (update) access to the repository */
157 int get_ns(pwu_repository_t
*, int);
158 struct passwd
*getpwnam_from(const char *, pwu_repository_t
*, int);
159 struct passwd
*getpwuid_from(uid_t
, pwu_repository_t
*, int);
160 struct spwd
*getspnam_from(const char *, pwu_repository_t
*, int);
161 int name_to_int(char *);
164 * __set_authtok_attr.c
166 int __set_authtoken_attr(char *, char *, pwu_repository_t
*, attrlist
*, int *);
168 * __get_authtokenn_attr.c
170 int __get_authtoken_attr(char *, pwu_repository_t
*, attrlist
*);
173 * __user_to_authenticate.c
175 int __user_to_authenticate(char *, pwu_repository_t
*, char **, int *);
178 * Password history definitions
180 #define DEFHISTORY 0 /* default history depth */
181 #define MAXHISTORY 26 /* max depth of history 1 yr every 2 weeks */
186 int __check_history(char *, char *, pwu_repository_t
*);
188 int __incr_failed_count(char *, char *, int);
189 int __rst_failed_count(char *, char *);
192 * Error / return codes
194 #define PWU_SUCCESS 0 /* update succeeded */
195 #define PWU_BUSY -1 /* Password database busy */
196 #define PWU_STAT_FAILED -2 /* stat of password file failed */
197 #define PWU_OPEN_FAILED -3 /* password file open failed */
198 #define PWU_WRITE_FAILED -4 /* can't write to password file */
199 #define PWU_CLOSE_FAILED -5 /* close returned error */
200 #define PWU_NOT_FOUND -6 /* user not found in database */
201 #define PWU_UPDATE_FAILED -7 /* couldn't update password file */
202 #define PWU_NOMEM -8 /* Not enough memory */
203 #define PWU_SERVER_ERROR -9 /* NIS server errors */
204 #define PWU_SYSTEM_ERROR -10 /* NIS local configuration problem */
205 #define PWU_DENIED -11 /* NIS update denied */
206 #define PWU_NO_CHANGE -12 /* Data hasn't changed */
207 #define PWU_REPOSITORY_ERROR -13 /* Unknown repository specified */
208 #define PWU_AGING_DISABLED -14 /* Modifying min/warn while max==-1 */
212 #define PWU_PWD_TOO_SHORT -15 /* new passwd too short */
213 #define PWU_PWD_INVALID -16 /* new passwd has invalid syntax */
214 #define PWU_PWD_IN_HISTORY -17 /* new passwd in history list */
215 #define PWU_CHANGE_NOT_ALLOWED -18 /* change not allowed */
216 #define PWU_WITHIN_MIN_AGE -19 /* change not allowed, within min age */
217 #define PWU_ACCOUNT_LOCKED -20 /* account successfully locked */
223 #endif /* _PASSWDUTIL_H */