summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/util.inc
diff options
context:
space:
mode:
Diffstat (limited to 'src/etc/inc/util.inc')
-rw-r--r--src/etc/inc/util.inc39
1 files changed, 13 insertions, 26 deletions
diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc
index e9cb7cb..4f13187 100644
--- a/src/etc/inc/util.inc
+++ b/src/etc/inc/util.inc
@@ -55,12 +55,6 @@
* ====================================================================
*
*/
-/*
- pfSense_BUILDER_BINARIES: /bin/ps /bin/kill /usr/bin/killall /sbin/ifconfig /usr/bin/netstat
- pfSense_BUILDER_BINARIES: /usr/bin/awk /sbin/dmesg /sbin/ping /usr/local/sbin/gzsig /usr/sbin/arp
- pfSense_BUILDER_BINARIES: /sbin/conscontrol /sbin/devd /bin/ps
- pfSense_MODULE: utils
-*/
/* kill a process by pid file */
function killbypid($pidfile) {
@@ -1046,21 +1040,24 @@ function get_configured_carp_interface_list($carpinterface = '', $family = 'inet
$iflist = array();
- if (!is_array($config['virtualip']['vip']) || empty($config['virtualip']['vip']))
+ if (!is_array($config['virtualip']['vip']) || empty($config['virtualip']['vip'])) {
return $iflist;
+ }
$viparr = &$config['virtualip']['vip'];
foreach ($viparr as $vip) {
- if ($vip['mode'] != "carp")
+ if ($vip['mode'] != "carp") {
continue;
+ }
if (empty($carpinterface)) {
$iflist["_vip{$vip['uniqid']}"] = $vip['subnet'];
continue;
}
- if ($carpinterface != "_vip{$vip['uniqid']}")
+ if ($carpinterface != "_vip{$vip['uniqid']}") {
continue;
+ }
switch ($what) {
case 'subnet':
@@ -1483,8 +1480,9 @@ function mwexec($command, $nologentry = false, $clearsigmask = false, $backgroun
// run in foreground, and (optionally) log if nonzero return
$outputarray = array();
exec("$command 2>&1", $outputarray, $retval);
- if (($retval <> 0) && (!$nologentry || isset($config['system']['developerspew'])))
+ if (($retval <> 0) && (!$nologentry || isset($config['system']['developerspew']))) {
log_error(sprintf(gettext("The command '%1\$s' returned exit code '%2\$d', the output was '%3\$s' "), $command, $retval, implode(" ", $outputarray)));
+ }
}
if ($clearsigmask) {
@@ -1499,13 +1497,13 @@ function mwexec_bg($command, $clearsigmask = false) {
return mwexec($command, false, $clearsigmask, true);
}
-/* unlink a file, if it exists */
+/* unlink a file, or pattern-match of a file, if it exists
+ if the file/path contains glob() compatible wildcards, all matching files will be unlinked
+ if no matches, no error occurs */
function unlink_if_exists($fn) {
$to_do = glob($fn);
- if (is_array($to_do)) {
- foreach ($to_do as $filename) {
- @unlink($filename);
- }
+ if (is_array($to_do) && count($to_do) > 0) {
+ array_map("unlink", $to_do);
} else {
@unlink($fn);
}
@@ -1583,17 +1581,6 @@ function alias_expand_urltable($name) {
return null;
}
-/* verify (and remove) the digital signature on a file - returns 0 if OK */
-function verify_digital_signature($fname) {
- global $g;
-
- if (!file_exists("/usr/local/sbin/gzsig")) {
- return 4;
- }
-
- return mwexec("/usr/local/sbin/gzsig verify {$g['etc_path']}/pubkey.pem < " . escapeshellarg($fname));
-}
-
/* obtain MAC address given an IP address by looking at the ARP table */
function arp_get_mac_by_ip($ip) {
mwexec("/sbin/ping -c 1 -t 1 " . escapeshellarg($ip), true);
OpenPOWER on IntegriCloud