mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply fixes from StyleCI (#12117)
* Apply fixes from StyleCI * Disable style check
This commit is contained in:
@@ -47,12 +47,12 @@ class User extends BaseValidation
|
||||
$lnms_username = \config('librenms.user');
|
||||
$lnms_groupname = \config('librenms.group');
|
||||
|
||||
if (!($username === 'root' || $username === $lnms_username)) {
|
||||
if (! ($username === 'root' || $username === $lnms_username)) {
|
||||
if (isCli()) {
|
||||
$validator->fail("You need to run this script as $lnms_username or root");
|
||||
} elseif (function_exists('posix_getgrnam')) {
|
||||
$lnms_group = posix_getgrnam($lnms_groupname);
|
||||
if (!in_array($username, $lnms_group['members'])) {
|
||||
if (! in_array($username, $lnms_group['members'])) {
|
||||
$validator->fail(
|
||||
"Your web server or php-fpm is not running as user '$lnms_username' or in the group '$lnms_groupname''",
|
||||
"usermod -a -G $lnms_groupname $username"
|
||||
@@ -66,8 +66,8 @@ class User extends BaseValidation
|
||||
return;
|
||||
}
|
||||
|
||||
# if no git, then we probably have different permissions by design
|
||||
if (!Git::repoPresent()) {
|
||||
// if no git, then we probably have different permissions by design
|
||||
if (! Git::repoPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ class User extends BaseValidation
|
||||
];
|
||||
|
||||
$find_result = rtrim(`find $dir \! -user $lnms_username -o \! -group $lnms_groupname 2> /dev/null`);
|
||||
if (!empty($find_result)) {
|
||||
if (! empty($find_result)) {
|
||||
// Ignore files created by the webserver
|
||||
$ignore_files = array(
|
||||
$ignore_files = [
|
||||
"$log_dir/error_log",
|
||||
"$log_dir/access_log",
|
||||
"$dir/bootstrap/cache/",
|
||||
@@ -96,7 +96,7 @@ class User extends BaseValidation
|
||||
"$dir/storage/framework/views/",
|
||||
"$dir/storage/debugbar/",
|
||||
"$dir/.pki/", // ignore files/folders created by setting the librenms home directory to the install directory
|
||||
);
|
||||
];
|
||||
|
||||
$files = array_filter(explode(PHP_EOL, $find_result), function ($file) use ($ignore_files) {
|
||||
if (Str::startsWith($file, $ignore_files)) {
|
||||
@@ -106,7 +106,7 @@ class User extends BaseValidation
|
||||
return true;
|
||||
});
|
||||
|
||||
if (!empty($files)) {
|
||||
if (! empty($files)) {
|
||||
$result = ValidationResult::fail(
|
||||
"We have found some files that are owned by a different user than $lnms_username, this " .
|
||||
'will stop you updating automatically and / or rrd files being updated causing graphs to fail.'
|
||||
@@ -115,6 +115,7 @@ class User extends BaseValidation
|
||||
->setList('Files', $files);
|
||||
|
||||
$validator->result($result);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user