validate username for webserver/fcgid/php-fpm in global settings to ensure it exists and is not a froxlor-managed user, fixes #1332
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -177,6 +177,10 @@ return [
|
||||
'type' => 'text',
|
||||
'default' => 'froxlorlocal',
|
||||
'string_emptyallowed' => false,
|
||||
'plausibility_check_method' => [
|
||||
'\\Froxlor\\Validate\\Check',
|
||||
'checkSystemUsername'
|
||||
],
|
||||
'save_method' => 'storeSettingWebserverFcgidFpmUser',
|
||||
'websrv_avail' => [
|
||||
'apache2'
|
||||
@@ -246,6 +250,10 @@ return [
|
||||
'type' => 'text',
|
||||
'default' => 'froxlorlocal',
|
||||
'string_emptyallowed' => false,
|
||||
'plausibility_check_method' => [
|
||||
'\\Froxlor\\Validate\\Check',
|
||||
'checkSystemUsername'
|
||||
],
|
||||
'save_method' => 'storeSettingWebserverFcgidFpmUser',
|
||||
'visible' => Settings::Get('phpfpm.enabled') && call_user_func([
|
||||
'\Froxlor\Settings\FroxlorVhostSettings',
|
||||
|
||||
@@ -104,6 +104,10 @@ return [
|
||||
'varname' => 'httpuser',
|
||||
'type' => 'text',
|
||||
'default' => 'www-data',
|
||||
'plausibility_check_method' => [
|
||||
'\\Froxlor\\Validate\\Check',
|
||||
'checkSystemUsername'
|
||||
],
|
||||
'save_method' => 'storeSettingWebserverFcgidFpmUser'
|
||||
],
|
||||
'system_httpgroup' => [
|
||||
|
||||
@@ -359,4 +359,41 @@ class Check
|
||||
|
||||
return [self::FORMFIELDS_PLAUSIBILITY_CHECK_OK];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fieldname
|
||||
* @param $fielddata
|
||||
* @param $newfieldvalue
|
||||
* @param $allnewfieldvalues
|
||||
* @return array|int[]
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function checkSystemUsername($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
|
||||
{
|
||||
if (empty($newfieldvalue) || $fielddata['value'] == $newfieldvalue) {
|
||||
$returnvalue = [
|
||||
self::FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
];
|
||||
} elseif (function_exists('posix_getpwnam') && posix_getpwnam($newfieldvalue) == false) {
|
||||
$returnvalue = [
|
||||
self::FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
'local_user_invalid'
|
||||
];
|
||||
} else {
|
||||
// user exists, but cannot be one of the froxlor-customers
|
||||
$sel_stmt = Database::prepare("SELECT COUNT(*) as numUsers FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `loginname` = :username");
|
||||
$result = Database::pexecute_first($sel_stmt, [':username' => $newfieldvalue]);
|
||||
if ($result && $result['numUsers'] > 0) {
|
||||
$returnvalue = [
|
||||
self::FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
|
||||
'local_user_isfroxloruser'
|
||||
];
|
||||
} else {
|
||||
$returnvalue = [
|
||||
self::FORMFIELDS_PLAUSIBILITY_CHECK_OK
|
||||
];
|
||||
}
|
||||
}
|
||||
return $returnvalue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -966,6 +966,8 @@ return [
|
||||
'no_wwwcnamae_ifwwwalias' => 'Es kann kein CNAME Eintrag für "www" angelegt werden, da die Domain einen www-Alias aktiviert hat. Ändere diese Einstellung auf "Kein Alias" oder "Wildcard Alias"',
|
||||
'local_group_exists' => 'Die angegebene Gruppe existiert bereits auf dem System',
|
||||
'local_group_invalid' => 'Der angegebene Gruppen-Name ist nicht gültig',
|
||||
'local_user_invalid' => 'Der angegebene Benutzer-Name ist nicht gültig oder existiert nicht',
|
||||
'local_user_isfroxloruser' => 'Der angegebene Benutzer-Name ist ein von froxlor verwalteter Benutzer und kann in diesem Kontext nicht verwendet werden.',
|
||||
'invaliddnsforletsencrypt' => 'Die DNS-Einträge der Domain enthalten keine der gewählten IP Adressen. Let\'s Encrypt Zertifikats-Erstellung ist nicht möglich.',
|
||||
'notallowedphpconfigused' => 'Nutzung einer PHP-Konfiguration welche nicht dem Kunden zugeordnet ist',
|
||||
'pathmustberelative' => 'Der Benutzer hat nicht die benötigten Berechtigungen, um Pfade außerhalb des Kunden-Heimatverzeichnisses anzugeben. Bitte einen relativen Pfad angeben (kein führendes /).',
|
||||
|
||||
@@ -1039,6 +1039,8 @@ return [
|
||||
'no_wwwcnamae_ifwwwalias' => 'Cannot set CNAME record for "www" as domain is set to generate a www-alias. Please change settings to either "No alias" or "Wildcard alias"',
|
||||
'local_group_exists' => 'The given group already exists on the system.',
|
||||
'local_group_invalid' => 'The given group name is invalid',
|
||||
'local_user_invalid' => 'The given user name is invalid or does not exist',
|
||||
'local_user_isfroxloruser' => 'The given user name is a froxlor managed username and cannot be used in this context',
|
||||
'invaliddnsforletsencrypt' => 'The domains DNS does not include any of the chosen IP addresses. Let\'s Encrypt certificate generation not possible.',
|
||||
'notallowedphpconfigused' => 'Trying to use php-config which is not assigned to customer',
|
||||
'pathmustberelative' => 'The user does not have the permission to specify directories outside the customers home-directory. Please specify a relative path (no leading /).',
|
||||
|
||||
Reference in New Issue
Block a user