0

I have an heterogeneous share, between Linux and Windows systems, hosted on a NetApp. On Linux, I mount the share with those options:

mount.cifs -o username=`logname`,dom=DOMAIN,cifsacl,multiuser,user_xattr,sec=krb5,iocharset=utf8,noserverino,mapchars //host/share /home/`logname`/mnt

All permissions (set from Windows) are correctly honored. However, there is a strange behavior:

If a user opens a file he created on Windows (or a copy of it) with vim or vi, the file is opened in readonly mode. If he modifies and writes it with :w!, the file gets locked, and cannot be read anymore, even by an administrator or root (permission denied). It can only be deleted by one of those. Gedit opens such files the same way: read only.

However, when such a file is opened with nano, it is precised [converted from DOS format], and when saved, it is flagged [dos format]. The file gets written, and no problem occurs at all.

Do you have any idea why it behaves like that ?

EDIT: I already tried to disable backups and swap files in /etc/vimrc with those options :

set nobackup
set nowritebackup
set noswapfile

Also tried :w! ++ff=dos and :w! ++ff=unix, without success.

NdFeB
  • 1
  • 3
  • I suspect that this is a side effect of how Vim handles "overwriting" a file. It actually moves a file aside and writes a new one, while attempting to preserve the file's OS permissions. Try turning off the 'writebackup' option and and see if the problem goes away. – Heptite Jun 21 '17 at 05:36
  • I have already done that, I edited the initial post to precise it. At the end of my "/etc/vimrc", I have those options : set nobackup, set nowritebackup, set noswapfile. Same behavior... – NdFeB Jun 21 '17 at 10:25
  • Did you check the actual file permissions before and after? – Seth Jun 21 '17 at 10:29
  • The share being NTFS-style permissions from a NetApp, and access being granted with a TGS, all Windows-made files appear to be root:root 000 . But permissions set in Windows are still honored, it is just not visible. So yes, i am sure about permissions, but it is not displayed in Linux, only honored. I mean, there is no problem with nano, only with vi and vim. EDIT: i'm going to check from Windows before and after, then i post again – NdFeB Jun 21 '17 at 11:41
  • Ok, indeed, permissions get overwritten. Explanation: FileA is writable by "Domain Admins" and "GroupA". FileA is copied and named FileB. FileB has the same ACLs. I CANNOT (i just discovered that) overwrite FileB with nano, and I can overwrite it with vi/vim with :w!. If doing so, it changes ACL to the user who edited it, + groups "All users" and "Domain Users". They all have only attributes ticked: "read attributes", "reading of read attributes" and "read authorization". Those last 3 do not honor, either with Windows or Linux : file is untouchable, except for being removed by an admin. – NdFeB Jun 21 '17 at 11:53
  • To summarize : nobody can copy a file from Linux, or the ACL get destroyed and the file is lost. – NdFeB Jun 21 '17 at 11:55

0 Answers0