Shorten gwifip if whole socket path exceeds 100 chars

dpinger stopps with an error when the socketname exceeds over
(around) 100 characters. The dpinger will not start and not deliver
monitoring results to the WebUI.

These long socket names can get created when using link-local addresses
and long gateway names / interface scopes.

See Ticket 6505
This commit is contained in:
Daniel Hoffend 2016-06-29 01:21:39 +02:00 committed by Chris Buechler
parent dca9eafb0e
commit 69eca02c01

View File

@ -128,10 +128,16 @@ function start_dpinger($gateway) {
$dpinger_defaults = return_dpinger_defaults();
$pidfile = "{$g['varrun_path']}/dpinger_{$gateway['name']}~" .
"{$gateway['gwifip']}~{$gateway['monitor']}.pid";
$socket = "{$g['varrun_path']}/dpinger_{$gateway['name']}~" .
"{$gateway['gwifip']}~{$gateway['monitor']}.sock";
$prefix = "{$g['varrun_path']}/dpinger_{$gateway['name']}~" .
"{$gateway['gwifip']}~{$gateway['monitor']}";
# dpinger socket path should not be longer then uaddr.sun_path
if (strlen($pidfile) > 95) {
$prefix = "{$g['varrun_path']}/dpinger_{$gateway['name']}~" .
substr(md5($gateway['gwifip']),0,8) . "~" .
$gateway['monitor'];
}
$pidfile = $prefix . ".pid";
$socket = $prefix . ".sock";
$alarm_cmd = "{$g['etc_path']}/rc.gateway_alarm";
$params = "-S "; /* Log warnings via syslog */