SUPEE 7405 补丁后上传文件的 chmod 640
Chmod 640 for uploaded file after SUPEE 7405 patch
安装 SUPEE 7405 补丁后,我们注意到从管理员上传图片时出现问题。所有文件权限都设置为 CHMOD 640,这使得所有用户都无法访问它们。
有没有不涉及重写/lib/Varien/File/Uploader.php文件的解决方案?
更改 Upload.php 代码适用于我的所有安装。
To fix existing uploaded images, you need to change ALL existing uploaded images permissions (chmod) from 0640 to 0644.
To fix it for the future, you would need to edit /lib/Varien/File/Uploader.php and change the line from (after applying the patch)
chmod($destinationFile, 0640);
to
chmod($destinationFile, 0644);
There is a similar one for directories that you'll need to change from 0750 to 0755.
已发布解决此问题的新版 SUPEE-7405:
http://magento.com/security/patches/supee-7405
Updated February 23, 2016
Updated versions of this release are now available. The updates add support for PHP 5.3 and address issues with upload file permissions, merging carts, and SOAP APIs experienced with the original release.
请注意,即使没有修改过的补丁,您也可以使用推荐的文件权限(见下文)来解决问题。
Magento 期望网络服务器拥有站点文件:
http://devdocs.magento.com/guides/m1x/install/installer-privileges_after.html#privs-after
您可以通过将网络服务器设为文件的所有者来解决此问题。
chown -R web-server-user-name magento/root/path
网络服务器用户名通常为www-data
或apache
。
如果您按照上述link中的说明进行操作,网络服务器将拥有对所有文件的读取权限,以及对媒体文件和 var 文件的写入权限。这应该是典型站点操作所需的全部内容。如果您需要使用 Magento Connect,您必须暂时授予网络服务器对所有文件的写入权限。
All file permissions are being set to CHMOD 640 which makes them inaccessible to all users.
只有网络服务器用户需要访问这些文件。无需向所有用户授予任何权限。
例如,如果您需要通过 FTP 编辑或上传文件,您可能希望向特定用户授予访问权限。在这种情况下,我所做的是设置一个拥有文件系统的用户并将文件的组设置为网络服务器:
cd magento/root/directory
# Set ownership
# 'username' should be the file system owner username
# 'webserver' should be the webserver username
chown -R username:webserver .
# Give the user read/write access to all files.
# Give the webserver read access to all files
find . -type f -exec chmod 640 {} \;
find . -type d -exec chmod 2750 {} \;
# Give the user and the webserver read/write access to var and media
find var/ -type f -exec chmod 660 {} \;
find media/ -type f -exec chmod 660 {} \;
find var/ -type d -exec chmod 2770 {} \;
find media/ -type d -exec chmod 2770 {} \;
chmod 2770 includes
chmod 660 includes/config.php
以上命令将授予您的文件系统所有者 read/write 访问所有内容的权限,以及网络服务器读取所有内容的权限。网络服务器也将能够写入媒体和 var 目录。
我们已经为我们的环境解决了这个问题,但是,我不确定这对其他人有多大帮助。尽管我不是网络工程师,但我会尽力解释。如果有足够多的人认为此 post 有帮助,我会将其标记为正确。另外,请注意,尽管问题是由 Magento 的 SUPEE 7405 补丁引起的,但解决方案是基于网络的,而不是基于代码的。
我相信补丁中更改 chmod 的目的是防止黑客劫持您的图像并在其中存储敏感数据(例如结帐 header 图像黑客)。为了防止这种黑客攻击,他们通过 chmod 640 限制对上传 files/images 的所有访问。
话虽如此...
Magento 1.X 的最新补丁似乎需要 环境配置更改 。正如我们的一位网络工程师所说,他们假设我们使用 Apache mod_php,它以 Apache 用户身份读取和写入所有文件。但是,如果您使用的是 fcgi 或 suphp,则文件将以域用户身份写入。根据您的环境,您可能需要将 Apache 添加到您的组并允许它读取文件。
首先尝试 chown -R 解决方案,如果它不起作用,您可能需要联系您的主机或将 Apache 添加到您的 "groups" 以便它具有所有者访问权限。
接受的答案是一个很好的解决方案。
如果您无法更改所有权(可能是因为您在共享服务器上),您可以运行 cron 作业来更改新上传文件的文件权限。
*/3 * * * * find /path/to/magento/ -type f -perm 640 -exec chmod 644 {} \;
*/3 * * * * find /path/to/magento/ -type d -perm 750 -exec chmod 2755 {} \;
请继续此文件
lib/Varien/File/Uploader.php
只需更改第 220 行并将 chmod($destinationFile, 0640)
更改为 chmod($destinationFile, 0644)
有效。
安装 SUPEE 7405 补丁后,我们注意到从管理员上传图片时出现问题。所有文件权限都设置为 CHMOD 640,这使得所有用户都无法访问它们。
有没有不涉及重写/lib/Varien/File/Uploader.php文件的解决方案?
更改 Upload.php 代码适用于我的所有安装。
To fix existing uploaded images, you need to change ALL existing uploaded images permissions (chmod) from 0640 to 0644.
To fix it for the future, you would need to edit /lib/Varien/File/Uploader.php and change the line from (after applying the patch)
chmod($destinationFile, 0640);
to
chmod($destinationFile, 0644);
There is a similar one for directories that you'll need to change from 0750 to 0755.
已发布解决此问题的新版 SUPEE-7405:
http://magento.com/security/patches/supee-7405
Updated February 23, 2016
Updated versions of this release are now available. The updates add support for PHP 5.3 and address issues with upload file permissions, merging carts, and SOAP APIs experienced with the original release.
请注意,即使没有修改过的补丁,您也可以使用推荐的文件权限(见下文)来解决问题。
Magento 期望网络服务器拥有站点文件:
http://devdocs.magento.com/guides/m1x/install/installer-privileges_after.html#privs-after
您可以通过将网络服务器设为文件的所有者来解决此问题。
chown -R web-server-user-name magento/root/path
网络服务器用户名通常为www-data
或apache
。
如果您按照上述link中的说明进行操作,网络服务器将拥有对所有文件的读取权限,以及对媒体文件和 var 文件的写入权限。这应该是典型站点操作所需的全部内容。如果您需要使用 Magento Connect,您必须暂时授予网络服务器对所有文件的写入权限。
All file permissions are being set to CHMOD 640 which makes them inaccessible to all users.
只有网络服务器用户需要访问这些文件。无需向所有用户授予任何权限。
例如,如果您需要通过 FTP 编辑或上传文件,您可能希望向特定用户授予访问权限。在这种情况下,我所做的是设置一个拥有文件系统的用户并将文件的组设置为网络服务器:
cd magento/root/directory
# Set ownership
# 'username' should be the file system owner username
# 'webserver' should be the webserver username
chown -R username:webserver .
# Give the user read/write access to all files.
# Give the webserver read access to all files
find . -type f -exec chmod 640 {} \;
find . -type d -exec chmod 2750 {} \;
# Give the user and the webserver read/write access to var and media
find var/ -type f -exec chmod 660 {} \;
find media/ -type f -exec chmod 660 {} \;
find var/ -type d -exec chmod 2770 {} \;
find media/ -type d -exec chmod 2770 {} \;
chmod 2770 includes
chmod 660 includes/config.php
以上命令将授予您的文件系统所有者 read/write 访问所有内容的权限,以及网络服务器读取所有内容的权限。网络服务器也将能够写入媒体和 var 目录。
我们已经为我们的环境解决了这个问题,但是,我不确定这对其他人有多大帮助。尽管我不是网络工程师,但我会尽力解释。如果有足够多的人认为此 post 有帮助,我会将其标记为正确。另外,请注意,尽管问题是由 Magento 的 SUPEE 7405 补丁引起的,但解决方案是基于网络的,而不是基于代码的。
我相信补丁中更改 chmod 的目的是防止黑客劫持您的图像并在其中存储敏感数据(例如结帐 header 图像黑客)。为了防止这种黑客攻击,他们通过 chmod 640 限制对上传 files/images 的所有访问。
话虽如此...
Magento 1.X 的最新补丁似乎需要 环境配置更改 。正如我们的一位网络工程师所说,他们假设我们使用 Apache mod_php,它以 Apache 用户身份读取和写入所有文件。但是,如果您使用的是 fcgi 或 suphp,则文件将以域用户身份写入。根据您的环境,您可能需要将 Apache 添加到您的组并允许它读取文件。
首先尝试 chown -R 解决方案,如果它不起作用,您可能需要联系您的主机或将 Apache 添加到您的 "groups" 以便它具有所有者访问权限。
接受的答案是一个很好的解决方案。
如果您无法更改所有权(可能是因为您在共享服务器上),您可以运行 cron 作业来更改新上传文件的文件权限。
*/3 * * * * find /path/to/magento/ -type f -perm 640 -exec chmod 644 {} \;
*/3 * * * * find /path/to/magento/ -type d -perm 750 -exec chmod 2755 {} \;
请继续此文件
lib/Varien/File/Uploader.php
只需更改第 220 行并将 chmod($destinationFile, 0640)
更改为 chmod($destinationFile, 0644)
有效。