fix #1178, change directory permission from 0777 to 0755

This commit is contained in:
joyqi 2021-09-15 14:59:08 +08:00
parent 4e5b88821d
commit 64b8e68688
5 changed files with 8 additions and 12 deletions

View File

@ -41,7 +41,7 @@ jobs:
mkdir build
cp -r LICENSE.txt index.php install.php admin install usr var build/
mkdir build/usr/uploads/
chmod 777 build/usr/uploads/
chmod 755 build/usr/uploads/
rm -rf build/admin/src
cd build && zip -q -r typecho.zip * && mv typecho.zip ../ && cd -
- name: Upload a Build Artifact

View File

@ -14,7 +14,7 @@ jobs:
mkdir build
cp -r LICENSE.txt index.php install.php admin install usr var build/
mkdir build/usr/uploads/
chmod 777 build/usr/uploads/
chmod 755 build/usr/uploads/
rm -rf build/admin/src
cd build && zip -q -r typecho.zip * && mv typecho.zip ../ && cd -
- name: Create Release

View File

@ -752,13 +752,13 @@ function install_step_1_perform()
$realUploadDir = \Typecho\Common::url($uploadDir, __TYPECHO_ROOT_DIR__);
$writeable = true;
if (is_dir($realUploadDir)) {
if (!is_writeable($realUploadDir)) {
if (!@chmod($realUploadDir, 0644)) {
if (!is_writeable($realUploadDir) || !is_readable($realUploadDir)) {
if (!@chmod($realUploadDir, 0755)) {
$writeable = false;
}
}
} else {
if (!@mkdir($realUploadDir, 0644)) {
if (!@mkdir($realUploadDir, 0755)) {
$writeable = false;
}
}

View File

@ -352,12 +352,12 @@ Typecho_Date::setTimezoneOffset($options->timezone);
$uploadDir = Common::url(Upload::UPLOAD_DIR, __TYPECHO_ROOT_DIR__);
if (is_dir($uploadDir)) {
if (!is_writeable($uploadDir)) {
if (!@chmod($uploadDir, 0644)) {
if (!@chmod($uploadDir, 0755)) {
throw new \Typecho\Widget\Exception(_t('上传目录无法写入, 请手动将安装目录下的 %s 目录的权限设置为可写然后继续升级', Upload::UPLOAD_DIR));
}
}
} else {
if (!@mkdir($uploadDir, 0644)) {
if (!@mkdir($uploadDir, 0755)) {
throw new \Typecho\Widget\Exception(_t('上传目录无法创建, 请手动创建安装目录下的 %s 目录, 并将它的权限设置为可写然后继续升级', Upload::UPLOAD_DIR));
}
}

View File

@ -273,14 +273,10 @@ class Upload extends Contents implements ActionInterface
return true;
}
if (!@mkdir($last)) {
if (!@mkdir($last, 0755)) {
return false;
}
$stat = @stat($last);
$perms = $stat['mode'] & 0007777;
@chmod($last, $perms);
return self::makeUploadDir($path);
}