From 594315618f95e2d48feae67b17ace8d2a0bc6845 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 5 Mar 2015 15:51:29 +0100 Subject: [PATCH] inc/ipsec: proper softcoding for tmp_path This allows us to grep for the file name as "name.something.xml" and still be able to find the variable or path or binary or so, while the actual file name is only set once avoiding typos in the process as well... --- src/etc/inc/ipsec.inc | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/etc/inc/ipsec.inc b/src/etc/inc/ipsec.inc index 902d8faed..89c40df24 100644 --- a/src/etc/inc/ipsec.inc +++ b/src/etc/inc/ipsec.inc @@ -1,12 +1,10 @@ {$g['tmp_path']}/strongswan_leases.xml"); + $strongswan_leases_xml = '/tmp/strongswan_leases.xml'; - if (!file_exists("{$g['tmp_path']}/strongswan_leases.xml")) { + $_gb = exec(sprintf('/usr/local/sbin/ipsec stroke leases > %s', $strongswan_leases_xml)); + + if (!file_exists($strongswan_leases_xml)) { log_error(gettext("IPsec daemon seems to have issues or not running! Could not display mobile user stats!")); return array(); } $custom_listtags = array('lease', 'pool'); - $response = parse_xml_config("{$g['tmp_path']}/strongswan_leases.xml", "leases"); - @unlink("{$g['tmp_path']}/strongswan_leases.xml"); + $response = parse_xml_config($strongswan_leases_xml, 'leases'); + @unlink($strongswan_leases_xml); unset($custom_listtags, $_gb); return $response;