ZaWertun / fedora-copr-kde5

https://copr.fedorainfracloud.org/coprs/zawertun/kde/
18 stars 4 forks source link

kdesu always asks for the root password instead of the user password #129

Closed popov895 closed 2 years ago

popov895 commented 2 years ago

SUMMARY

When I installed my system I locked the root password (this is by default) and everything works fine: I can work with the root privileges in the terminal, I can edit and save system files in KWrite, synchronize SDDM settings, and I'm always asked for the user password (not root). But when I launch KSystemLog, I'm always asked for the root password instead of the user password, and since the root password is locked, I cannot run this application with the root privileges.

$ sudo passwd -S root
root LK 1969-12-31 0 99999 7 -1 (Password locked.)
$ groups
epopov wheel

Screenshot_20220817_110902

The same thing happens when I launch KSystemLog with kdesu ksystemlog from terminal, but when I launch it with sudo ksystemlog, I'm asked for the user password (not root) and the app launches with the root privileges. I have a similar issue on openSUSE Tumbleweed (https://bugzilla.opensuse.org/show_bug.cgi?id=1197052), so I'm not sure if it's not a polkit or kdesu problem in this case.

$ dnf info kdesu
Installed Packages
Name         : kdesu
Epoch        : 1
Version      : 5.25.4
Release      : 1.fc36
Architecture : x86_64
Size         : 443 k
Source       : kde-cli-tools-5.25.4-1.fc36.src.rpm
Repository   : @System
From repo    : copr:copr.fedorainfracloud.org:zawertun:kde
Summary      : Runs a program with elevated privileges
URL          : https://cgit.kde.org/kde-cli-tools
License      : GPLv2+
Description  : Runs a program with elevated privileges.

SOFTWARE/OS VERSIONS

Operating System: Fedora Linux 36 KDE Plasma Version: 5.25.4 KDE Frameworks Version: 5.97.0 Qt Version: 5.15.5 Graphics Platform: X11

ZaWertun commented 2 years ago

kdesu uses su to run commands, it's can be changed only in compiletime. See:

  1. https://invent.kde.org/frameworks/kdesu/-/blob/master/CMakeLists.txt#L48
  2. https://invent.kde.org/frameworks/kdesu/-/blob/master/src/suprocess.cpp#L33
ZaWertun commented 2 years ago

Just checked: even when compiled with KDESU_USE_SUDO_DEFAULT=On it still requires password, while my user already in wheel group.

popov895 commented 2 years ago

kdesu uses su to run commands, it's can be changed only in compiletime. See:

Default super user command can be changed via config file:

ZaWertun commented 2 years ago

kdesu uses su to run commands, it's can be changed only in compiletime. See:

Default super user command can be changed via config file:

* https://wiki.archlinux.org/title/sudo#kdesu

* https://invent.kde.org/frameworks/kdesu/-/blob/master/src/suprocess.cpp#L60

It's still won't help running with sudo while in wheel group. There is just no such logic in kdesu sources. It always asks for a password.

ZaWertun commented 2 years ago

https://bugs.kde.org/show_bug.cgi?id=349236

ZaWertun commented 2 years ago

Just found same bug from 2015 year, 100% your case.

popov895 commented 2 years ago

I think I figured it out.

save system files in KWrite, synchronize SDDM settings, and I'm always asked for the user password (not root)

For these purposes, authorization helpers are used:

when I launch KSystemLog, I'm always asked for the root password instead of the user password

It's not yet clear whether this is a kdesu or polkit issue (kdesu is most likely to blame). In my case, editing the desktop file of the application helped:

Exec=ksystemlog -qwindowtitle %c
X-KDE-SubstituteUID=true

should be replaced to

Exec=pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ksystemlog -qwindowtitle %c
X-KDE-SubstituteUID=false

See https://askubuntu.com/questions/1404500/software-sources-not-accessible-from-discover.

popov895 commented 2 years ago

Default super user command can be changed via config file:

* https://wiki.archlinux.org/title/sudo#kdesu

This did the trick for me!