更改 debian 上的默认文件权限

发布于 2024-12-21 12:25:57 字数 1459 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦里兽 2024-12-28 12:25:57

您必须更改写入该目录的用户的 umask。顺便说一句,当不需要时不要设置执行权限。

umask 是应该应用的权限的负掩码。默认情况下,所有文件都将使用 666 创建,所有目录将使用 777 创建。当 umask 为 002(这似乎是您想要的)时,它们将变为 664 和 775。

现在,如何设置 umask 取决于实际写入的程序文件,以及此设置在其配置文件中是否可用。

另一种鲜为人知的方法是将 POSIX ACL 设置为上传目录:为此,您可以在 /var/ 上使用 setfacl-d 选项www(前提是您的操作系统和文件系统都支持)。

You must change the umask of the user(s) writing to the directory. And BTW do NOT set execute permissions when they are not needed.

A umask is a negative mask of permissions which should be applied. By default, all files would be created with 666 and all directories with 777. With a umask of 002, which seems to be what you want, these become 664 and 775.

Now, how to set the umask depends on the program which actually writes the file, and whether this setting is available in its configuration file.

Another, less known way, would be to set POSIX ACLs to the upload directory: for this, you can use setfacl with the -d option on /var/www (provided your OS, and filesystem, support it both).

嘿看小鸭子会跑 2024-12-28 12:25:57

您的评论之一表明您正在通过 proftpd 上传文件。如果是这种情况,那么您的问题确实是针对该软件的。答案是不要修改 /etc/profile,因为这将更改所有使用 Bourne Shell 或类似(即 Bash)的用户的默认 umask。此外,用户必须实际登录到 shell 才能读取 /etc/profile,并且在正确配置的系统上,运行守护程序的用户实际上并不登录。检查 http://www.proftpd.org/docs/howto/Umask.html 了解 proftpd 和 umask 的特定信息。

One of your comments suggests you are uploading the files through proftpd. If this is the case, then your question is really specific to that piece of software. The answer is not to go modifying /etc/profile, as that is going to change the default umask for all users that use Bourne Shell or similar (i.e. Bash). Furthermore, a user must actually log into the shell for /etc/profile to be read, and on a properly configured system, the user your daemon is running as does not actually log in. Check http://www.proftpd.org/docs/howto/Umask.html for information specific to proftpd and umasks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文