https://bugs.kde.org/show_bug.cgi?id=442798
Bug ID: 442798
Summary: Kate recreates a file when saving it on sshfs, which
removes hardlinks
Product: kate
Version: 21.08.1
Platform: Other
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: application
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
I have a remote server and I want to edit its config via local kate editor. The
file I want to edit is in the directory in which my user does not have write
permissions. I added myself to the group of file and created a hardlink of it
into home directory of myuser at remote server.
root@server:~# touch /etc/example.conf
root@server:~# chgrp myuser /etc/example.conf
root@server:~# ls -l /etc/example.conf
-rw-r--r-- 1 root myuser 0 Sep 22 12:48 /etc/example.conf
myuser@server:~$ echo 123 >> /etc/example.conf
-bash: /etc/example.conf: Permission denied
myuser@server:~$ sudo ln /etc/example.conf example_in_home.conf
myuser@server:~$ ls -l
-rw-r--r-- 2 root myuser 0 Sep 22 12:48 example_in_home.conf
I forgot to give write permission to the myuser group for that file.
Now I mount my home directory from remote server to my localhost
myuser@localhost$ sshfs -o allow_other,default_permissions,uid=1000,gid=1000
server:/home/myuser/ /home/myuser/mnt-dev
If I check the number of hardlinks at localhost, it is 1, but I guess it is
normal.
myuser@localhost$ ls -l /home/myuser/mnt-dev
-rw-r--r-- 1 myuser myuser 0 Sep 22 12:48 example_in_home.conf
Now I open kate, make edit and try to save file.
Expected behavior:
kate says that you do not have write permission to that file.
Actual behavior:
kate shows dialog saying you should be an administrator to save this file and
asks for the password. After entering correct password, file is saved. But it
is saved (I guess) via recreating that file. So the hardlink is lost, and I
_silently_ loose ability to edit _system_ config (/etc/example.conf) of the
remote server.
Additional info.
I checked with vim and it seems that it also does recreating of a file.
However, echo does not mess your file even when you invoke it with sudo:
myuser@localhost$ sudo echo 555 >> example_in_home.conf
bash: example_in_home.conf: Permission deinied
All is ok (the hardlinks are preserved) when the group w permission is granted
on file.
myuser@server:~$ sudo chmod g+w example_in_home.conf
myuser@server:~$ ls -l
-rw-rw-r-- 2 root myuser 0 Sep 22 12:48 example_in_home.conf
myuser@localhost$ kate /home/myuser/mnt-dev/example_in_home.conf # Write
something to that file via kate.
myuser@server:~$ ls -l
-rw-rw-r-- 2 root myuser 0 Sep 22 12:48 example_in_home.conf
SOFTWARE/OS VERSIONS
Arch Linux
KDE Plasma Version: 5.22.90
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2
Kate: 21.08.1
sshfs: 3.7.2-1
--
You are receiving this mail because:
You are watching all bug changes.