Bug 471539

Summary: File permissions change after editing txt file
Product: [Frameworks and Libraries] kio-admin Reporter: opensource
Component: generalAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED FIXED    
Severity: grave CC: nate, sitter
Priority: NOR    
Version: 23.04.1   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 5.108
Sentry Crash Report:

Description opensource 2023-06-28 15:34:42 UTC
SUMMARY
***
Editing a txt file using kio-admin slave changes its permissions. 
***


STEPS TO REPRODUCE
1. Create a text file owned by the root user. 
2. Set r/w access permission on the file to the root user only (sudo chmod og-rwx) (ls -l shows '-rw------- 1 root root')
3. Edit the text file with Kate text editor using admin://...path to file, write something, save changes. 

OBSERVED RESULT
File permissions have been changed, the file in now readable by other users/groups (ls -l shows '-rw-r--r-- 1 root root').

EXPECTED RESULT
File permissions should be left unchanged.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.106.0
Qt Version: 5.15.9

ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2023-06-29 12:06:16 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1337
Comment 2 Méven Car 2023-07-07 07:45:44 UTC
Git commit b939a68f166db3d29bb900884d713084cc415751 by Méven Car, on behalf of Harald Sitter.
Committed on 07/07/2023 at 07:07.
Pushed by meven into branch 'master'.

file: preserve mode on put

this prevents us from losing owner/group or mode on overwriting put
operations

M  +25   -0    src/kioworkers/file/file.cpp

https://invent.kde.org/frameworks/kio/-/commit/b939a68f166db3d29bb900884d713084cc415751
Comment 3 Harald Sitter 2023-07-07 09:40:11 UTC
Git commit aa5732dccb2fc82c3a30fce63d6e80339bb021fa by Harald Sitter.
Committed on 07/07/2023 at 09:17.
Pushed by sitter into branch 'kf5'.

file: preserve mode on put

this prevents us from losing owner/group or mode on overwriting put
operations
(cherry picked from commit b939a68f166db3d29bb900884d713084cc415751)

M  +25   -0    src/ioslaves/file/file.cpp

https://invent.kde.org/frameworks/kio/-/commit/aa5732dccb2fc82c3a30fce63d6e80339bb021fa