permissionsdebianmountsmbcifs

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 ;)


Solution

  • Your problem is a very common one. You are using incorrect tags to be able to change the file permissions of the mounted folder.

    You need to add 'umask=', instead of 'file_mode=700' and 'dir_mode=700' as it is using system mount options not CIFS's options.

    To do this you can use:

    //address/location /mount/location cifs credentials=/location,uid=id,gid=id,umask=700 0 0
    

    This will mount the file share under the set file permissions.

    For security I would recommend using a credentials file, which contains the username and password, and must be set as read only.