Commit d90e3a5e authored by Franco Fichtner's avatar Franco Fichtner

inc: tmp_path removal in smaller files

parent 7fd322f1
......@@ -1229,7 +1229,7 @@ function get_interface_info($ifdescr) {
$usbmodemoutput = array();
exec("usbconfig", $usbmodemoutput);
$mondev = "{$g['tmp_path']}/3gstats.{$ifdescr}";
$mondev = "/tmp/3gstats.{$ifdescr}";
if(file_exists($mondev)) {
$cellstats = file($mondev);
/* skip header */
......@@ -1753,7 +1753,7 @@ function update_alias_names_upon_change($section, $field, $new_alias_name, $orig
return;
}
if($debug) $fd = fopen("{$g['tmp_path']}/print_r", "a");
if($debug) $fd = fopen('/tmp/print_r', 'a');
if($debug) fwrite($fd, print_r($pconfig, true));
if(is_array($sectionref)) {
......@@ -1797,7 +1797,7 @@ function update_alias_url_data() {
$isfirst = 0;
foreach ($alias['aliasurl'] as $alias_url) {
/* fetch down and add in */
$temp_filename = tempnam("{$g['tmp_path']}/", "alias_import");
$temp_filename = tempnam('/tmp/', 'alias_import');
unlink($temp_filename);
$verify_ssl = isset($config['system']['checkaliasesurlcert']);
mkdir($temp_filename);
......
<?php
/*
Copyright (C) 2008 Ermal Luçi
All rights reserved.
......@@ -23,13 +24,8 @@
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
pfSense_BUILDER_BINARIES: /bin/kill /sbin/kldload /bin/rm /bin/ps
pfSense_MODULE: shaper
*/
/* XXX: needs some reducing on include. */
/* include all configuration functions. */
require_once("globals.inc");
require_once("functions.inc");
require_once("util.inc");
......@@ -4106,7 +4102,7 @@ function generate_layer7_files() {
if (!is_module_loaded("ipdivert.ko"))
mwexec("/sbin/kldload ipdivert.ko");
array_map('unlink', glob("{$g['tmp_path']}/*.l7"));
array_map('unlink', glob('/tmp/*.l7'));
}
update_layer7_custom_patterns();
......@@ -4114,7 +4110,7 @@ function generate_layer7_files() {
foreach($layer7_rules_list as $l7rules) {
if($l7rules->GetREnabled()) {
$filename = $l7rules->GetRName() . ".l7";
$path = "{$g['tmp_path']}/" . $filename;
$path = '/tmp/' . $filename;
$rules = $l7rules->build_l7_rules();
......@@ -4136,7 +4132,7 @@ function layer7_start_l7daemon() {
foreach($layer7_rules_list as $l7rules) {
if($l7rules->GetREnabled()) {
$filename = $l7rules->GetRName() . ".l7";
$path = "{$g['tmp_path']}/" . $filename;
$path = '/tmp/' . $filename;
unset($l7pid);
/* Only reread the configuration rather than restart to avoid losing information. */
......@@ -4484,8 +4480,8 @@ return;
"net.inet.ip.dummynet.hash_size" => "256"
));
}
file_put_contents("{$g['tmp_path']}/rules.limiter", $dn_rules);
mwexec("/sbin/ipfw {$g['tmp_path']}/rules.limiter");
file_put_contents('/tmp/rules.limiter', $dn_rules);
mwexec('/sbin/ipfw /tmp/rules.limiter');
}
}
......
......@@ -499,41 +499,52 @@ function cleanup_lb_anchor($anchorname = "*") {
}
/* Mark an anchor for later cleanup. This will allow us to remove an old VS name */
function cleanup_lb_mark_anchor($name) {
global $g;
function cleanup_lb_mark_anchor($name)
{
/* Nothing to do! */
if (empty($name))
if (empty($name)) {
return;
$filename = "{$g['tmp_path']}/relayd_anchors_remove";
}
$filename = '/tmp/relayd_anchors_remove';
$cleanup_anchors = array();
/* Read in any currently unapplied name changes */
if (file_exists($filename))
if (file_exists($filename)) {
$cleanup_anchors = explode("\n", file_get_contents($filename));
}
/* Only add the anchor to the list if it's not already there. */
if (!in_array($name, $cleanup_anchors))
if (!in_array($name, $cleanup_anchors)) {
$cleanup_anchors[] = $name;
}
file_put_contents($filename, implode("\n", $cleanup_anchors));
}
/* Cleanup relayd anchors that have been marked for cleanup. */
function cleanup_lb_marked() {
global $g, $config;
$filename = "{$g['tmp_path']}/relayd_anchors_remove";
function cleanup_lb_marked()
{
global $config;
$filename = '/tmp/relayd_anchors_remove';
$cleanup_anchors = array();
/* Nothing to do! */
if (!file_exists($filename)) {
return;
} else {
$cleanup_anchors = explode("\n", file_get_contents($filename));
/* Nothing to do! */
if (empty($cleanup_anchors))
if (empty($cleanup_anchors)) {
return;
}
}
/* Load current names so we can make sure we don't remove an anchor that is still in use. */
$vs_a = $config['load_balancer']['virtual_server'];
$active_vsnames = array();
if(is_array($vs_a)) {
if (isset($vs_a)) {
foreach ($vs_a as $vs) {
$active_vsnames[] = $vs['name'];
}
......@@ -545,7 +556,6 @@ function cleanup_lb_marked() {
cleanup_lb_anchor($anchor);
}
}
unlink_if_exists($filename);
}
?>
<?php
/* $Id$ */
/*
xmlparse_attr.inc
functions to parse configuration files in XML format with attributes
Copyright (C) 2010 Erik Fonnesbeck
All rights reserved.
Based on xmlparse.inc, originally part of m0n0wall (http://m0n0.ch/wall)
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
All rights reserved.
......@@ -129,7 +124,7 @@ function cData_attr($parser, $data) {
function parse_xml_regdomain(&$rdattributes, $rdfile = '', $rootobj = 'regulatory-data')
{
global $g, $listtags;
global $listtags;
if (empty($rdfile)) {
$rdfile = '/etc/regdomain.xml';
......@@ -138,8 +133,8 @@ function parse_xml_regdomain(&$rdattributes, $rdfile = '', $rootobj = 'regulator
$listtags = listtags_rd();
$parsed_xml = array();
if (file_exists($g['tmp_path'] . '/regdomain.cache')) {
$parsed_xml = unserialize(file_get_contents($g['tmp_path'] . '/regdomain.cache'));
if (file_exists('/tmp/regdomain.cache')) {
$parsed_xml = unserialize(file_get_contents('/tmp/regdomain.cache'));
if (!empty($parsed_xml)) {
$rdmain = $parsed_xml['main'];
$rdattributes = $parsed_xml['attributes'];
......@@ -161,7 +156,7 @@ function parse_xml_regdomain(&$rdattributes, $rdfile = '', $rootobj = 'regulator
unset($rdattributes['shared-frequency-bands']);
$parsed_xml = array('main' => $rdmain, 'attributes' => $rdattributes);
$rdcache = fopen($g['tmp_path'] . '/regdomain.cache', "w");
$rdcache = fopen('/tmp/regdomain.cache', 'w');
fwrite($rdcache, serialize($parsed_xml));
fclose($rdcache);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment