Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

インストール時にディレクトリに加えてファイルの書き込み権限もチェックする処理を追加 #3993

Merged
merged 1 commit into from
Nov 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions src/Eccube/Controller/Install/InstallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ class InstallController extends AbstractController
'mcrypt',
];

protected $writableDirs = [
'app',
'html',
'var',
];

/**
* @var PasswordEncoder
*/
Expand Down Expand Up @@ -159,7 +153,7 @@ public function step1(Request $request)
}

/**
* ディレクトリの書き込み権限をチェック.
* ディレクトリとファイルの書き込み権限をチェック.
*
* @Route("/install/step2", name="install_step2")
* @Template("step2.twig")
Expand All @@ -172,20 +166,30 @@ public function step2()
throw new NotFoundHttpException();
}

$protectedDirs = [];
foreach ($this->writableDirs as $writableDir) {
$targetDirs = Finder::create()
->in($this->getParameter('kernel.project_dir').'/'.$writableDir)
->directories();
foreach ($targetDirs as $targetDir) {
if (!is_writable($targetDir->getRealPath())) {
$protectedDirs[] = $targetDir;
}
$noWritePermissions = [];

// ディレクトリの書き込み権限をチェック
$targetDirs = Finder::create()
->in($this->getParameter('kernel.project_dir'))
->directories();
foreach ($targetDirs as $targetDir) {
if (!is_writable($targetDir->getRealPath())) {
$noWritePermissions[] = $targetDir;
}
}

// ファイルの書き込み権限をチェック
$targetFiles = Finder::create()
->in($this->getParameter('kernel.project_dir'))
->files();
foreach ($targetFiles as $targetFile) {
if (!is_writable($targetFile->getRealPath())) {
$noWritePermissions[] = $targetFile;
}
}

return [
'protectedDirs' => $protectedDirs,
'noWritePermissions' => $noWritePermissions,
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Resource/locale/messages.ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ install.start_eccube_installation: '<p>EC-CUBEのインストールを開始し
install.cooperation_of_providing_information: 'EC-CUBEのシステム向上・デバッグのため、サイト情報の提供にご協力おねがいいたします。<br>目的以外で利用することはございません。<br><span class="small">(サイト情報:お店のURL、PHPバージョン、DBバージョン)</span>'
install.accept_infomation_provision: 送信を承諾する
install.permission_is_valid: アクセス権限は正常です
install.permission_is_invalid: 以下のディレクトリのアクセス制限を変更してください
install.permission_is_invalid: 以下のファイルまたはディレクトリに書き込み権限を付与してください
install.system_requirement: システム要件をご確認ください
install.required_extension_disabled: '[必須] %module%拡張モジュールが有効になっていません。'
install.required_database_extension_disabled: '[必須] pdo_pgsql又はpdo_mysql 拡張モジュールを有効にしてください。'
Expand Down
18 changes: 9 additions & 9 deletions src/Eccube/Resource/template/install/step2.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ file that was distributed with this source code.
<div class="row">
<div class="col-md-12">
<textarea class="form-control disp_area" name="disp_area">
{% if protectedDirs|length == 0 %}
&gt;&gt;○:{{ 'install.permission_is_valid'|trans }}
{% else %}
{{ 'install.permission_is_invalid'|trans }}
{% for dir in protectedDirs %}
&gt;&gt;☓:{{ dir }}
{% endfor %}
{% endif %}
{% if noWritePermissions|length == 0 %}
&gt;&gt;○:{{ 'install.permission_is_valid'|trans }}
{% else %}
{{ 'install.permission_is_invalid'|trans }}
{% for noWritePermission in noWritePermissions %}
&gt;&gt;☓:{{ noWritePermission }}
{% endfor %}
{% endif %}
</textarea>
<ul class="btn_area">
<li>
{% if protectedDirs|length > 0 %}
{% if noWritePermissions|length > 0 %}
<a href="{{ path('install_step2') }}" class="btn btn-primary btn-block btn-lg">{{ 'install.update'|trans }}</a>
{% else %}
<a href="{{ path('install_step3') }}" class="btn btn-primary btn-block btn-lg">{{ 'install.next'|trans }}</a>
Expand Down
2 changes: 1 addition & 1 deletion tests/Eccube/Tests/Web/Install/InstallControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function testStep1()
public function testStep2()
{
$this->actual = $this->controller->step2($this->request);
$this->assertArrayHasKey('protectedDirs', $this->actual);
$this->assertArrayHasKey('noWritePermissions', $this->actual);
}

public function testStep3()
Expand Down