diff --git a/emhttp/login.php b/emhttp/login.php index 9c6bd96f9..9752dc3f7 100644 --- a/emhttp/login.php +++ b/emhttp/login.php @@ -1,6 +1,7 @@ = $maxFails) { - if ($failCount == $maxFails) exec("logger -t webGUI -- \"Ignoring login attempts for {$username} from {$remote_addr}\""); + if ($failCount == $maxFails) my_logger("Ignoring login attempts for {$username} from {$remote_addr}"); throw new Exception(_('Too many invalid login attempts')); } @@ -216,7 +216,7 @@ if (!empty($username) && !empty($password)) { $_SESSION['unraid_user'] = $username; session_regenerate_id(true); session_write_close(); - exec("logger -t webGUI -- \"Successful login user {$username} from {$remote_addr}\""); + my_logger("Successful login user {$username} from {$remote_addr}"); // Redirect the user to the start page header("Location: /".$start_page); @@ -226,7 +226,7 @@ if (!empty($username) && !empty($password)) { $error = $exception->getMessage(); // Log error to syslog - exec("logger -t webGUI -- \"Unsuccessful login user {$username} from {$remote_addr}\""); + my_logger("Unsuccessful login user {$username} from {$remote_addr}"); appendToFile($failFile, $time."\n"); } } diff --git a/emhttp/plugins/dynamix/include/.set-password.php b/emhttp/plugins/dynamix/include/.set-password.php index 3e3256f46..628532069 100644 --- a/emhttp/plugins/dynamix/include/.set-password.php +++ b/emhttp/plugins/dynamix/include/.set-password.php @@ -36,7 +36,7 @@ if (!empty($_POST['password']) && !empty($_POST['confirmPassword'])) { } // Error when attempting to set password - exec("logger -t webGUI -- \"{$VALIDATION_MESSAGES['saveError']} [REMOTE_ADDR]: {$REMOTE_ADDR}\""); + my_logger("{$VALIDATION_MESSAGES['saveError']} [REMOTE_ADDR]: {$REMOTE_ADDR}"); return $POST_ERROR = $VALIDATION_MESSAGES['saveError']; } diff --git a/emhttp/plugins/dynamix/include/PageBuilder.php b/emhttp/plugins/dynamix/include/PageBuilder.php index 931d05943..19bdc1fbc 100644 --- a/emhttp/plugins/dynamix/include/PageBuilder.php +++ b/emhttp/plugins/dynamix/include/PageBuilder.php @@ -12,6 +12,7 @@ ?> 'D j M Y h:i A','%A' => 'l','%Y' => 'Y','%B' => 'F','%e' => 'j','%d' => 'd','%m' => 'm','%I' => 'h','%H' => 'H','%M' => 'i','%S' => 's','%p' => 'a','%R' => 'H:i', '%F' => 'Y-m-d', '%T' => 'H:i:s']; return date(strtr($fmt,$legacy), $time); } +// ensure params passed to logger are properly escaped +function my_logger($message, $tag="webgui") { + exec('logger -t '.escapeshellarg($tag).' -- '.escapeshellarg($message)); +} ?> diff --git a/emhttp/plugins/dynamix/include/local_prepend.php b/emhttp/plugins/dynamix/include/local_prepend.php index 0f5458f7a..c683c1b87 100644 --- a/emhttp/plugins/dynamix/include/local_prepend.php +++ b/emhttp/plugins/dynamix/include/local_prepend.php @@ -15,7 +15,7 @@ // auto_prepend_file="/usr/local/emhttp/webGui/include/local_prepend.php" function csrf_terminate($reason) { - exec("logger -t webGUI -- \"error: {$_SERVER['REQUEST_URI']} - {$reason} csrf_token\""); + exec('logger -t webGUI -- '.escapeshellarg("error: {$_SERVER['REQUEST_URI']} - {$reason} csrf_token")); exit; } diff --git a/emhttp/plugins/dynamix/include/publish.php b/emhttp/plugins/dynamix/include/publish.php index f4340dc4f..66d42ac9e 100644 --- a/emhttp/plugins/dynamix/include/publish.php +++ b/emhttp/plugins/dynamix/include/publish.php @@ -11,13 +11,16 @@ */ ?> $socket, CURLOPT_RETURNTRANSFER => 1]); if ($message) curl_setopt_array($com, [CURLOPT_POSTFIELDS => $message, CURLOPT_POST => 1]); $reply = curl_exec($com); curl_close($com); - if ($reply===false) exec("logger -t curl_socket -- 'curl to $url failed'"); + if ($reply===false) my_logger("curl to $url failed", 'curl_socket'); return $reply; } @@ -32,7 +35,7 @@ function publish($endpoint, $message, $len=1) { ]); $reply = curl_exec($com); curl_close($com); - if ($reply===false) exec("logger -t publish -- 'curl to $endpoint failed'"); + if ($reply===false) my_logger("curl to $endpoint failed", 'publish'); return $reply; } ?> diff --git a/emhttp/plugins/dynamix/scripts/netconfig b/emhttp/plugins/dynamix/scripts/netconfig index 0621a9c97..8dcca64df 100755 --- a/emhttp/plugins/dynamix/scripts/netconfig +++ b/emhttp/plugins/dynamix/scripts/netconfig @@ -12,6 +12,9 @@ */ ?>