Bug 475892

Summary: KTextBuffer tries to authenticate as root to save a file even if the file is owned by the user
Product: [Frameworks and Libraries] frameworks-ktexteditor Reporter: zocsfxljsgpmiuaanz
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version First Reported In: 5.111.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description zocsfxljsgpmiuaanz 2023-10-20 20:57:44 UTC
SUMMARY
When a file cannot be saved due to permission issues, KTextBuffer always tries to use the KAuth action "org.kde.ktexteditor.katetextbuffer.savefile" to save it as root. Even when the file is actually owned by the user and in a directory controlled by the user, but the user doesn't have write permissions (which, given that the file is theirs, is easy to change).


STEPS TO REPRODUCE
1. Remove the write permission of a text file owned by your user
2. Modify it with Kate, KWrite, or any application that uses KTextEditor
3. Try to save it

OBSERVED RESULT
A polkit dialog asking for authentication as root appears.

EXPECTED RESULT
Given that you can already change the permission without need of root, KTextEditor should probably simply inform the user about it, change the permission by itself, or something that doesn't involve unnecessary authentication as root.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.11