-: 0:Source:pwqual.c -: 0:Graph:/var/tsitkova/Sources/v10/trunk/src/lib/kadm5/srv/pwqual.so.gcno -: 0:Data:/var/tsitkova/Sources/v10/trunk/src/lib/kadm5/srv/pwqual.so.gcda -: 0:Runs:951 -: 0:Programs:1 -: 1:/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -: 2:/* lib/kadm5/srv/pwqual.c */ -: 3:/* -: 4: * Copyright (C) 2010 by the Massachusetts Institute of Technology. -: 5: * All rights reserved. -: 6: * -: 7: * Export of this software from the United States of America may -: 8: * require a specific license from the United States Government. -: 9: * It is the responsibility of any person or organization contemplating -: 10: * export to obtain such a license before exporting. -: 11: * -: 12: * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and -: 13: * distribute this software and its documentation for any purpose and -: 14: * without fee is hereby granted, provided that the above copyright -: 15: * notice appear in all copies and that both that copyright notice and -: 16: * this permission notice appear in supporting documentation, and that -: 17: * the name of M.I.T. not be used in advertising or publicity pertaining -: 18: * to distribution of the software without specific, written prior -: 19: * permission. Furthermore if you modify this software you must label -: 20: * your software as modified software and not distribute it in such a -: 21: * fashion that it might be confused with the original M.I.T. software. -: 22: * M.I.T. makes no representations about the suitability of -: 23: * this software for any purpose. It is provided "as is" without express -: 24: * or implied warranty. -: 25: */ -: 26: -: 27:/* -: 28: * -: 29: * Consumer interface for password quality plugins. -: 30: */ -: 31: -: 32:#include "k5-int.h" -: 33:#include "server_internal.h" -: 34:#include -: 35: -: 36:struct pwqual_handle_st { -: 37: struct krb5_pwqual_vtable_st vt; -: 38: krb5_pwqual_moddata data; -: 39:}; -: 40: -: 41:krb5_error_code 653: 42:k5_pwqual_load(krb5_context context, const char *dict_file, -: 43: pwqual_handle **handles_out) -: 44:{ -: 45: krb5_error_code ret; 653: 46: krb5_plugin_initvt_fn *modules = NULL, *mod; -: 47: size_t count; 653: 48: pwqual_handle *list = NULL, handle = NULL; -: 49: 653: 50: *handles_out = NULL; -: 51: 653: 52: ret = k5_plugin_load_all(context, PLUGIN_INTERFACE_PWQUAL, &modules); 653: 53: if (ret != 0) #####: 54: goto cleanup; -: 55: -: 56: /* Allocate a large enough list of handles. */ 653: 57: for (count = 0; modules[count] != NULL; count++); 653: 58: list = k5alloc((count + 1) * sizeof(*list), &ret); 653: 59: if (list == NULL) #####: 60: goto cleanup; -: 61: -: 62: /* For each module, allocate a handle, initialize its vtable, and bind the -: 63: * dictionary filename. */ 653: 64: count = 0; 3265: 65: for (mod = modules; *mod != NULL; mod++) { 2612: 66: handle = k5alloc(sizeof(*handle), &ret); 2612: 67: if (handle == NULL) #####: 68: goto cleanup; 2612: 69: ret = (*mod)(context, 1, 1, (krb5_plugin_vtable)&handle->vt); 2612: 70: if (ret != 0) { /* Failed vtable init is non-fatal. */ #####: 71: free(handle); #####: 72: handle = NULL; #####: 73: continue; -: 74: } 2612: 75: handle->data = NULL; 2612: 76: if (handle->vt.open != NULL) { 653: 77: ret = handle->vt.open(context, dict_file, &handle->data); 653: 78: if (ret != 0) /* Failed dictionary binding is fatal. */ #####: 79: goto cleanup; -: 80: } 2612: 81: list[count++] = handle; 2612: 82: list[count] = NULL; 2612: 83: handle = NULL; -: 84: } 653: 85: list[count] = NULL; -: 86: 653: 87: ret = 0; 653: 88: *handles_out = list; 653: 89: list = NULL; -: 90: -: 91:cleanup: 653: 92: free(handle); 653: 93: k5_plugin_free_modules(context, modules); 653: 94: k5_pwqual_free_handles(context, list); 653: 95: return ret; -: 96:} -: 97: -: 98:void 1300: 99:k5_pwqual_free_handles(krb5_context context, pwqual_handle *handles) -: 100:{ -: 101: pwqual_handle *hp, handle; -: 102: 1300: 103: if (handles == NULL) 653: 104: return; 3235: 105: for (hp = handles; *hp != NULL; hp++) { 2588: 106: handle = *hp; 2588: 107: if (handle->vt.close != NULL) 647: 108: handle->vt.close(context, handle->data); 2588: 109: free(handle); -: 110: } 647: 111: free(handles); -: 112:} -: 113: -: 114:const char * #####: 115:k5_pwqual_name(krb5_context context, pwqual_handle handle) -: 116:{ #####: 117: return handle->vt.name; -: 118:} -: 119: -: 120:krb5_error_code 2120: 121:k5_pwqual_check(krb5_context context, pwqual_handle handle, -: 122: const char *password, const char *policy_name, -: 123: krb5_principal princ) -: 124:{ 2120: 125: return handle->vt.check(context, handle->data, password, policy_name, -: 126: princ, NULL); -: 127:}