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 #if !defined(lint) && !defined(__CODECENTER__)
27 static char *rcsid
= "$Header$";
38 #include "server_internal.h"
41 adb_policy_init(kadm5_server_handle_t handle
)
43 /* now policy is initialized as part of database. No seperate call needed */
44 /* Solaris Kerberos: krb5_db_inited returns 0 when db has been inited */
45 if( krb5_db_inited( handle
->context
) == 0 )
48 return krb5_db_open( handle
->context
, NULL
,
49 KRB5_KDB_OPEN_RW
| KRB5_KDB_SRV_TYPE_ADMIN
);
53 adb_policy_close(kadm5_server_handle_t handle
)
55 /* will be taken care by database close */
60 /* stolen from v4sever/kadm_funcs.c */
65 static char newstr
[80];
70 if (i
>= sizeof(newstr
))
90 for (cp
= str
; *cp
; cp
++) {
102 str_check_gecos(gecos
, pwstr
)
106 char *cp
, *ncp
, *tcp
;
108 for (cp
= gecos
; *cp
; ) {
109 /* Skip past punctuation */
113 /* Skip to the end of the word */
114 for (ncp
= cp
; *ncp
; ncp
++)
115 if (!isalnum(*ncp
) && *ncp
!= '\'')
117 /* Delimit end of word */
120 /* Check word to see if it's the password */
122 if (!strcasecmp(pwstr
, cp
))
125 if (!strcasecmp(pwstr
, tcp
))
135 /* some of this is stolen from gatekeeper ... */
137 passwd_check(kadm5_server_handle_t handle
,
138 char *password
, int use_policy
, kadm5_policy_ent_t pol
,
139 krb5_principal principal
)
148 extern struct passwd
*hes_getpwnam();
153 if(strlen(password
) < pol
->pw_min_length
)
154 return KADM5_PASS_Q_TOOSHORT
;
157 if (islower((unsigned char) c
)) {
161 else if (isupper((unsigned char) c
)) {
164 } else if (isdigit((unsigned char) c
)) {
167 } else if (ispunct((unsigned char) c
)) {
175 if ((nupper
+ nlower
+ ndigit
+ npunct
+ nspec
) < pol
->pw_min_classes
)
176 return KADM5_PASS_Q_CLASS
;
177 if((find_word(password
) == KADM5_OK
))
178 return KADM5_PASS_Q_DICT
;
180 int i
, n
= krb5_princ_size(handle
->context
, principal
);
181 cp
= krb5_princ_realm(handle
->context
, principal
)->data
;
182 if (strcasecmp(cp
, password
) == 0)
183 return KADM5_PASS_Q_DICT
;
184 for (i
= 0; i
< n
; i
++) {
185 cp
= krb5_princ_component(handle
->context
, principal
, i
)->data
;
186 if (strcasecmp(cp
, password
) == 0)
187 return KADM5_PASS_Q_DICT
;
189 ent
= hes_getpwnam(cp
);
190 if (ent
&& ent
->pw_gecos
)
191 if (str_check_gecos(ent
->pw_gecos
, password
))
192 return KADM5_PASS_Q_DICT
; /* XXX new error code? */
198 if (strlen(password
) < 1)
199 return KADM5_PASS_Q_TOOSHORT
;
205 trunc_name(size_t *len
, char **dots
)
207 *dots
= *len
> MAXPRINCLEN
? "..." : "";
208 *len
= *len
> MAXPRINCLEN
? MAXPRINCLEN
: *len
;