Linux Ubuntu 上的 Samba 文件共享不会屏蔽或强制新文件的权限

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8997219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:13:03  来源:igfitidea点击:

Samba file sharing on Ubuntu doesn't mask or force permissions for new files

linuxfileubuntufile-permissionssamba

提问by Aharon Rossano

I've setup a shared folder on my Ubuntu 10.4 server using Samba and put in the following configuration to the shared folder:

我已经使用 Samba 在我的 Ubuntu 10.4 服务器上设置了一个共享文件夹,并将以下配置放入共享文件夹中:

[share]
    comment = Ubuntu File Server Share
    path = path..
    browsable = yes
    valid users = @team
    write list = @team
        force group = team
        writable = yes
        printable = no
    guest ok = no
    read only = no
    create mask = 0664
    directory mask = 0775
    force create mode = 0775 

My issue is that new files created are still coming up with 644 instead of 664. Any suggestions on what else to try to ensure that it corrects the permission?

我的问题是创建的新文件仍然是 644 而不是 664。还有什么建议可以尝试确保它更正权限?

回答by Marvin Pinto

My understanding of create maskis that samba users are allowed to modify those permissions up to the mask. So if you set it to 0777for example, then a user would be able to modify all bits. This is notthe same as unix file masks. So your setting of 0664 would mean that a user can modify the permissions on User (rw), Group (rx) and Other (r). This does notmean that the files will be created with those permissions - simply means that the user can usethose permissions.

我的理解create mask是允许 samba 用户将这些权限修改为掩码。因此,如果您将其设置0777为例如,那么用户将能够修改所有位。这是一样的UNIX文件掩码。因此,您的 0664 设置意味着用户可以修改用户 ( rw)、组 ( rx) 和其他 ( r)的权限。但这并不意味着该文件将与权限创建-简单的说就是用户可以使用这些权限。

You can use force create modeinstead which shoulddo what you need:

您可以force create mode改用 which来满足您的需求:

force create mode = 0664

回答by zuallauz

I would try removing the create and directory mask settings. I can get it to work by just using this:

我会尝试删除创建和目录掩码设置。我可以通过使用它来让它工作:

force create mode = 0775
force directory mode = 0775
force user = zuallauz
force group = www-data

That forces all the new directories and files created to have 0775 permissions.

这会强制创建的所有新目录和文件都具有 0775 权限。

Failing that you could try setting the parent directory manually once via command line to 775 (or whatever permissions you need) then using:

如果失败,您可以尝试通过命令行手动将父目录设置为 775(或您需要的任何权限),然后使用:

inherit permissions = yes

inherit permissions = yes

Theoretically all new files should inherit their parent directory's permissions. Don't forget to restart samba after changing the config:

理论上所有新文件都应该继承其父目录的权限。更改配置后不要忘记重新启动 samba:

sudo restart smbd
sudo restart nmbd

See good documentation on all the settings here.

在此处查看有关所有设置的良好文档。