Bug 379215

Summary: When 2 processes call the same KAuth action, first executed action result returns to both
Product: [Frameworks and Libraries] frameworks-kauth Reporter: Martin Kostolný <clearmartin>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs>
Status: CONFIRMED ---    
Severity: critical CC: elvis.angelaccio, katyaberezyaka, nate, simonandric5, sitter
Priority: VHI    
Version: 5.33.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:

Description Martin Kostolný 2017-04-25 17:41:59 UTC
I'm currently working on a KAuth integration into KTextEditor document saving. First iteration is already in master, second is being worked on here: https://phabricator.kde.org/D5394

I have simulated following behaviour (copied from a comment in D5494):
1) open Kate to edit a privileged file1
2) open KWrite to edit a different privileged file2
3) edit & save file1 (KAuth dialog is shown, do not enter password yet)
4) edit & save file2 -> it seems nothing happens (thats probably because one KAuth dialog of the same action is already opened)
5) fill password to existing KAuth dialog and send -> both editors say "saved", although only the first one is really saved

This means that KAuth::Action::execute().exec() returns in both processes (Kate and KWrite) at the same time when the first action was finished.

I believe that each such action should end on its own even if they both have the same ID and use the same helper binary.

PS: Alternatively I could differentiate the Action reply by returning different data in data() map. But no data are actually returned back from helper binary (just Success or Error reply) - I'll create another bug report for that.

I'll gladly provide more information on demand :).
Comment 1 Harald Sitter 2020-09-05 15:47:32 UTC
Mhhh. This may actually be a substantial architectural defect. I'm only glancing over the code but it looks a whole lot like the way the client<->helper communication is built assumes that only one action of a single type e.g. "org.kde.foo.action" is run at any given time. Specifically the helper gets told to run an action and then informs on progress for that action via signals that only link to the request by the action name. That is why two instances of kwrite would get finished, the helper emits actionPerformed("org.kate.whatevs", {}) and both clients think their request is the one that was performed.

Fixing this essentially needs the entire IPC to get changed :|
Oh dear oh dear