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).
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.
发布评论
评论(3)
您应该使用
umask
。更多信息请参见:http://www.cyberciti.biz /tips/understanding-linux-unix-umask-value-usage.htmlYou should use
umask
. More info here: http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html您必须更改写入该目录的用户的 umask。顺便说一句,当不需要时不要设置执行权限。
umask 是应该应用的权限的负掩码。默认情况下,所有文件都将使用 666 创建,所有目录将使用 777 创建。当 umask 为 002(这似乎是您想要的)时,它们将变为 664 和 775。
现在,如何设置 umask 取决于实际写入的程序文件,以及此设置在其配置文件中是否可用。
另一种鲜为人知的方法是将 POSIX ACL 设置为上传目录:为此,您可以在
/var/ 上使用
(前提是您的操作系统和文件系统都支持)。setfacl
和-d
选项wwwYou 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).您的评论之一表明您正在通过 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.