How do I correctly set ownership of a cifs mount?

How do I correctly set ownership of a cifs mount?

我尝试使用 fstab 中的以下行挂载 Windows 共享:

//some_mount /media/some_mount cifs uid=1000,gid=1000,credentials=/home/quant/.smbcredentials,sec=ntlm 0 0

当我运行时,sudo mount -a目录/media/some_mount已正确挂载。我还可以看到目录的权限是正确的(即我的用户具有读/写权限)。但是,当我尝试进入其中一个目录时,出现以下错误:

-bash: cd: some_mount/dir/: Operation not permitted

如果我首先运行sudo -i并以 root 身份运行相同的命令,则一切都正常。

我已经尝试运行id -g quantid -u quant并确认我的giduid都是1000。

为什么我不能以非 root 用户身份访问这些目录?

答案1

As @terdon points out you need execute permissions to traverse a directory. Check the permissions on the mount point /media/some_mount in your example. I'll use /mnt for my example

$ ll /mnt
total 20
drwxr-xr-x  5 root root 4096 Oct 24 01:42 ./ 

You'll note that while only the owner (root in my example) has write permissions and both the group (root in my example) and everyone else has read and execute permissions meaning anyone can see the contents of and traverse the directory. chmod is the key to setting permissions. After determining how the permissions are currently set, adjust them according to your requirements. For details on how to do this see the man chmod page. If you need further guidance, drop me a comment and I'll do what I can to help.

相关内容