Bug 450727 - Can't edit an application's desktop entry which is a symlink
Summary: Can't edit an application's desktop entry which is a symlink
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: Properties dialog (show other bugs)
Version: git master
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-23 00:06 UTC by Roman Nikonov
Modified: 2022-09-16 18:10 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.96


Attachments
Error when trying to change Discord's desktop entry (91.60 KB, image/png)
2022-02-23 00:06 UTC, Roman Nikonov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Nikonov 2022-02-23 00:06:41 UTC
Created attachment 147067 [details]
Error when trying to change Discord's desktop entry

SUMMARY
If user tries to edit a desktop entry in /usr/share/applications that is a symlink to some file without write access, this results in an error.


STEPS TO REPRODUCE
1. Install a package that contains a symlink from /usr/share/applications. For example, Discord package on Arch/Manjaro: `pacman -S discord`
2. Open Application Launcher
3. Right-click on an app installed on step 1, select 'Edit application'
4. Change something and click 'Save'

OBSERVED RESULT
Error:
Could not save properties due to insufficient write access to:
‘/home/roma/.local/share/applications/discord.desktop’.

~/.local/share/applications/discord.desktop is a symlink to /opt/discord/discord.desktop.

EXPECTED RESULT
~/.local/share/applications/discord.desktop is successfully saved and is an arbitrary file owned by the current user.

SOFTWARE/OS VERSIONS
Linux distro: Manjaro stable
KDE Plasma Version: 5.23.5, master
KDE Frameworks Version: 5.90.0, master
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Similar bug: https://bugs.kde.org/show_bug.cgi?id=394476
But it needs to be resolved separately IMO, since it involves editing a file that's already in `~/.local/share/applications/` but is unwriteable for the current user.
Comment 1 Bug Janitor Service 2022-02-23 00:12:56 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/768
Comment 2 Bug Janitor Service 2022-05-22 11:51:33 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/848
Comment 3 Ahmad Samir 2022-06-13 19:19:43 UTC
Git commit a4be43231840a145c808f6ce81217f02f03935e8 by Ahmad Samir.
Committed on 13/06/2022 at 19:19.
Pushed by ahmadsamir into branch 'master'.

KPropertiesDialog: fix saving changes when editing a .desktop file symlink

Consider the use case of:
/usr/share/applications/foo.desktop is symlink to /opt/someapp/foo.desktop

relativeAppsLocation() was using QFile::canonicalFilePath(), which meant
that foo.desktop would resolve to a file outside /usr/share/applications,
since the code, rightly, expects files in QStandardPaths::ApplicationsLocation
locations, m_sRelativePath would end up being empty, which makes the check in
KFilePropsPlugin::slotCopyFinished() fail, and the .desktop file wouldn't
get copied to ~/.local/share/applications/, and the saving would fail.
FIXED-IN: 5.96

M  +5    -3    src/widgets/kpropertiesdialog.cpp

https://invent.kde.org/frameworks/kio/commit/a4be43231840a145c808f6ce81217f02f03935e8
Comment 4 Patrick Silva 2022-09-16 18:10:44 UTC
The error message persists on Arch Linux when I try to edit 'Name' field in 'Application' tab of 'Edit application' window of Discord icon present in Favorites list of Kickoff.

Operating System: Arch Linux
KDE Plasma Version: 5.25.90
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Graphics Platform: Wayland