权限位未在Samba共享上强制执行


12

我有一个问题,其中未使用Linux客户端在samba共享上强制执行权限位。我在服务器上配置了samba,以强制某些用户,组和权限位,并且此操作按预期工作,直到我触摸该文件或它成为IO重定向的目标为止。

这是正在发生的事情:

user@linuxbox:~-->ls -l ~/archive/foo.txt
ls: cannot access /home/user/archive/foo.txt: No such file or directory
user@linuxbox:~-->touch ~/archive/foo.txt
user@linuxbox:~-->ls -l ~/archive/foo.txt
-rw-rw-r-- 1 archive archive 0 2010-09-13 20:29 /home/user/archive/foo.txt
user@linuxbox:~-->touch ~/archive/foo.txt
user@linuxbox:~-->ls -l ~/archive/foo.txt
-rwxrwxrwx 1 archive archive 0 2010-09-13 20:30 /home/user/archive/foo.txt

请注意,当我触摸现有文件时,其许可权位是0777。它们应该是0664,就像它最初创建时一样。如何在现有文件上执行0664?

我在服务器上有3.0.24版,在客户端上有3.4.7版。这是我的smb.conf:

[global]
interfaces = egiga0
unix charset = UTF8
workgroup = workgroup
netbios name = foo
server string = Foo
security = USER
map to guest = bad user
host msdfs = no
encrypt passwords = yes

[archive]
comment = File Archive
path = /home/archive
force user = archive
force group = archive
read only = yes
write list = @archive
guest ok = yes
create mask = 0
force create mode = 0664
security mask = 0
force security mode = 0664
directory mask = 0
force directory mode = 0775
directory security mask = 0
force directory security mode = 0775

您的smb.conf中有什么?
— Grizly

我已经放入了smb.conf的内容。坦率地说,我不确定是否需要所有显式模式和掩码位。
— 乔纳森·沃特尼

@Jonathon,您的所有操作touch似乎都在* nix系统上...您是在Windows上创建文件的系统吗?还是从Windows系统创建文件?还是这* nix是通过samba到* nix的(在这种情况下为什么是samba而不是nfs)
— xenoterracide 2010年

@xenoterracide,我正在使用Linux客户端触摸共享上的文件;在这种情况下,我要* nix到* nix。混合了Windows,Mac和Linux机器到此samba服务。
— 乔纳森·沃特尼

你确定你的口罩好吗?创建掩码,安全掩码,目录掩码。尚不清楚天气如何,面具本身是否为“ 0”有效。除此之外...多么奇怪。
— gabe。

Answers:


2

samba权限仅在SMB(即Windows)网络客户端上起作用。如果要在服务器(和任何NFS客户端)上强制执行此操作,则需要在所有目录上设置粘滞位。

首先更正其中的文件:

chown -R archive /home/archive 
chgrp -R archive /home/archive 
find /home/archive -type d -exec chmod 0775 {} \;
find /home/archive -type f -exec chmod 0664 {} \;

然后使用组粘滞位强制执行此操作

find /home/archive -type d -exec chmod g+s {} \;

这并非无懈可击,但确实可以解决此类问题的99%。

问候DaveF

在我的Solaris框上的结果:

davef@dalek[10]$ cd /proj/ftptmp
davef@dalek[11]$ ls -ld .
drwxrwsr-x  60 root     ftpusers     377 Oct  5 09:31 ./
davef@dalek[12]$
davef@dalek[12]$ ls -l foo.txt
foo.txt: No such file or directory
davef@dalek[13]$ touch foo.txt
davef@dalek[14]$ ls -l foo.txt
-rw-rw-r--   1 davef    ftpusers       0 Oct 15 11:49 foo.txt
davef@dalek[15]$ touch foo.txt
davef@dalek[16]$ ls -l foo.txt
-rw-rw-r--   1 davef    ftpusers       0 Oct 15 11:49 foo.txt
davef@dalek[17]$
davef@dalek[17]$ umask
2
davef@dalek[18]$

谢谢。终于有机会尝试一下,但是不幸的是问题仍然存在。
— 乔纳森·沃特尼

我想知道这是否可能是您的umask?
— David Allan Finch 2010年

我的umask是0022。还有其他想法吗?:)
— Jonathon Watney 2010年

我需要在Linux机器上尝试一下。还没有时间。顺便说一句,我们使用NFS Unix到Linux等不是SMB。
— David Allan Finch 2010年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.