Bug 498589 - Symbolic link file turns into a regular file after saving edits
Summary: Symbolic link file turns into a regular file after saving edits
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 24.12.1
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-13 08:03 UTC by LuoTat
Modified: 2025-01-18 12:10 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description LuoTat 2025-01-13 08:03:15 UTC
When opening a symbolic link that points to a file requiring root permissions in Kate, the following issue occurs: after editing and saving the file, the symbolic link becomes a regular file.

STEPS TO REPRODUCE
1. Open a symbolic link that points to a file requiring root permissions in Kate.
2. Edit and modify the file.
3. Save the file.
4. Check the file that a symbolic link is now a regular file, losing its symbolic link properties and no longer pointing to the original target.
Comment 1 John Kizer 2025-01-16 06:59:56 UTC
Hi - thanks for your bug report! I can reproduce this on KDE Neon, although with the caveat that at step 3, I'm presented with a privilege escalation dialog since root privileges would be needed to save the original file. After authenticating, the actual root-owned file remained unchanged and the symlink was replaced by a copy of the original file, with the changes included.

As a note though, the following bug report may be related to this one, and this issue may be an unavoidable consequence of other issues that need handled when opening a symlink: https://bugs.kde.org/show_bug.cgi?id=369094 

However, this other report also appears to be a directly related situation, although it is from several years ago and was fixed at the time: https://bugs.kde.org/show_bug.cgi?id=354405

Thanks!
Comment 2 Christoph Cullmann 2025-01-16 19:54:26 UTC
Actually interesting that we did not resolve the symlink first.
Comment 3 Christoph Cullmann 2025-01-16 20:12:27 UTC
That commit did 'break' this:

commit 96a76919f37819b7188e5520528182fb2a7824c0
Author: Patrick Northon <northon_patrick3@yahoo.ca>
Date:   Sun Nov 27 00:35:56 2022 -0500

    - Fixed runningChanhged typo.
    - Define PWD environment variable so that shell scripts can get a path with symbolic links intact.
    - Don't canonize paths in processed lines from build output.
    - In KateDocManager: findDocument will compare canonized paths to avoid opening the same document from different urls. Documents will store an absolute urls.
Comment 4 Christoph Cullmann 2025-01-16 20:15:48 UTC
Ok, this fixes other issues, see

https://invent.kde.org/utilities/kate/-/merge_requests/1021
Comment 5 Bug Janitor Service 2025-01-16 20:23:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/774
Comment 6 Christoph Cullmann 2025-01-16 20:30:09 UTC
Testers for the small patch welcome, this should be minimal intrusive. A lot of the other link resolving issues got solved in https://invent.kde.org/utilities/kate/-/merge_requests/1021 already.
Comment 7 Christoph Cullmann 2025-01-18 12:10:52 UTC
Git commit f8f5b95848c2d172175be9dc92e4907d653a132f by Christoph Cullmann.
Committed on 18/01/2025 at 12:04.
Pushed by cullmann into branch 'master'.

ensure we do not kill symlinks

M  +9    -3    src/buffer/katetextbuffer.cpp

https://invent.kde.org/frameworks/ktexteditor/-/commit/f8f5b95848c2d172175be9dc92e4907d653a132f