possibility to specify both ipv4 and ipv6
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -31,6 +31,7 @@ use Froxlor\UI\Panel\UI;
|
|||||||
use Froxlor\UI\Request;
|
use Froxlor\UI\Request;
|
||||||
use Froxlor\Config\ConfigParser;
|
use Froxlor\Config\ConfigParser;
|
||||||
use Froxlor\Validate\Validate;
|
use Froxlor\Validate\Validate;
|
||||||
|
use Froxlor\System\IPTools;
|
||||||
|
|
||||||
class Install
|
class Install
|
||||||
{
|
{
|
||||||
@@ -256,13 +257,18 @@ class Install
|
|||||||
*/
|
*/
|
||||||
private function checkSystem(array $validatedData): void
|
private function checkSystem(array $validatedData): void
|
||||||
{
|
{
|
||||||
$serverip = $validatedData['serverip'] ?? '';
|
$serveripv4 = $validatedData['serveripv4'] ?? '';
|
||||||
|
$serveripv6 = $validatedData['serveripv6'] ?? '';
|
||||||
$servername = $validatedData['servername'] ?? '';
|
$servername = $validatedData['servername'] ?? '';
|
||||||
$httpuser = $validatedData['httpuser'] ?? 'www-data';
|
$httpuser = $validatedData['httpuser'] ?? 'www-data';
|
||||||
$httpgroup = $validatedData['httpgroup'] ?? 'www-data';
|
$httpgroup = $validatedData['httpgroup'] ?? 'www-data';
|
||||||
|
|
||||||
if (!Validate::validate_ip2($serverip, true, '', false, true)) {
|
if (empty($serveripv4) && empty($serveripv6)) {
|
||||||
throw new Exception(lng('error.invalidip', [$serverip]));
|
throw new Exception(lng('install.errors.nov4andnov6ip'));
|
||||||
|
} elseif (!Validate::validate_ip2($serveripv4, true, '', false, true) || IPTools::is_ipv6($serveripv4)) {
|
||||||
|
throw new Exception(lng('error.invalidip', [$serveripv4]));
|
||||||
|
} elseif (!Validate::validate_ip2($serveripv6, true, '', false, true) || IPTools::is_ipv6($serveripv6) == false) {
|
||||||
|
throw new Exception(lng('error.invalidip', [$serveripv6]));
|
||||||
} elseif (!Validate::validateDomain($servername) && !Validate::validateLocalHostname($servername)) {
|
} elseif (!Validate::validateDomain($servername) && !Validate::validateLocalHostname($servername)) {
|
||||||
throw new Exception(lng('install.errors.servernameneedstobevalid'));
|
throw new Exception(lng('install.errors.servernameneedstobevalid'));
|
||||||
} elseif (posix_getpwnam($httpuser) === false) {
|
} elseif (posix_getpwnam($httpuser) === false) {
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ class Core
|
|||||||
$mysql_access_host_array = array_map('trim', explode(',', $this->validatedData['mysql_access_host']));
|
$mysql_access_host_array = array_map('trim', explode(',', $this->validatedData['mysql_access_host']));
|
||||||
|
|
||||||
// @todo localhost/127.0.0.1/serverip checks and addition is only required if mysql_access_host is not a separate machine
|
// @todo localhost/127.0.0.1/serverip checks and addition is only required if mysql_access_host is not a separate machine
|
||||||
|
/*
|
||||||
if (in_array('127.0.0.1', $mysql_access_host_array) && !in_array('localhost', $mysql_access_host_array)) {
|
if (in_array('127.0.0.1', $mysql_access_host_array) && !in_array('localhost', $mysql_access_host_array)) {
|
||||||
$mysql_access_host_array[] = 'localhost';
|
$mysql_access_host_array[] = 'localhost';
|
||||||
}
|
}
|
||||||
@@ -240,6 +241,7 @@ class Core
|
|||||||
if (!in_array($this->validatedData['serverip'], $mysql_access_host_array)) {
|
if (!in_array($this->validatedData['serverip'], $mysql_access_host_array)) {
|
||||||
$mysql_access_host_array[] = $this->validatedData['serverip'];
|
$mysql_access_host_array[] = $this->validatedData['serverip'];
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
$mysql_access_host_array = array_unique($mysql_access_host_array);
|
$mysql_access_host_array = array_unique($mysql_access_host_array);
|
||||||
|
|
||||||
@@ -370,8 +372,10 @@ class Core
|
|||||||
WHERE `settinggroup` = :group AND `varname` = :varname
|
WHERE `settinggroup` = :group AND `varname` = :varname
|
||||||
");
|
");
|
||||||
|
|
||||||
|
$mainip = !empty($this->validatedData['serveripv6']) ? $this->validatedData['serveripv6'] : $this->validatedData['serveripv4'];
|
||||||
|
|
||||||
$this->updateSetting($upd_stmt, 'admin@' . $this->validatedData['servername'], 'panel', 'adminmail');
|
$this->updateSetting($upd_stmt, 'admin@' . $this->validatedData['servername'], 'panel', 'adminmail');
|
||||||
$this->updateSetting($upd_stmt, $this->validatedData['serverip'], 'system', 'ipaddress');
|
$this->updateSetting($upd_stmt, $mainip, 'system', 'ipaddress');
|
||||||
if ($this->validatedData['use_ssl']) {
|
if ($this->validatedData['use_ssl']) {
|
||||||
$this->updateSetting($upd_stmt, 1, 'system', 'use_ssl');
|
$this->updateSetting($upd_stmt, 1, 'system', 'use_ssl');
|
||||||
$this->updateSetting($upd_stmt, 1, 'system', 'leenabled');
|
$this->updateSetting($upd_stmt, 1, 'system', 'leenabled');
|
||||||
@@ -496,23 +500,47 @@ class Core
|
|||||||
`ssl` = :ssl
|
`ssl` = :ssl
|
||||||
");
|
");
|
||||||
$nvh = $this->validatedData['webserver'] == 'apache2' ? '1' : '0';
|
$nvh = $this->validatedData['webserver'] == 'apache2' ? '1' : '0';
|
||||||
$stmt->execute([
|
if (!empty($this->validatedData['serveripv6'])) {
|
||||||
'nvh' => $nvh,
|
$stmt->execute([
|
||||||
'serverip' => $this->validatedData['serverip'],
|
'nvh' => $nvh,
|
||||||
'serverport' => 80,
|
'serverip' => $this->validatedData['serveripv6'],
|
||||||
'ssl' => 0
|
'serverport' => 80,
|
||||||
]);
|
'ssl' => 0
|
||||||
$defaultip = $db_user->lastInsertId();
|
]);
|
||||||
|
$defaultip = $db_user->lastInsertId();
|
||||||
|
}
|
||||||
|
if (!empty($this->validatedData['serveripv4'])) {
|
||||||
|
$stmt->execute([
|
||||||
|
'nvh' => $nvh,
|
||||||
|
'serverip' => $this->validatedData['serveripv4'],
|
||||||
|
'serverport' => 80,
|
||||||
|
'ssl' => 0
|
||||||
|
]);
|
||||||
|
$lastinsert = $db_user->lastInsertId();
|
||||||
|
$defaultip = $defaultip != false ? $defaultip . ',' . $lastinsert : $lastinsert;
|
||||||
|
}
|
||||||
|
|
||||||
$defaultsslip = false;
|
$defaultsslip = false;
|
||||||
if ($this->validatedData['use_ssl']) {
|
if ($this->validatedData['use_ssl']) {
|
||||||
$stmt->execute([
|
if (!empty($this->validatedData['serveripv6'])) {
|
||||||
'nvh' => $this->validatedData['webserver'] == 'apache2' ? '1' : '0',
|
$stmt->execute([
|
||||||
'serverip' => $this->validatedData['serverip'],
|
'nvh' => $this->validatedData['webserver'] == 'apache2' ? '1' : '0',
|
||||||
'serverport' => 443,
|
'serverip' => $this->validatedData['serveripv6'],
|
||||||
'ssl' => 1
|
'serverport' => 443,
|
||||||
]);
|
'ssl' => 1
|
||||||
$defaultsslip = $db_user->lastInsertId();
|
]);
|
||||||
|
$defaultsslip = $db_user->lastInsertId();
|
||||||
|
}
|
||||||
|
if (!empty($this->validatedData['serveripv4'])) {
|
||||||
|
$stmt->execute([
|
||||||
|
'nvh' => $this->validatedData['webserver'] == 'apache2' ? '1' : '0',
|
||||||
|
'serverip' => $this->validatedData['serveripv4'],
|
||||||
|
'serverport' => 443,
|
||||||
|
'ssl' => 1
|
||||||
|
]);
|
||||||
|
$lastinsert = $db_user->lastInsertId();
|
||||||
|
$defaultsslip = $defaultsslip != false ? $defaultsslip . ',' . $lastinsert : $lastinsert;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert the defaultip
|
// insert the defaultip
|
||||||
|
|||||||
@@ -2493,7 +2493,7 @@ Yours sincerely, your administrator',
|
|||||||
'ipv6' => 'Primary IPv6 address (if applicable)',
|
'ipv6' => 'Primary IPv6 address (if applicable)',
|
||||||
'servername' => 'Server name (FQDN, no ip-address)',
|
'servername' => 'Server name (FQDN, no ip-address)',
|
||||||
'phpbackend' => 'PHP backend',
|
'phpbackend' => 'PHP backend',
|
||||||
'activate_newsfeed' => 'Enable the official newsfeed<br><small>(https://inside.froxlor.org/news/)</small>',
|
'activate_newsfeed' => 'Enable the official newsfeed<br><small>(external source: https://inside.froxlor.org/news/)</small>',
|
||||||
],
|
],
|
||||||
'install' => [
|
'install' => [
|
||||||
'top' => 'Finish setup',
|
'top' => 'Finish setup',
|
||||||
@@ -2509,6 +2509,7 @@ Yours sincerely, your administrator',
|
|||||||
'unabletocreateuser' => 'Test user could not be created',
|
'unabletocreateuser' => 'Test user could not be created',
|
||||||
'unabletodropuser' => 'Test user could not be dropped',
|
'unabletodropuser' => 'Test user could not be dropped',
|
||||||
'unabletoflushprivs' => 'Given privileged user is unable to flush privileges',
|
'unabletoflushprivs' => 'Given privileged user is unable to flush privileges',
|
||||||
|
'nov4andnov6ip' => 'Either IPv4- or IPv6-address must be given',
|
||||||
'servernameneedstobevalid' => 'Given servername does not seem to be a FQDN or hostname',
|
'servernameneedstobevalid' => 'Given servername does not seem to be a FQDN or hostname',
|
||||||
'websrvuserdoesnotexist' => 'Given webserver-user does not seem to exist on the system',
|
'websrvuserdoesnotexist' => 'Given webserver-user does not seem to exist on the system',
|
||||||
'websrvgrpdoesnotexist' => 'Given webserver-group does not seem to exist on the system',
|
'websrvgrpdoesnotexist' => 'Given webserver-group does not seem to exist on the system',
|
||||||
|
|||||||
Reference in New Issue
Block a user