Skip to content

Commit 150aa06

Browse files
committed
eliminate mkdir error for existing directory
1 parent 78ce49a commit 150aa06

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

server/plugins-available/apache2_plugin.inc.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3791,7 +3791,7 @@ function _add_jailkit_user()
37913791
// add the user to the chroot
37923792
$jailkit_chroot_userhome = $this->_get_home_dir($this->website['system_user']);
37933793

3794-
if(!is_dir($this->website['document_root'].'/etc')) mkdir($this->website['document_root'].'/etc');
3794+
if(!is_dir($this->website['document_root'].'/etc')) $app->system->mkdir($this->website['document_root'].'/etc', 0755, true);
37953795
if(!is_file($this->website['document_root'].'/etc/passwd')) $app->system->exec_safe('touch ?', $this->website['document_root'].'/etc/passwd');
37963796

37973797
// IMPORTANT!
@@ -3800,9 +3800,11 @@ function _add_jailkit_user()
38003800
// and the user has FULL ACCESS to the root of the server!
38013801
$app->system->create_jailkit_user($this->website['system_user'], $this->website['document_root'], $jailkit_chroot_userhome);
38023802

3803-
$app->system->mkdir($this->website['document_root'].$jailkit_chroot_userhome, 0755, true);
3804-
$app->system->chown($this->website['document_root'].$jailkit_chroot_userhome, $this->website['system_user']);
3805-
$app->system->chgrp($this->website['document_root'].$jailkit_chroot_userhome, $this->website['system_group']);
3803+
if(!is_dir($this->website['document_root'].$jailkit_chroot_userhome)) {
3804+
$app->system->mkdir($this->website['document_root'].$jailkit_chroot_userhome, 0750, true);
3805+
$app->system->chown($this->website['document_root'].$jailkit_chroot_userhome, $this->website['system_user']);
3806+
$app->system->chgrp($this->website['document_root'].$jailkit_chroot_userhome, $this->website['system_group']);
3807+
}
38063808

38073809
$app->log("Added created jailkit user home in : ".$this->website['document_root'].$jailkit_chroot_userhome, LOGLEVEL_DEBUG);
38083810
}

server/plugins-available/cron_jailkit_plugin.inc.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ function _add_jailkit_user()
323323
// add the user to the chroot
324324
$jailkit_chroot_userhome = $this->_get_home_dir($this->parent_domain['system_user']);
325325

326-
if(!is_dir($this->parent_domain['document_root'].'/etc')) mkdir($this->parent_domain['document_root'].'/etc');
326+
if(!is_dir($this->parent_domain['document_root'].'/etc')) $app->system->mkdir($this->parent_domain['document_root'].'/etc', 0755, true);
327327
if(!is_file($this->parent_domain['document_root'].'/etc/passwd')) $app->system->exec_safe('touch ?', $this->parent_domain['document_root'].'/etc/passwd');
328328

329329
// IMPORTANT!
@@ -332,9 +332,11 @@ function _add_jailkit_user()
332332
// and the user has FULL ACCESS to the root of the server!
333333
$app->system->create_jailkit_user($this->parent_domain['system_user'], $this->parent_domain['document_root'], $jailkit_chroot_userhome);
334334

335-
$app->system->mkdir($this->parent_domain['document_root'].$jailkit_chroot_userhome, 0755, true);
336-
$app->system->chown($this->parent_domain['document_root'].$jailkit_chroot_userhome, $this->parent_domain['system_user']);
337-
$app->system->chgrp($this->parent_domain['document_root'].$jailkit_chroot_userhome, $this->parent_domain['system_group']);
335+
if(!is_dir($this->parent_domain['document_root'].$jailkit_chroot_userhome)) {
336+
$app->system->mkdir($this->parent_domain['document_root'].$jailkit_chroot_userhome, 0750, true);
337+
$app->system->chown($this->parent_domain['document_root'].$jailkit_chroot_userhome, $this->parent_domain['system_user']);
338+
$app->system->chgrp($this->parent_domain['document_root'].$jailkit_chroot_userhome, $this->parent_domain['system_group']);
339+
}
338340

339341
}
340342

server/plugins-available/nginx_plugin.inc.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3576,7 +3576,7 @@ function _add_jailkit_user()
35763576
// add the user to the chroot
35773577
$jailkit_chroot_userhome = $this->_get_home_dir($this->website['system_user']);
35783578

3579-
if(!is_dir($this->website['document_root'].'/etc')) mkdir($this->website['document_root'].'/etc');
3579+
if(!is_dir($this->website['document_root'].'/etc')) $app->system->mkdir($this->website['document_root'].'/etc', 0755, true);
35803580
if(!is_file($this->website['document_root'].'/etc/passwd')) $app->system->exec_safe('touch ?', $this->website['document_root'].'/etc/passwd');
35813581

35823582
// IMPORTANT!
@@ -3585,10 +3585,11 @@ function _add_jailkit_user()
35853585
// and the user has FULL ACCESS to the root of the server!
35863586
$app->system->create_jailkit_user($this->website['system_user'], $this->website['document_root'], $jailkit_chroot_userhome);
35873587

3588-
$app->system->mkdir($this->website['document_root'].$jailkit_chroot_userhome, 0755, true);
3589-
$app->system->chown($this->website['document_root'].$jailkit_chroot_userhome, $this->website['system_user']);
3590-
$app->system->chgrp($this->website['document_root'].$jailkit_chroot_userhome, $this->website['system_group']);
3591-
3588+
if(!is_dir($this->website['document_root'].$jailkit_chroot_userhome)) {
3589+
$app->system->mkdir($this->website['document_root'].$jailkit_chroot_userhome, 0750, true);
3590+
$app->system->chown($this->website['document_root'].$jailkit_chroot_userhome, $this->website['system_user']);
3591+
$app->system->chgrp($this->website['document_root'].$jailkit_chroot_userhome, $this->website['system_group']);
3592+
}
35923593
$app->log("Added created jailkit user home in : ".$this->website['document_root'].$jailkit_chroot_userhome, LOGLEVEL_DEBUG);
35933594
}
35943595

server/plugins-available/shelluser_jailkit_plugin.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ function _add_jailkit_user()
398398
}
399399
$jailkit_chroot_puserhome = $this->_get_home_dir($this->data['new']['puser']);
400400

401-
if(!is_dir($this->data['new']['dir'].'/etc')) mkdir($this->data['new']['dir'].'/etc', 0755);
401+
if(!is_dir($this->data['new']['dir'].'/etc')) $app->system->mkdir($this->data['new']['dir'].'/etc', 0755, true);
402402
if(!is_file($this->data['new']['dir'].'/etc/passwd')) touch($this->data['new']['dir'].'/etc/passwd', 0755);
403403

404404
// IMPORTANT!
@@ -417,7 +417,7 @@ function _add_jailkit_user()
417417
if(is_dir($this->data['old']['dir'].$jailkit_chroot_userhome_old)) {
418418
$app->system->rename($this->data['old']['dir'].$jailkit_chroot_userhome_old,$this->data['new']['dir'].$jailkit_chroot_userhome);
419419
} else {
420-
mkdir($this->data['new']['dir'].$jailkit_chroot_userhome, 0750, true);
420+
$app->system->mkdir($this->data['new']['dir'].$jailkit_chroot_userhome, 0750, true);
421421
}
422422
}
423423
$app->system->chown($this->data['new']['dir'].$jailkit_chroot_userhome, $this->data['new']['username']);

0 commit comments

Comments
 (0)