Bug 363678

Summary: kauth_install_actions does not honour CMAKE_INSTALL_PREFIX
Product: [Frameworks and Libraries] frameworks-kauth Reporter: Elvis Angelaccio <elvis.angelaccio>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs>
Status: CONFIRMED ---    
Severity: normal CC: alexander.lohnau, cfeck, emmanuel.lepage, harmathy, herzenschein, kmcwilliampublic, postix
Priority: NOR    
Version: 5.22.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Elvis Angelaccio 2016-05-29 20:54:07 UTC
This issue is documented in [1] and there is a workaround (building polkit-qt-1 and then rebuilding kauth), but still, it would be nice to have it fixed.

[1]: https://techbase.kde.org/Getting_Started/Build/Troubleshooting#Issues_building_kdebase

Reproducible: Always

Steps to Reproduce:
1. git clone git://anongit.kde.org/kwalletmanager.git && cd kwalletmanager
2. mkdir build && cd build
3. cmake -DCMAKE_INSTALL_PREFIX=~/foo ..
4. make install

Actual Results:  
CMake Error at src/konfigurator/cmake_install.cmake:92 (file):
  file INSTALL cannot copy file
  "/home/elvis/kwalletmanager/build/src/konfigurator/org.kde.kcontrol.kcmkwallet5.policy"
  to "/usr/share/polkit-1/actions/org.kde.kcontrol.kcmkwallet5.policy".

a.k.a.

kauth_install_actions ignores my CMAKE_INSTALL_PREFIX and tries to install in /usr/share/polkit-1/actions/

Expected Results:  
make install exits without error
a.k.a.
kauth_install_actions (called by kwalletmanager) respects CMAKE_INSTALL_PREFIX.
Comment 1 Christoph Feck 2016-05-30 02:24:33 UTC
Can polkit be instructed to also look into other directories? From what I know, both dbus and polkit only check the system directories, because of security reasons. It might be possible to expand this path of system directories.
Comment 2 Elvis Angelaccio 2016-05-30 10:57:26 UTC
(In reply to Christoph Feck from comment #1)
> Can polkit be instructed to also look into other directories? From what I
> know, both dbus and polkit only check the system directories, because of
> security reasons. It might be possible to expand this path of system
> directories.

The techbase link above does mention a KDE4_AUTH_POLICY_FILES_INSTALL_DIR cmake variable that used to be configurable via command line. Nowadays doesn't seem to work anymore (KAuth has a KAUTH_POLICY_FILES_INSTALL_DIR variable, but I'm not sure it can be overriden).

dbus doesn't seem affected, e.g. kwalletmanager install the following dbus files just fine:

-- Installing: /home/elvis/test/etc/dbus-1/system.d/org.kde.kcontrol.kcmkwallet5.conf
-- Installing: /home/elvis/test/share/dbus-1/system-services/org.kde.kcontrol.kcmkwallet5.service
Comment 3 Christoph Feck 2016-05-30 15:41:36 UTC
> kwalletmanager install the following dbus files just fine

But you also need to add these directories to /etc/dbus-1/*.conf
For details, see https://dbus.freedesktop.org/doc/dbus-daemon.1.html
Comment 4 Max Harmathy 2018-08-17 13:22:14 UTC
Would it be possible to not install the policy file if an install prefix is set?
Comment 5 Max Harmathy 2018-08-17 13:49:23 UTC
I just realised, that this would make packaging impossible.

But I looked into actual packaging and found that setting DESTDIR on installation resolves the issue.
Comment 6 Christoph Feck 2018-09-04 23:18:09 UTC
*** Bug 397517 has been marked as a duplicate of this bug. ***
Comment 7 Thiago Sueto 2022-05-23 09:07:17 UTC
This issue is more broad than just the polkit case and currently hinders building and installing plasma-desktop locally without kdesrc-build, and I assume this should affect any other KDE software that uses KAUTH_HELPER_INSTALL_DIR.

There's a relevant mailing list thread about this: https://mail.kde.org/pipermail/kde-core-devel/2020-October/091002.html

It is not possible to bypass this permission issue in any way. I tried with all of these, none worked:

KAUTH_HELPER_INSTALL_DIR
INSTALL_BROKEN_KAUTH_POLICY_FILES
KAUTH_BACKEND_NAME
KAUTH_POLICY_FILES_INSTALL_DIR
KDE4_AUTH_POLICY_FILES_INSTALL_DIR

And I tried numerous combinations of CMAKE_INSTALL_PREFIX and DESTDIR in my attempts to make this work for months, thinking this was perhaps some user error on my side.

So currently the only ways of testing software that uses this KAuth feature without kdesrc-build are:

* install everything as root, which is liable to break things
And assuming you actually know about this issue, what's happening in the background and what to do with this cryptic error message:
* CMAKE_INSTALL_PREFIX=/local/path then sudo install, thus overriding the package manager's installed files
* comment out the install line in the CMakeLists.txt that uses KAUTH_HELPER_INSTALL_DIR
* compile KAuth together with the application one wants to compile

Use case: I was trying to self compile plasma-desktop just to work on a KCM which isn't related and doesn't use KAUTH_HELPER_INSTALL_DIR anywhere.
Comment 9 Alexander Lohnau 2022-05-25 07:28:25 UTC
>I'm going to leave these references here one shows polkit hardcoding /usr and one shows dbus hardcoding /usr.

By my understanding this shows, that for the use case Thiago described, skipping the installation is the most sensible option.
Comment 10 Alexander Lohnau 2022-07-08 18:13:38 UTC
As Harald pointed out, there is the INSTALL_BROKEN_KAUTH_POLICY_FILES cmake option.
However, this is only used inside of the KAUTH_INSTALL_ACTIONS function. Meaning the KAuth config paths will not respect those settings.

An alternative might be to allow overriding the KAuth backend that is used and then set the KAuth variables accordingly to the CMAKE_INSTALL_PREFIX. Then projects like plasma-desktop can installed, without some files  getting installed to /usr. 
What do you think?
Comment 11 Kristen McWilliam 2024-09-05 18:40:47 UTC
Ran into this while trying to extend a KAuth helper; really unfortunate developer experience.

If we don't have a good way to resolve the root issues, perhaps someone familiar could at least update the KAuth guide with information about how to properly build and test: https://develop.kde.org/docs/features/kauth/using_kauth/