Changeset 480 for trunk/server/source3/libads/kerberos_verify.c
- Timestamp:
- Aug 2, 2010, 8:16:45 PM (15 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 453,478
- Property svn:mergeinfo changed
-
trunk/server/source3/libads/kerberos_verify.c
r414 r480 308 308 krb5_error_code ret = 0; 309 309 bool auth_ok = False; 310 bool cont = true; 310 311 char *password_s = NULL; 311 krb5_data password; 312 /* Let's make some room for 2 password (old and new)*/ 313 krb5_data passwords[2]; 312 314 krb5_enctype enctypes[] = { 313 315 #if defined(ENCTYPE_ARCFOUR_HMAC) … … 319 321 }; 320 322 krb5_data packet; 321 int i ;323 int i, j; 322 324 323 325 *pp_tkt = NULL; … … 325 327 *perr = 0; 326 328 329 ZERO_STRUCT(passwords); 327 330 328 331 if (!secrets_init()) { … … 339 342 } 340 343 341 password.data = password_s; 342 password.length = strlen(password_s); 344 passwords[0].data = password_s; 345 passwords[0].length = strlen(password_s); 346 347 password_s = secrets_fetch_prev_machine_password(lp_workgroup()); 348 if (password_s) { 349 DEBUG(10,("ads_secrets_verify_ticket: found previous password\n")); 350 passwords[1].data = password_s; 351 passwords[1].length = strlen(password_s); 352 } 343 353 344 354 /* CIFS doesn't use addresses in tickets. This would break NAT. JRA */ … … 348 358 349 359 /* We need to setup a auth context with each possible encoding type in turn. */ 350 for (i=0;enctypes[i];i++) { 351 krb5_keyblock *key = NULL; 352 353 if (!(key = SMB_MALLOC_P(krb5_keyblock))) { 354 ret = ENOMEM; 355 goto out; 356 } 357 358 if (create_kerberos_key_from_string(context, host_princ, &password, key, enctypes[i], false)) { 359 SAFE_FREE(key); 360 continue; 361 } 362 363 krb5_auth_con_setuseruserkey(context, auth_context, key); 364 365 if (!(ret = krb5_rd_req(context, &auth_context, &packet, 366 NULL, 367 NULL, NULL, pp_tkt))) { 368 DEBUG(10,("ads_secrets_verify_ticket: enc type [%u] decrypted message !\n", 369 (unsigned int)enctypes[i] )); 370 auth_ok = True; 371 krb5_copy_keyblock(context, key, keyblock); 360 for (j=0; j<2 && passwords[j].length; j++) { 361 362 for (i=0;enctypes[i];i++) { 363 krb5_keyblock *key = NULL; 364 365 if (!(key = SMB_MALLOC_P(krb5_keyblock))) { 366 ret = ENOMEM; 367 goto out; 368 } 369 370 if (create_kerberos_key_from_string(context, host_princ, &passwords[j], key, enctypes[i], false)) { 371 SAFE_FREE(key); 372 continue; 373 } 374 375 krb5_auth_con_setuseruserkey(context, auth_context, key); 376 377 if (!(ret = krb5_rd_req(context, &auth_context, &packet, 378 NULL, 379 NULL, NULL, pp_tkt))) { 380 DEBUG(10,("ads_secrets_verify_ticket: enc type [%u] decrypted message !\n", 381 (unsigned int)enctypes[i] )); 382 auth_ok = True; 383 cont = false; 384 krb5_copy_keyblock(context, key, keyblock); 385 krb5_free_keyblock(context, key); 386 break; 387 } 388 389 DEBUG((ret != KRB5_BAD_ENCTYPE) ? 3 : 10, 390 ("ads_secrets_verify_ticket: enc type [%u] failed to decrypt with error %s\n", 391 (unsigned int)enctypes[i], error_message(ret))); 392 393 /* successfully decrypted but ticket is just not valid at the moment */ 394 if (ret == KRB5KRB_AP_ERR_TKT_NYV || 395 ret == KRB5KRB_AP_ERR_TKT_EXPIRED || 396 ret == KRB5KRB_AP_ERR_SKEW) { 397 krb5_free_keyblock(context, key); 398 cont = false; 399 break; 400 } 401 372 402 krb5_free_keyblock(context, key); 403 } 404 if (!cont) { 405 /* If we found a valid pass then no need to try 406 * the next one or we have invalid ticket so no need 407 * to try next password*/ 373 408 break; 374 409 } 375 376 DEBUG((ret != KRB5_BAD_ENCTYPE) ? 3 : 10,377 ("ads_secrets_verify_ticket: enc type [%u] failed to decrypt with error %s\n",378 (unsigned int)enctypes[i], error_message(ret)));379 380 /* successfully decrypted but ticket is just not valid at the moment */381 if (ret == KRB5KRB_AP_ERR_TKT_NYV ||382 ret == KRB5KRB_AP_ERR_TKT_EXPIRED ||383 ret == KRB5KRB_AP_ERR_SKEW) {384 krb5_free_keyblock(context, key);385 break;386 }387 388 krb5_free_keyblock(context, key);389 390 410 } 391 411 392 412 out: 393 SAFE_FREE(password_s); 413 SAFE_FREE(passwords[0].data); 414 SAFE_FREE(passwords[1].data); 394 415 *perr = ret; 395 416 return auth_ok;
Note:
See TracChangeset
for help on using the changeset viewer.