星期一, 六月 11, 2007

cifs uid/gid overwrite

默认情况下,使用 cifs 挂载 samba 后,挂载文件系统的文件属主是有问题的:
smbclient# ls /mnt/host/ -l
total 24
-rw-r--r-- 1 root root 372 May 25 09:55 adjust
drwxr-xr-x 5 10003 10003 0 Jun 11 11:37 fs_backup
drwxr-xr-x 12 10003 10014 0 Jun 11 11:37 logs
这意味这文件属于了不该属于的用户。但即使使用:
smbclient# mount //store/homes -t cifs /mnt/host -o uid=0,gid=0,username=host_p01,password='********'
挂载也没有用,文件属主还是不对。

从 man 手册的情况来看,是有一个 Unix Extensions 在产生影响。要关闭这个选项,需要在 Samba 客户机上执行:
smbclient# echo "0">/proc/fs/cifs/LinuxExtensionsEnabled
然后再重新挂载 cifs 文件系统,不需要使用 uid,gid 参数,也会映射到 root 用户:
smbclient# mount //store/homes -t cifs /mnt/host -o username=host_p01,password='********'
smbclient# ls /mnt/host/ -l
total 24
-rwxrwSrwt 1 root root 372 May 25 09:55 adjust
drwxrwxrwx 1 root root 0 Jun 11 11:37 fs_backup
drwxrwxrwx 1 root root 0 Jun 11 11:37 logs
但是这样一来,文件的权限又有问题了!!! 只能通过增加参数来解决这个问题:
smbclient# mount //store/homes -t cifs /mnt/host -o file_mode=0644,dir_mode=0755,username=host_p01,password='********'
但是符号链接仍然不能使用。鱼与熊掌呀,现在只能如此了,好在这边应用中还没有必须用到 symlink 的地方,希望后续版本能够解决这个问题

smbclient# cd /mnt/hosts/
smbclient# ln logs/ -s test
ln: creating symbolic link `test' to `logs/': Operation not supported
如果要在服务器端关闭 Unix Extensions,在 /etc/samba/smb.conf 中编辑:
unix extensions = no

没有评论: