From: Ken Raeburn Date: Tue, 20 Jan 2009 22:52:15 +0000 (+0000) Subject: delete trailing whitespace, including insanely long 'blank' lines X-Git-Tag: krb5-1.7-alpha1~60 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4f936fdfba2e1060dea66ecba83c993a2b4d48b1;p=krb5.git delete trailing whitespace, including insanely long 'blank' lines git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21764 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/kadm5/srv/svr_principal.c b/src/lib/kadm5/srv/svr_principal.c index 47580da39..de11acd7e 100644 --- a/src/lib/kadm5/srv/svr_principal.c +++ b/src/lib/kadm5/srv/svr_principal.c @@ -36,27 +36,26 @@ static int decrypt_key_data(krb5_context context, int n_key_data, krb5_key_data *key_data, krb5_keyblock **keyblocks, int *n_keys); -static krb5_error_code +static krb5_error_code kadm5_copy_principal(krb5_context context, krb5_const_principal inprinc, krb5_principal *outprinc) { register krb5_principal tempprinc; register int i, nelems; - + tempprinc = (krb5_principal)krb5_db_alloc(context, NULL, sizeof(krb5_principal_data)); - + if (tempprinc == 0) return ENOMEM; - + memcpy(tempprinc, inprinc, sizeof(krb5_principal_data)); - + nelems = (int) krb5_princ_size(context, inprinc); tempprinc->data = krb5_db_alloc(context, NULL, nelems * sizeof(krb5_data)); - if (tempprinc->data == 0) { krb5_db_free(context, (char *)tempprinc); return ENOMEM; } - + for (i = 0; i < nelems; i++) { unsigned int len = krb5_princ_component(context, inprinc, i)->length; krb5_princ_component(context, tempprinc, i)->length = len; @@ -72,7 +71,7 @@ kadm5_copy_principal(krb5_context context, krb5_const_principal inprinc, krb5_pr memcpy(krb5_princ_component(context, tempprinc, i)->data, krb5_princ_component(context, inprinc, i)->data, len); } - + tempprinc->realm.data = krb5_db_alloc(context, NULL, tempprinc->realm.length = inprinc->realm.length); if (!tempprinc->realm.data && tempprinc->realm.length) { @@ -85,19 +84,19 @@ kadm5_copy_principal(krb5_context context, krb5_const_principal inprinc, krb5_pr if (tempprinc->realm.length) memcpy(tempprinc->realm.data, inprinc->realm.data, inprinc->realm.length); - + *outprinc = tempprinc; return 0; } - + static void kadm5_free_principal(krb5_context context, krb5_principal val) { register krb5_int32 i; - + if (!val) return; - + if (val->data) { i = krb5_princ_size(context, val); while(--i >= 0) @@ -117,7 +116,7 @@ kadm5_ret_t krb5_copy_key_data_contents(context, from, to) krb5_key_data *from, *to; { int i, idx; - + *to = *from; idx = (from->key_data_ver == 1 ? 1 : 2); @@ -168,7 +167,7 @@ static void cleanup_key_data(context, count, data) krb5_key_data * data; { int i, j; - + for (i = 0; i < count; i++) for (j = 0; j < data[i].key_data_ver; j++) if (data[i].key_data_length[j]) @@ -243,7 +242,7 @@ kadm5_create_principal_3(void *server_handle, if ((mask & KADM5_POLICY)) { if ((ret = kadm5_get_policy(handle->lhandle, entry->policy, &polent)) != KADM5_OK) { - if(ret == EINVAL) + if(ret == EINVAL) return KADM5_BAD_POLICY; else return ret; @@ -269,14 +268,14 @@ kadm5_create_principal_3(void *server_handle, kdb.magic = KRB5_KDB_MAGIC_NUMBER; kdb.len = KRB5_KDB_V1_BASE_LENGTH; /* gag me with a chainsaw */ - if ((mask & KADM5_ATTRIBUTES)) + if ((mask & KADM5_ATTRIBUTES)) kdb.attributes = entry->attributes; else kdb.attributes = handle->params.flags; if ((mask & KADM5_MAX_LIFE)) - kdb.max_life = entry->max_life; - else + kdb.max_life = entry->max_life; + else kdb.max_life = handle->params.max_life; if (mask & KADM5_MAX_RLIFE) @@ -298,7 +297,7 @@ kadm5_create_principal_3(void *server_handle, } if ((mask & KADM5_PW_EXPIRATION)) kdb.pw_expiration = entry->pw_expiration; - + kdb.last_success = 0; kdb.last_failed = 0; kdb.fail_auth_count = 0; @@ -414,7 +413,7 @@ kadm5_create_principal_3(void *server_handle, return KADM5_OK; } - + kadm5_ret_t kadm5_delete_principal(void *server_handle, krb5_principal principal) { @@ -599,7 +598,7 @@ kadm5_modify_principal(void *server_handle, KADM5_REF_COUNT))))) goto done; - if ((mask & KADM5_ATTRIBUTES)) + if ((mask & KADM5_ATTRIBUTES)) kdb.attributes = entry->attributes; if ((mask & KADM5_MAX_LIFE)) kdb.max_life = entry->max_life; @@ -611,7 +610,7 @@ kadm5_modify_principal(void *server_handle, kdb.max_renewable_life = entry->max_renewable_life; if (mask & KADM5_FAIL_AUTH_COUNT) kdb.fail_auth_count = entry->fail_auth_count; - + if((mask & KADM5_KVNO)) { for (i = 0; i < kdb.n_key_data; i++) kdb.key_data[i].key_data_kvno = entry->kvno; @@ -652,7 +651,7 @@ done: kdb_free_entry(handle, &kdb, &adb); return ret; } - + kadm5_ret_t kadm5_rename_principal(void *server_handle, krb5_principal source, krb5_principal target) @@ -755,7 +754,7 @@ kadm5_get_principal(void *server_handle, krb5_principal principal, if ((mask & KADM5_PRINCIPAL) && (ret = krb5_copy_principal(handle->context, kdb.princ, - &entry->principal))) { + &entry->principal))) { goto done; } @@ -777,12 +776,12 @@ kadm5_get_principal(void *server_handle, krb5_principal principal, /* values that must be checked separately against the mask */ if ((mask & KADM5_MOD_NAME) || (mask & KADM5_MOD_TIME)) { ret = krb5_dbe_lookup_mod_princ_data(handle->context, &kdb, - &(entry->mod_date), + &(entry->mod_date), &(entry->mod_name)); if (ret) { goto done; } - + if (! (mask & KADM5_MOD_TIME)) entry->mod_date = 0; if (! (mask & KADM5_MOD_NAME)) { @@ -798,7 +797,7 @@ kadm5_get_principal(void *server_handle, krb5_principal principal, for (entry->kvno = 0, i=0; i entry->kvno) entry->kvno = kdb.key_data[i].key_data_kvno; - + if (handle->api_version == KADM5_API_VERSION_2) entry->mkvno = 0; else { @@ -822,7 +821,7 @@ kadm5_get_principal(void *server_handle, krb5_principal principal, krb5_tl_data *tl, *tl2; entry->tl_data = NULL; - + tl = kdb.tl_data; while (tl) { if (tl->tl_data_type > 255) { @@ -834,7 +833,7 @@ kadm5_get_principal(void *server_handle, krb5_principal principal, entry->tl_data = tl2; entry->n_tl_data++; } - + tl = tl->tl_data_next; } } @@ -847,7 +846,7 @@ kadm5_get_principal(void *server_handle, krb5_principal principal, ret = ENOMEM; goto done; } - } else + } else entry->key_data = NULL; for (i = 0; i < entry->n_key_data; i++) @@ -872,7 +871,7 @@ kadm5_get_principal(void *server_handle, krb5_principal principal, ret = ENOMEM; goto done; } - + newv1->principal = entry->principal; newv1->princ_expire_time = entry->princ_expire_time; newv1->last_pwd_change = entry->last_pwd_change; @@ -951,15 +950,15 @@ check_pw_reuse(krb5_context context, &pw_hist_data[y].key_data[z], &histkey, NULL); if (ret) - return(ret); - + return(ret); + if ((newkey.length == histkey.length) && (newkey.enctype == histkey.enctype) && (memcmp(newkey.contents, histkey.contents, histkey.length) == 0)) { krb5_free_keyblock_contents(context, &histkey); krb5_free_keyblock_contents(context, &newkey); - + return(KADM5_PASS_REUSE); } krb5_free_keyblock_contents(context, &histkey); @@ -998,7 +997,7 @@ int create_history_entry(krb5_context context, int n_key_data, int i, ret; krb5_keyblock key; krb5_keysalt salt; - + hist->key_data = (krb5_key_data*)malloc(n_key_data*sizeof(krb5_key_data)); if (hist->key_data == NULL) return ENOMEM; @@ -1018,7 +1017,7 @@ int create_history_entry(krb5_context context, int n_key_data, &hist->key_data[i]); if (ret) return ret; - + krb5_free_keyblock_contents(context, &key); /* krb5_free_keysalt(context, &salt); */ } @@ -1091,7 +1090,7 @@ static kadm5_ret_t add_to_history(krb5_context context, } if (adb->old_keys == NULL) return(ENOMEM); - + memset(&adb->old_keys[nkeys], 0, sizeof(osa_pw_hist_ent)); nkeys = ++adb->old_key_len; /* @@ -1191,7 +1190,7 @@ kadm5_set_use_password_server (void) #ifdef USE_PASSWORD_SERVER /* - * kadm5_launch_task () runs a program (task_path) to synchronize the + * kadm5_launch_task () runs a program (task_path) to synchronize the * Apple password server with the Kerberos database. Password server * programs can receive arguments on the command line (task_argv) * and a block of data via stdin (data_buffer). @@ -1204,11 +1203,11 @@ kadm5_set_use_password_server (void) static kadm5_ret_t kadm5_launch_task (krb5_context context, const char *task_path, char * const task_argv[], - const char *buffer) + const char *buffer) { kadm5_ret_t ret; int data_pipe[2]; - + ret = pipe (data_pipe); if (ret) ret = errno; @@ -1221,20 +1220,20 @@ kadm5_launch_task (krb5_context context, close (data_pipe[1]); } else if (pid == 0) { /* The child: */ - + if (dup2 (data_pipe[0], STDIN_FILENO) == -1) _exit (1); close (data_pipe[0]); close (data_pipe[1]); - + execv (task_path, task_argv); - + _exit (1); /* Fail if execv fails */ } else { /* The parent: */ int status; - + ret = 0; close (data_pipe[0]); @@ -1317,7 +1316,7 @@ kadm5_chpass_principal_3(void *server_handle, kdb_free_entry(handle, &kdb, &adb); return(ret); } - + if ((adb.aux_attributes & KADM5_POLICY)) { if ((ret = kadm5_get_policy(handle->lhandle, adb.policy, &pol))) goto done; @@ -1341,7 +1340,7 @@ kadm5_chpass_principal_3(void *server_handle, ret = krb5_timeofday(handle->context, &now); if (ret) goto done; - + if ((adb.aux_attributes & KADM5_POLICY)) { /* the policy was loaded before */ @@ -1375,7 +1374,7 @@ kadm5_chpass_principal_3(void *server_handle, 1, &hist); if (ret) goto done; - + if (pol.pw_history_num > 1) { if (adb.admin_history_kvno != hist_kvno) { ret = KADM5_BAD_HIST_KEY; @@ -1422,10 +1421,10 @@ kadm5_chpass_principal_3(void *server_handle, ret = kadm5_launch_task (handle->context, path, argv, password); } - + if (pstring != NULL) free (pstring); - + if (ret) goto done; } @@ -1450,7 +1449,7 @@ done: krb5_db_free_principal(handle->context, &kdb, 1); if (have_pol && (ret2 = kadm5_free_policy_ent(handle->lhandle, &pol)) - && !ret) + && !ret) ret = ret2; return ret; @@ -1516,7 +1515,7 @@ kadm5_randkey_principal_3(void *server_handle, if ((adb.aux_attributes & KADM5_POLICY)) { if ((ret = kadm5_get_policy(handle->lhandle, adb.policy, - &pol)) != KADM5_OK) + &pol)) != KADM5_OK) goto done; have_pol = 1; @@ -1571,7 +1570,7 @@ kadm5_randkey_principal_3(void *server_handle, -1, -1, &key_data); if (ret) goto done; - + ret = decrypt_key_data(handle->context, 1, key_data, keyblocks, NULL); if (ret) @@ -1583,8 +1582,8 @@ kadm5_randkey_principal_3(void *server_handle, if (ret) goto done; } - } - + } + /* key data changed, let the database provider know */ kdb.mask = KADM5_KEY_DATA /* | KADM5_RANDKEY_USED */; @@ -1639,7 +1638,7 @@ kadm5_setv4key_principal(void *server_handle, if (keyblock->enctype != ENCTYPE_DES_CBC_CRC) return KADM5_SETV4KEY_INVAL_ENCTYPE; - + if ((ret = kdb_get_entry(handle, principal, &kdb, &adb))) return(ret); @@ -1649,7 +1648,7 @@ kadm5_setv4key_principal(void *server_handle, if (kdb.key_data != NULL) cleanup_key_data(handle->context, kdb.n_key_data, kdb.key_data); - + kdb.key_data = (krb5_key_data*)krb5_db_alloc(handle->context, NULL, sizeof(krb5_key_data)); if (kdb.key_data == NULL) return ENOMEM; @@ -1698,7 +1697,7 @@ kadm5_setv4key_principal(void *server_handle, if ((adb.aux_attributes & KADM5_POLICY)) { if ((ret = kadm5_get_policy(handle->lhandle, adb.policy, - &pol)) != KADM5_OK) + &pol)) != KADM5_OK) goto done; have_pol = 1; @@ -1735,7 +1734,7 @@ kadm5_setv4key_principal(void *server_handle, goto done; } #endif - + if (pol.pw_max_life) kdb.pw_expiration = now + pol.pw_max_life; else @@ -1836,7 +1835,7 @@ kadm5_setkey_principal_3(void *server_handle, if ((ret = kdb_get_entry(handle, principal, &kdb, &adb))) return(ret); - + for (kvno = 0, i=0; i kvno) kvno = kdb.key_data[i].key_data_kvno; @@ -1850,7 +1849,7 @@ kadm5_setkey_principal_3(void *server_handle, n_old_keys = 0; old_key_data = NULL; } - + kdb.key_data = (krb5_key_data*)krb5_db_alloc(handle->context, NULL, (n_keys+n_old_keys) *sizeof(krb5_key_data)); if (kdb.key_data == NULL) { @@ -1930,7 +1929,7 @@ kadm5_setkey_principal_3(void *server_handle, if ((adb.aux_attributes & KADM5_POLICY)) { if ((ret = kadm5_get_policy(handle->lhandle, adb.policy, - &pol)) != KADM5_OK) + &pol)) != KADM5_OK) goto done; have_pol = 1; @@ -1967,7 +1966,7 @@ kadm5_setkey_principal_3(void *server_handle, goto done; } #endif - + if (pol.pw_max_life) kdb.pw_expiration = now + pol.pw_max_life; else @@ -2066,7 +2065,7 @@ static int decrypt_key_data(krb5_context context, for (i = 0; i < n_key_data; i++) { ret = krb5_dbekd_decrypt_key_data(context, &master_keyblock, - &key_data[i], + &key_data[i], &keys[i], NULL); if (ret) { for (; i >= 0; i--) { @@ -2160,4 +2159,3 @@ kadm5_ret_t kadm5_decrypt_key(void *server_handle, return KADM5_OK; } -