始终在挂载共享cif上获得权限777

时间:2016-11-07 14:53:13

标签: permissions debian mount smb cifs

从Synology NAS挂载SMB共享文件夹时遇到一些问题。 我想安装一个具有权限的共享文件夹:git:root 700

但是挂载的文件夹总是将权限设置为777(即使在没有错误的chmod 700之后)

在我的/etc/fstab我用过这一行:

#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

你知道为什么我不能设置700的权利吗? 我犯了一个错误?有点蠢吗?

先谢谢你的帮助;)

5 个答案:

答案 0 :(得分:3)

一个好的开始是查看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. 
[...]

因为file_mode(和dir_mode)似乎仅在服务器支持CIFS Unix扩展时才起作用,我将首先禁用它们(通过nounix选项)

答案 1 :(得分:2)

如果远程计算机用户ID和本地计算机用户ID不匹配,则权限默认为777。Mount.cifs不支持umask,因此可以使用“ noperm”选项。这样,即使本地和远程计算机上的用户权限不匹配,仍将允许用户读写该文件夹,等效于umask = 000。

//address/location /mount/location cifs username=username,password=password,noperm,vers=2.0 0 0

答案 2 :(得分:0)

你的问题很常见。您使用的标记不正确,无法更改已安装文件夹的文件权限。

您需要添加'umask =',而不是'file_mode = 700''dir_mode = 700'系统挂载选项不是CIFS的选项。

要执行此操作,您可以使用:

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

这将以设置文件权限挂载文件共享。

为了安全起见,我建议使用包含用户名和密码的凭证文件,并且必须设置为只读。

答案 3 :(得分:0)

我尝试安装仅具有root权限的CIFS共享。其他用户甚至不能列出任何文件。

因此,我使用了以下fstab条目:

//192.168.0.100/DRV   /mnt/DRV   cifs   user=user,pass=pass,uid=0,gid=0,nounix,file_mode=0007,dir_mode=0007   0   0

我还尝试了 noperm 参数。

我详细创建了具有以下权限的文件夹:

drwxrwx--- 2 root root 4096 Mai 14 09:09 DRV

安装网络共享后,文件夹具有:

d------rwx 2 root root 4096 Mai 14 04:50 W

答案 4 :(得分:0)

添加nounix很好。有关信息,我在/etc/fstab中的行是:

//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

其中1000是我的用户ID和组ID。

.smbcredentials里面,我有这个:

username=<distant login>
password=<distant password>
相关问题