3 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
5 * Openvision retains the copyright to derivative works of
6 * this source code. Do *NOT* create a derivative of this
7 * source code before consulting with your legal department.
8 * Do *NOT* integrate *ANY* of this source code into another
9 * product before consulting with your legal department.
11 * For further information, read the top-level Openvision
12 * copyright which is contained in the top-level MIT Kerberos
15 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
21 * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
26 static char *rcsid
= "$Header$";
36 #include "server_internal.h"
39 adb_policy_init(kadm5_server_handle_t handle
)
41 /* now policy is initialized as part of database. No seperate call needed */
42 /* Solaris Kerberos: krb5_db_inited returns 0 when db has been inited */
43 if( krb5_db_inited( handle
->context
) == 0 )
46 return krb5_db_open( handle
->context
, NULL
,
47 KRB5_KDB_OPEN_RW
| KRB5_KDB_SRV_TYPE_ADMIN
);
51 adb_policy_close(kadm5_server_handle_t handle
)
53 /* will be taken care by database close */
58 /* stolen from v4sever/kadm_funcs.c */
63 static char newstr
[80];
68 if (i
>= sizeof(newstr
))
88 for (cp
= str
; *cp
; cp
++) {
100 str_check_gecos(gecos
, pwstr
)
104 char *cp
, *ncp
, *tcp
;
106 for (cp
= gecos
; *cp
; ) {
107 /* Skip past punctuation */
111 /* Skip to the end of the word */
112 for (ncp
= cp
; *ncp
; ncp
++)
113 if (!isalnum(*ncp
) && *ncp
!= '\'')
115 /* Delimit end of word */
118 /* Check word to see if it's the password */
120 if (!strcasecmp(pwstr
, cp
))
123 if (!strcasecmp(pwstr
, tcp
))
133 /* some of this is stolen from gatekeeper ... */
135 passwd_check(kadm5_server_handle_t handle
,
136 char *password
, int use_policy
, kadm5_policy_ent_t pol
,
137 krb5_principal principal
)
146 extern struct passwd
*hes_getpwnam();
151 if(strlen(password
) < pol
->pw_min_length
)
152 return KADM5_PASS_Q_TOOSHORT
;
155 if (islower((unsigned char) c
)) {
159 else if (isupper((unsigned char) c
)) {
162 } else if (isdigit((unsigned char) c
)) {
165 } else if (ispunct((unsigned char) c
)) {
173 if ((nupper
+ nlower
+ ndigit
+ npunct
+ nspec
) < pol
->pw_min_classes
)
174 return KADM5_PASS_Q_CLASS
;
175 if((find_word(password
) == KADM5_OK
))
176 return KADM5_PASS_Q_DICT
;
178 int i
, n
= krb5_princ_size(handle
->context
, principal
);
179 cp
= krb5_princ_realm(handle
->context
, principal
)->data
;
180 if (strcasecmp(cp
, password
) == 0)
181 return KADM5_PASS_Q_DICT
;
182 for (i
= 0; i
< n
; i
++) {
183 cp
= krb5_princ_component(handle
->context
, principal
, i
)->data
;
184 if (strcasecmp(cp
, password
) == 0)
185 return KADM5_PASS_Q_DICT
;
187 ent
= hes_getpwnam(cp
);
188 if (ent
&& ent
->pw_gecos
)
189 if (str_check_gecos(ent
->pw_gecos
, password
))
190 return KADM5_PASS_Q_DICT
; /* XXX new error code? */
196 if (strlen(password
) < 1)
197 return KADM5_PASS_Q_TOOSHORT
;
203 trunc_name(size_t *len
, char **dots
)
205 *dots
= *len
> MAXPRINCLEN
? "..." : "";
206 *len
= *len
> MAXPRINCLEN
? MAXPRINCLEN
: *len
;