Why is sed changing permissions of a file on a cifs mounted share?

I have an Arch linux machine that uses the following fstab entry to mount a share:

The server that is sharing the folder is a Windows server, and the partition the shared folder is on is NTFS.

Using the above fstab entry, the share mounts at boot just fine. As expected, all files at /mnt/ appear to be owned by 'tal' and have the permissions 0600. Newly created files under /mnt are also owned by tal (whether they are created by root or tal), and have the 0600 permissions, as expected.

The problem is that if I have a file under /mnt:

and I run this on it:

to delete the first 2 lines, the 2 lines are deleted, but the file's permissions change to:

Why is sed changing the file permissions? Looking at the inode of test.txt, I can tell that sed's -i option recreates the file with the new content rather than modifying the file, but that shouldn't really matter - all newly created files under /mnt should get the 0600 permissions.

As a test, I modified the same file with vim and checked the inodes too. Vim also recreates the file in place rather than modifying it, but when vim does it, the permissions remain as 0600.

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论