Changeset 478 for vendor/current/source3/passdb/secrets.c
- Timestamp:
- Aug 2, 2010, 6:40:21 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/passdb/secrets.c
r414 r478 325 325 326 326 /** 327 * Form a key for fetching the machine previous trust account password 328 * 329 * @param domain domain name 330 * 331 * @return keystring 332 **/ 333 static const char *machine_prev_password_keystr(const char *domain) 334 { 335 char *keystr; 336 337 keystr = talloc_asprintf_strupper_m(talloc_tos(), "%s/%s", 338 SECRETS_MACHINE_PASSWORD_PREV, domain); 339 SMB_ASSERT(keystr != NULL); 340 return keystr; 341 } 342 343 /** 327 344 * Form a key for fetching the machine trust account password 328 345 * … … 572 589 573 590 /************************************************************************ 574 Routine to delete the plaintext machine account password 591 Routine to delete the old plaintext machine account password if any 592 ************************************************************************/ 593 594 static bool secrets_delete_prev_machine_password(const char *domain) 595 { 596 char *oldpass = (char *)secrets_fetch(machine_prev_password_keystr(domain), NULL); 597 if (oldpass == NULL) { 598 return true; 599 } 600 SAFE_FREE(oldpass); 601 return secrets_delete(machine_prev_password_keystr(domain)); 602 } 603 604 /************************************************************************ 605 Routine to delete the plaintext machine account password and old 606 password if any 575 607 ************************************************************************/ 576 608 577 609 bool secrets_delete_machine_password(const char *domain) 578 610 { 611 if (!secrets_delete_prev_machine_password(domain)) { 612 return false; 613 } 579 614 return secrets_delete(machine_password_keystr(domain)); 580 615 } 581 616 582 617 /************************************************************************ 583 Routine to delete the plaintext machine account password, sec channel type and584 last change time from secrets database618 Routine to delete the plaintext machine account password, old password, 619 sec channel type and last change time from secrets database 585 620 ************************************************************************/ 586 621 587 622 bool secrets_delete_machine_password_ex(const char *domain) 588 623 { 624 if (!secrets_delete_prev_machine_password(domain)) { 625 return false; 626 } 589 627 if (!secrets_delete(machine_password_keystr(domain))) { 590 628 return false; … … 606 644 607 645 /************************************************************************ 646 Routine to store the previous machine password (by storing the current password 647 as the old) 648 ************************************************************************/ 649 650 static bool secrets_store_prev_machine_password(const char *domain) 651 { 652 char *oldpass; 653 bool ret; 654 655 oldpass = (char *)secrets_fetch(machine_password_keystr(domain), NULL); 656 if (oldpass == NULL) { 657 return true; 658 } 659 ret = secrets_store(machine_prev_password_keystr(domain), oldpass, strlen(oldpass)+1); 660 SAFE_FREE(oldpass); 661 return ret; 662 } 663 664 /************************************************************************ 608 665 Routine to set the plaintext machine account password for a realm 609 the password is assumed to be a null terminated ascii string 666 the password is assumed to be a null terminated ascii string. 667 Before storing 610 668 ************************************************************************/ 611 669 … … 617 675 uint32 sec_channel_type; 618 676 677 if (!secrets_store_prev_machine_password(domain)) { 678 return false; 679 } 680 619 681 ret = secrets_store(machine_password_keystr(domain), pass, strlen(pass)+1); 620 682 if (!ret) … … 628 690 629 691 return ret; 692 } 693 694 695 /************************************************************************ 696 Routine to fetch the previous plaintext machine account password for a realm 697 the password is assumed to be a null terminated ascii string. 698 ************************************************************************/ 699 700 char *secrets_fetch_prev_machine_password(const char *domain) 701 { 702 return (char *)secrets_fetch(machine_prev_password_keystr(domain), NULL); 630 703 } 631 704
Note:
See TracChangeset
for help on using the changeset viewer.