Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Always permission 777 on mount shared cifs

I have a little problem when I mount a SMB shared folder from a Synology NAS. I want to mount a shared folder with permissions: git:root 700

But the mounted folder always have permission set to 777 ( even after a chmod 700 without error)

In my /etc/fstab I used this line:

#uid=999 ---> git user
//server/folder /mnt/artifacts cifs username=windowsUser,password=xxxxx,gid=0,uid=999,file_mode=0700,dir_mode=0700,iocharset=utf8 0 0

Do you know why I cannot set my rights to 700 ? I did a mistake ? Something stupid ?

Thanks in advance for your help ;)

like image 220
David Avatar asked Nov 07 '16 14:11

David


People also ask

How do I change permissions in CIFS?

To change the permissions a user or a group has for the CIFS share, on the Security tab, under the "Group or user names" pane, click on the user name or the group name and then click Edit.

How do I set 777 permissions on a specific folder?

Easiest way to set permissions to 777 is to connect to Your server through FTP Application like FileZilla, right click on folder, module_installation, and click Change Permissions - then write 777 or check all permissions. Save this answer.


3 Answers

If the remote machine user ID and the local machine user ID do not match, the permissions will default to 777. Mount.cifs doesn't support umask, so instead "noperm" option can be used. This way even if the permissions of the users on the local and remote machines don't match, the user will still be allowed to read and write to the folder, the equivalent of umask=000.

//address/location /mount/location cifs username=username,password=password,noperm,vers=2.0 0 0
like image 96
Docnovak Avatar answered Oct 27 '22 06:10

Docnovak


a good start is to check out the manpage for CIFS:

$ man mount.cifs
[...]
   file_mode=arg
       If the server does not support the CIFS Unix extensions this overrides the default file mode.

   dir_mode=arg
       If the server does not support the CIFS Unix extensions this overrides the default mode for directories.
[...]
   nounix
       Disable the CIFS Unix Extensions for this mount. 
[...]

So since the file_mode (and dir_mode) seem to only work if the server does not support the CIFS Unix extensions, i would start by disabling them (via the nounix option)

like image 41
umläute Avatar answered Oct 27 '22 04:10

umläute


Adding nounix worked just fine. For information, the line I have in /etc/fstab is :

//server/share /mnt/folder cifs credentials=/home/yannick/.smbcredentials,iocharset=utf8,sec=ntlm,vers=1.0,uid=1000,gid=1000,file_mode=0644,dir_mode=0755,nounix 0 0

with 1000 being my user id and group id.

Inside .smbcredentials, I have this :

username=<distant login>
password=<distant password>
like image 2
Yannick Mauray Avatar answered Oct 27 '22 05:10

Yannick Mauray