Always permission 777 on mount shared cifs

不羁的心 提交于 2019-12-06 04:36:22

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.

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)

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!