Bug 492488 - kglobalaccel is sometimes run as root, causing things it launches to also get run as root
Summary: kglobalaccel is sometimes run as root, causing things it launches to also get...
Status: REPORTED
Alias: None
Product: frameworks-kglobalaccel
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.115.0
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-01 11:18 UTC by Vijit
Modified: 2024-09-18 18:18 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
real krunner (6.79 KB, image/png)
2024-09-01 11:20 UTC, Vijit
Details
surrogate search window (4.68 KB, image/png)
2024-09-01 11:21 UTC, Vijit
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vijit 2024-09-01 11:18:23 UTC
SUMMARY

KRunner search looks wierd. It's like a real search window but has a different history and search logic. And it opens by the same hot keys. I don't know what the program starts, but it's definitely NOT `/usr/bin/krunner`.

Moreover, it happens by itself. On one call I get real krunner, in the second time it another and don't change until I reboot.

STEPS TO REPRODUCE
Hit Alt+Space

OBSERVED RESULT
 See what you got. There two different krunner search windows.

EXPECTED RESULT
I  want to get a real krunner search window.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KUbuntu 24.04
KDE Plasma Version: 5.27.11
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.13

ADDITIONAL INFORMATION

I check the hotkey in [~/.config/kglobalshortcutsrc]. There is only one binding:
```
[org.kde.krunner.desktop]
RunClipboard=Alt+Shift+F2,Alt+Shift+F2,Run command on clipboard contents
_k_friendly_name=KRunner
_launch=Alt+Space,Alt+Space\tAlt+F2\tSearch,KRunner
```

Also there is only one block with 'KRunner'.

I tried to find the process when the surrogate window is opened - no luck. But I'm sure, this is not `/usr/bin/krunner`, because I see this process when it is running.

---

P.S.: what a poor bug form! Jesus! Only one attachment?! Submit by Enter? WTF?!
Comment 1 Vijit 2024-09-01 11:20:33 UTC
Created attachment 173195 [details]
real krunner
Comment 2 Vijit 2024-09-01 11:21:01 UTC
Created attachment 173196 [details]
surrogate search window
Comment 3 Vijit 2024-09-01 11:29:09 UTC
I tried to disable the Alt + Space combination in the system settings, the surrogate opens anyway. So it is somewhere and opens to the same hotkey and the system intercepts keystrokes specifically to launch it, and not the real krunner.
Comment 4 Nate Graham 2024-09-07 08:04:53 UTC
Thanks for the bug report! Unfortunately I'm having a hard time figuring out what bug is being reported here. Can you please read https://community.kde.org/Get_Involved/Issue_Reporting? 

"Hit Alt+Space" isn't very helpful to me I'm afraid; when I press this, I just see the normal KRunner. You've attached two screenshots of KRunner, one with a light color scheme and one with a dark color scheme. Are you saying that sometimes it appears with a different color scheme or something?
Comment 5 Vijit 2024-09-07 16:27:30 UTC
Well..

The dark theme - is the real krunner, with the color in according my desktop scheme.

The light theme is an app  that opens instead real krunner search.

I don't know how to find the app that intercepts the hotkey "Alt+space". I removed all hotkeys for krunner in System Settings > Shortcuts, but this "surrogate" opens anyway. I double checked in [~/.config/kglobalshortcutsrc] and [~/.config/khotkeysrc] - nothing suspicious.
Comment 6 Vijit 2024-09-07 17:24:02 UTC
Here is more details.

I found out, how to start the real krunner - mouse right click on desktop > show KRunner. 

