secretagent: fix crash with multiple requests

Original commit message(s)

  • secretagent: fix duplicate delete/update jobs

    Once a DeleteSecrets/UpdateSecrets request has started its corresponding QKeychain jobs, it should not create new ones every time processNext() is called

  • Use dynamically allocated DeletePasswordJob

    If allocated on the stack, the job is immediately deleted and the callback is never executed

  • secretagent: fix missing secrets returned

    A new GetSecrets request while a previous one was waiting on a QKeyChain job would make the previous one return early with no secrets

  • secretagent: fix crash with multiple requests

    The QKeyChain finished handlers capture a QList item by reference This is unsafe and causes a crash if a new request is created before the job finishes, because QList will move the item to a new location and the captured reference becomes dangling.

    Instead, we store QSharedPointer into the list The QKeyChain callbacks capture a weak reference to the shared pointer and check the pointer is still valid before use.

Reason for the change

Fixes kded6 crashes on a fresh reboot if there are multiple wireguard VPN connections needing a secret

Test plan

Confirmed that the bug does not happen anymore, multiple connections successfully get their correct secrets

The original crash can be reproduced without rebooting:

  • Have multiple wireguard VPN connections
  • Disconnect the wireguard VPN connections in NetworkManager
  • Run kded6 --replace
  • Run systemctl restart NetworkManager

Screenshots or screen recordings

None

Bugs fixed

BUG: 521935

Possibly related: BUG: 522047 BUG: 522313

Edited by Mickaël Thomas

Merge request reports

Loading