Commit 8ab6b6d
committed
fix(auth): serialize keyring migration under a reentrant credential lock
load_tokens()'s keyring read-copy-delete migration ran outside
_credential_transaction_locks, so it could race persist_login/persist_logout
and overwrite a newer file token with the older keyring value. Serialize it
under the credential lock. The lock is now reentrant per thread (fcntl.flock /
msvcrt.locking deny a second same-file acquisition within one process), so
callers already inside a credential transaction — e.g. persist_login loading
the previous token at the same key (oauth.py:804) — re-enter instead of
self-deadlocking. Adds reentrancy and migration-under-held-lock regression tests.1 parent 5b808da commit 8ab6b6d
2 files changed
Lines changed: 85 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
641 | 641 | | |
642 | 642 | | |
643 | 643 | | |
644 | | - | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
645 | 651 | | |
646 | 652 | | |
647 | 653 | | |
| |||
719 | 725 | | |
720 | 726 | | |
721 | 727 | | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
722 | 745 | | |
723 | 746 | | |
| 747 | + | |
| 748 | + | |
724 | 749 | | |
725 | 750 | | |
726 | 751 | | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
727 | 758 | | |
728 | 759 | | |
729 | 760 | | |
| |||
736 | 767 | | |
737 | 768 | | |
738 | 769 | | |
| 770 | + | |
| 771 | + | |
739 | 772 | | |
740 | 773 | | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
741 | 782 | | |
742 | 783 | | |
743 | 784 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
511 | 511 | | |
512 | 512 | | |
513 | 513 | | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
514 | 557 | | |
515 | 558 | | |
516 | 559 | | |
| |||
0 commit comments