Then I found out how to identify the process owner the window (based on this arcticle - https://kb.froglogic.com/misc/find-process-for-window/), and I checked:

```
// Opened real Krunner, execute this command and click to the window
$ xprop _NET_WM_PID | sed 's/_NET_WM_PID(CARDINAL) = //'
2394781

// Same actions for surrogate
$ xprop _NET_WM_PID | sed 's/_NET_WM_PID(CARDINAL) = //'
 705568
```

Ok, we see two different processes. Now lets check the parent process. Same actions this mouse, but a bit different command:

```
// Real krunner
$ ps ww -o ppid=,pid=,cmd= -q `xprop _NET_WM_PID | sed 's/_NET_WM_PID(CARDINAL) = //'`
   1948 2394781 /usr/bin/krunner

// Surrogate
$ ps ww -o ppid=,pid=,cmd= -q `xprop _NET_WM_PID | sed 's/_NET_WM_PID(CARDINAL) = //'`
   1948  705568 /usr/bin/krunner
```

Same parent! How? What is it?

The last check:
```
$ ps aux | grep -E -i '2394781|705568'
root      705568  0.0  0.3 1175068 129932 ?      Sl   сен03   1:13 /usr/bin/krunner
vijit    2394781  0.4  0.5 2145516 190784 ?      Ssl  сен07   0:03 /usr/bin/krunner
```

Surrogate was started by root. It seems, I shot in the leg somehow. I mean, both windows is the same application, but started by different users. I'll keep digging.
Comment 7 Vijit 2024-09-07 17:29:03 UTC
Even if killed the root-owned process, then pressed Alt+Space under my acconut - starts `krunner` by the root. I don't get, how it possible? Now request for the root privileges, just started the app under root.
Comment 8 Vijit 2024-09-07 17:50:44 UTC
*No request for... (I made a typo above).
Comment 9 Vijit 2024-09-07 19:02:55 UTC
As for now, I'm solving the problem in this way:
- find and kill all `/usr/bin/kglobalaccel5`. This process manages the hotkeys pressing. I had two of it, started by root and my user.
- restart `/usr/bin/kglobalaccel5` in background by my user.

Now by Alt+Space opens `krunner` owned by my user.

A new question: why `/usr/bin/kglobalaccel5` was run by root? I didn't made it explicitly, I even didn't know about this process until this moment.
Comment 10 Nate Graham 2024-09-07 22:02:28 UTC
Ok, so definitely the problem is kglobalaccel5 being run as root. That's unexpected, and not intended. Good investigation so far.

Can you try again in a new clean user account and see if the same issues occur? if not, then the issue is localized to your current user account, where for some reason kglobalaccel5 is being launched as root.
Comment 11 Vijit 2024-09-08 00:51:48 UTC
I met with this a few times. After reboot this behavior disappeared and appears again by some reason. I'll track it and try to find out more. At least now I know where is the sign of the problem.
Comment 12 Nate Graham 2024-09-08 07:02:24 UTC
Can you try in a new clean user account?
Comment 13 Vijit 2024-09-08 16:59:43 UTC
Yes, I can, but what the point? I can just reboot and problem disappeared on my account for a while. What exactly I should see with the new account? There is no problem, so? I need to use this account for uncertain time to make a conclusion. That's unacceptable.

At the same time I can stay on my account and check periodically, after some normal actions in OS, when the problem appears. I think this is the right direction in finding the causes.
Comment 14 Nate Graham 2024-09-16 14:28:31 UTC
Well, clearly there's still an issue on your system even if you found a workaround for it :) KGlobalAccel isn't supposed to be launched as root, and this happening anyway is the cause of the problem you're seeing. It's nice that you've found a workaround, but we need to figure out if it's a general code issue that we need to fix.

For debugging purposes, can you create a new clean user account and see if the issue still happens?

The reason why I ask, is because if the problem does not happen there, it means the issue is localized to your normal user account, which makes it much more likely that it's caused by a configuration issue on your side rather than a code issue on our side.

Thanks!
Comment 15 Vijit 2024-09-16 14:36:35 UTC
There is no problem with a new user.
Comment 16 Nate Graham 2024-09-16 15:46:29 UTC
OK great, that means it's likely a configuration issue in your normal user account.

Have you made any changes or customizations that could account for this? Examples:
- Manual shortcuts/autostart entries for kglobalaccel
- Running System Settings as root/sudo
Comment 17 Vijit 2024-09-16 15:53:54 UTC
> Have you made any changes or customizations that could account for this?

Explicitly - no. 

I still tracking krunner's behavior after reboot. And it works properly for now.
Comment 18 Nate Graham 2024-09-16 16:16:18 UTC
So after rebooting you're unable to reproduce the issue anymore? Is that right?
Comment 19 Vijit 2024-09-17 03:10:30 UTC
As I already said before:
> I met with this a few times. After reboot this behavior disappeared and appears again by some reason.
Comment 20 Nate Graham 2024-09-17 17:15:26 UTC
So you reboot, the problem goes away, and then at some point in time, it comes back?
Comment 21 Vijit 2024-09-18 03:04:30 UTC
Exactly.
Comment 22 Nate Graham 2024-09-18 18:18:27 UTC
I still think this is highly likely to be caused by a configuration issue in your home folder, but I'm out of ideas as to what specifically it might be.