mirror of
https://github.com/unraid/webgui.git
synced 2026-01-06 01:29:54 -06:00
Updated logger function to escape message part
This commit is contained in:
@@ -368,7 +368,7 @@ class DockerTemplates {
|
||||
@copy($iconRAM,$icon);
|
||||
}
|
||||
if ( !is_file($iconRAM) ) {
|
||||
exec("/usr/bin/logger ".escapeshellarg("$imageName: Could not download icon $imgUrl"));
|
||||
exec("/usr/bin/logger -- ".escapeshellarg("$imageName: Could not download icon $imgUrl"));
|
||||
}
|
||||
|
||||
return (is_file($iconRAM)) ? str_replace($docroot, '', $iconRAM) : '';
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
# missing qemu directory would indicate new libvirt image file created
|
||||
if [ ! -d /etc/libvirt/qemu ]; then
|
||||
logger "initializing /etc/libvirt"
|
||||
logger -- "initializing /etc/libvirt"
|
||||
# initialize with default settings
|
||||
cp -rp /etc/libvirt-/* /etc/libvirt
|
||||
# check if libvirt image file exists on USB flash
|
||||
|
||||
@@ -139,7 +139,7 @@ $dnsserver = _var($$ethX,'DNS_SERVER1');
|
||||
|
||||
$link = iflink($ethX);
|
||||
$postUp0 = "$script add $link WireGuard-<wg> $server <port> <port> udp";
|
||||
$postUp1 = "logger -t wireguard 'Tunnel WireGuard-<wg> started';$services";
|
||||
$postUp1 = "logger -t wireguard -- \"Tunnel WireGuard-<wg> started\";$services";
|
||||
$postUp2 = "iptables -t nat -A POSTROUTING -s <source> -o $link -j MASQUERADE";
|
||||
$postUp3 = "iptables -N WIREGUARD_DROP_<WG>;iptables -A WIREGUARD -o $link -j WIREGUARD_DROP_<WG>";
|
||||
$postUpX = "iptables -A WIREGUARD_DROP_<WG> -s <source> -d <target> -j DROP";
|
||||
@@ -149,7 +149,7 @@ $postUp36 = "ip6tables -N WIREGUARD_DROP_<WG>;ip6tables -A WIREGUARD -o $link -
|
||||
$postUpX6 = "ip6tables -A WIREGUARD_DROP_<WG> -s <source> -d <target> -j DROP";
|
||||
$postUpZ6 = "ip6tables -A WIREGUARD_DROP_<WG> -s <source> -j ACCEPT;ip6tables -A WIREGUARD_DROP_<WG> -j RETURN";
|
||||
$postDown0 = "$script del $link <port> udp";
|
||||
$postDown1 = "logger -t wireguard 'Tunnel WireGuard-<wg> stopped';$services";
|
||||
$postDown1 = "logger -t wireguard -- \"Tunnel WireGuard-<wg> stopped\";$services";
|
||||
$postDown2 = "iptables -t nat -D POSTROUTING -s <source> -o $link -j MASQUERADE";
|
||||
$postDown3 = "iptables -F WIREGUARD_DROP_<WG>;iptables -D WIREGUARD -o $link -j WIREGUARD_DROP_<WG>;iptables -X WIREGUARD_DROP_<WG>";
|
||||
$postDown26= "ip6tables -t nat -D POSTROUTING -s <source> -o $link -j MASQUERADE";
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
/usr/bin/logger "Submitting SysDrivers Build"
|
||||
/usr/bin/logger -- "Submitting SysDrivers Build"
|
||||
/usr/local/emhttp/plugins/dynamix/include/SysDriversInit.php &> /dev/null &
|
||||
@@ -119,12 +119,12 @@ function verifyTwoFactorToken(string $username, string $token): bool {
|
||||
// This should accept 200 or 204 status codes
|
||||
if ($httpCode !== 200 && $httpCode !== 204) {
|
||||
// Log error to syslog
|
||||
exec("logger -t webGUI ".escapeshellarg("2FA code for {$username} is invalid, blocking access!"));
|
||||
exec("logger -t webGUI -- ".escapeshellarg("2FA code for {$username} is invalid, blocking access!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Log success to syslog
|
||||
exec("logger -t webGUI ".escapeshellarg("2FA code for {$username} is valid, allowing login!"));
|
||||
exec("logger -t webGUI -- ".escapeshellarg("2FA code for {$username} is valid, allowing login!"));
|
||||
|
||||
// Success
|
||||
return true;
|
||||
@@ -199,7 +199,7 @@ if (!empty($username) && !empty($password)) {
|
||||
|
||||
// Check if we're limited
|
||||
if ($failCount >= $maxFails) {
|
||||
if ($failCount == $maxFails) exec("logger -t webGUI ".escapeshellarg("Ignoring login attempts for {$username} from {$remote_addr}"));
|
||||
if ($failCount == $maxFails) exec("logger -t webGUI -- ".escapeshellarg("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 ".escapeshellarg("Successful login user {$username} from {$remote_addr}"));
|
||||
exec("logger -t webGUI -- ".escapeshellarg("Successful login user {$username} from {$remote_addr}"));
|
||||
|
||||
// Redirect the user to the start page
|
||||
header("Location: /".$var['START_PAGE']);
|
||||
@@ -226,7 +226,7 @@ if (!empty($username) && !empty($password)) {
|
||||
$error = $exception->getMessage();
|
||||
|
||||
// Log error to syslog
|
||||
exec("logger -t webGUI ".escapeshellarg("Unsuccessful login user {$username} from {$remote_addr}"));
|
||||
exec("logger -t webGUI -- ".escapeshellarg("Unsuccessful login user {$username} from {$remote_addr}"));
|
||||
appendToFile($failFile, $time."\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ if (!empty($_POST['password']) && !empty($_POST['confirmPassword'])) {
|
||||
}
|
||||
|
||||
// Error when attempting to set password
|
||||
exec("logger -t webGUI ".escapeshellarg($VALIDATION_MESSAGES['saveError'] . " [REMOTE_ADDR]: {$REMOTE_ADDR}"));
|
||||
exec("logger -t webGUI -- ".escapeshellarg($VALIDATION_MESSAGES['saveError'] . " [REMOTE_ADDR]: {$REMOTE_ADDR}"));
|
||||
return $POST_ERROR = $VALIDATION_MESSAGES['saveError'];
|
||||
}
|
||||
|
||||
|
||||
@@ -215,9 +215,9 @@ EOF
|
||||
echo "${RET}"
|
||||
} >>"${LOG}"
|
||||
# if there was an error with the submission, log details and exit loop
|
||||
[[ "${RET}" != *"retry_after"* ]] && echo "${DATA}" >>"${LOG}" && logger -t "${SCRIPTNAME}" "Failed sending notification" && break
|
||||
[[ "${RET}" != *"retry_after"* ]] && echo "${DATA}" >>"${LOG}" && logger -t "${SCRIPTNAME}" -- "Failed sending notification" && break
|
||||
# if retries exhausted, log failure
|
||||
[[ "${i}" -eq "${MAX}" ]] && echo "${DATA}" >>"${LOG}" && logger -t "${SCRIPTNAME}" "Failed sending notification - rate limited" && break
|
||||
[[ "${i}" -eq "${MAX}" ]] && echo "${DATA}" >>"${LOG}" && logger -t "${SCRIPTNAME}" -- "Failed sending notification - rate limited" && break
|
||||
# we were rate limited, try again after a delay
|
||||
sleep 1
|
||||
done
|
||||
|
||||
@@ -32,7 +32,7 @@ function build_pages($pattern) {
|
||||
foreach (glob($pattern,GLOB_NOSORT) as $entry) {
|
||||
[$header, $content] = my_explode("\n---\n",file_get_contents($entry));
|
||||
$page = @parse_ini_string($header);
|
||||
if (!$page) {exec("logger -t 'webGUI' Invalid .page format: $entry"); continue;}
|
||||
if (!$page) {exec("logger -t webGUI -- \"Invalid .page format: $entry\""); continue;}
|
||||
$page['file'] = $entry;
|
||||
$page['root'] = dirname($entry);
|
||||
$page['name'] = basename($entry, '.page');
|
||||
|
||||
@@ -6,11 +6,10 @@ function SysDriverslog($m, $type = "NOTICE") {
|
||||
$m = print_r($m,true);
|
||||
$m = str_replace("\n", " ", $m);
|
||||
$m = str_replace('"', "'", $m);
|
||||
$cmd = "/usr/bin/logger ".'"'.$m.'"'." -tSysDrivers";
|
||||
$cmd = "/usr/bin/logger -t SysDrivers -- \"$m\"";
|
||||
exec($cmd);
|
||||
}
|
||||
|
||||
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
// add translations
|
||||
require_once "$docroot/webGui/include/Translations.php";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2020, Lime Technology
|
||||
/* Copyright 2005-2023, Lime Technology
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
@@ -15,7 +15,7 @@
|
||||
* auto_prepend_file="/usr/local/emhttp/webGui/include/local_prepend.php"
|
||||
*/
|
||||
function csrf_terminate($reason) {
|
||||
shell_exec("logger error: " . escapeshellarg($_SERVER['REQUEST_URI']) . ": $reason csrf_token");
|
||||
shell_exec("logger -- ".escapeshellarg("error: ".$_SERVER['REQUEST_URI']).": $reason csrf_token");
|
||||
exit;
|
||||
}
|
||||
putenv('PATH=.:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin');
|
||||
|
||||
@@ -25,7 +25,7 @@ function update_wireguard($ifname) {
|
||||
$vtun = basename($wg,'.conf');
|
||||
// interface has changed?
|
||||
if (exec("grep -Pom1 ' dev $nic ' $wg")=='') {
|
||||
exec("logger -t netconfig 'updated wireguard $vtun configuration'");
|
||||
exec("logger -t netconfig -- \"updated wireguard $vtun configuration\"");
|
||||
exec("sed -ri 's/ dev (br0|bond0|eth0) / dev $nic /' $wg");
|
||||
}
|
||||
// restart active wireguard tunnels
|
||||
|
||||
@@ -6,7 +6,7 @@ if [[ -n $1 ]]; then
|
||||
fi
|
||||
for cmd in $SERVICES; do
|
||||
if /etc/rc.d/rc.$cmd update; then
|
||||
logger -t network "reload service: $cmd"
|
||||
logger -t network -- "reload service: $cmd"
|
||||
/etc/rc.d/rc.$cmd reload >/dev/null 2>&1
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
lock=/tmp/atlock.tmp
|
||||
|
||||
logger -t network "update services: ${1:-1}s"
|
||||
logger -t network -- "update services: ${1:-1}s"
|
||||
rm -f $lock
|
||||
echo "sleep ${1:-1};/usr/local/emhttp/webGui/scripts/reload_services $lock"|at -M now 2>/dev/null
|
||||
exit 0
|
||||
|
||||
@@ -34,7 +34,7 @@ while :; do
|
||||
IP=$(ip -4 addr show dev $LINK|grep -Pom1 'inet \K.[^/]+')
|
||||
PORT=$(wg show $WG listen-port)
|
||||
upnpc -u $XML -m $LINK -e "WireGuard-$WG" -a $IP $PORT $PORT udp >/dev/null 2>&1
|
||||
[[ $? -eq 0 ]] && logger -t upnpc "Added port $PORT/udp" || logger -t upnpc "Failed to add port $PORT/udp"
|
||||
[[ $? -eq 0 ]] && logger -t upnpc -- "Added port $PORT/udp" || logger -t upnpc -- "Failed to add port $PORT/udp"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -38,18 +38,18 @@ add)
|
||||
upnpc -u $XML -m $LINK -e $3 -a $4 $5 $6 $7 >/dev/null 2>&1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
[[ -n $WG ]] && at -M -f ${POLLER}_start now 2>/dev/null
|
||||
logger -t upnpc "Added port $5/$7"
|
||||
logger -t upnpc -- "Added port $5/$7"
|
||||
else
|
||||
logger -t upnpc "Failed to add port $5/$7"
|
||||
logger -t upnpc -- "Failed to add port $5/$7"
|
||||
fi
|
||||
;;
|
||||
del)
|
||||
upnpc -u $XML -m $LINK -d $3 $4 >/dev/null 2>&1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
[[ -z $WG && -n $(pgrep -f $POLLER) ]] && pkill -f $POLLER
|
||||
logger -t upnpc "Deleted port $3/$4"
|
||||
logger -t upnpc -- "Deleted port $3/$4"
|
||||
else
|
||||
logger -t upnpc "Failed to delete port $3/$4"
|
||||
logger -t upnpc -- "Failed to delete port $3/$4"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user