summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2009-12-28 09:41:47 +0000
committerErmal Luçi <eri@pfsense.org>2009-12-28 09:42:23 +0000
commit6955830f96ee6f3912a89e271eb59e501dfe3514 (patch)
treef1f6cbf3f4e76be76594a04ee0f90a937f49282d /etc
parent39618326e0ddd3d79f2596b6a11d9bc09da6ded0 (diff)
downloadpfsense-6955830f96ee6f3912a89e271eb59e501dfe3514.zip
pfsense-6955830f96ee6f3912a89e271eb59e501dfe3514.tar.gz
Replace some occurrence of /tmp with the propper global variable in attempt to minimize the search for what changes /tmp permissions.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/filter.inc6
-rw-r--r--etc/inc/interfaces.inc24
-rw-r--r--etc/inc/notices.inc8
-rw-r--r--etc/inc/pkg-utils.inc9
-rw-r--r--etc/inc/services.inc4
-rw-r--r--etc/inc/shaper.inc12
-rw-r--r--etc/inc/system.inc30
-rw-r--r--etc/inc/util.inc6
8 files changed, 46 insertions, 53 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc
index 86399d6..f31806a 100644
--- a/etc/inc/filter.inc
+++ b/etc/inc/filter.inc
@@ -303,7 +303,7 @@ function filter_configure_sync() {
if(strstr("$rules_error", "busy")) {
exec("/sbin/pfctl -d");
exec("/sbin/pfctl -e");
- exec("/sbin/pfctl -f /tmp/rules.debug");
+ exec("/sbin/pfctl -f {$g['tmp_path']}/rules.debug");
file_notice("pf_busy", "PF was wedged/busy and has been reset.", "pf_busy", "");
log_error("PF was wedged/busy and has been reset.");
}
@@ -1477,7 +1477,6 @@ function filter_generate_user_rule($rule) {
/* source address */
$src = filter_generate_address($rule, "source");
if(empty($src) || ($src == "/")) {
- file_put_contents('/tmp/rule_src.array', print_r($rule, 1));
return "# at the break!";
}
$aline['src'] = " from $src ";
@@ -1489,9 +1488,6 @@ function filter_generate_user_rule($rule) {
/* destination address */
$dst = filter_generate_address($rule, "destination");
if(empty($dst) || ($dst == "/")) {
- global $FilterIflist;
- file_put_contents('/tmp/rule_dst.array', print_r($rule, 1));
- file_put_contents('/tmp/filterIflist.dmp', print_r($FilterIflist, 1));
return "# returning at dst $dst == \"/\"";
}
$aline['dst'] = "to $dst ";
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index ee048f0..277ac25 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -575,7 +575,7 @@ function interface_gre_configure(&$gre) {
log_error("Could not bring greif up -- variable not defined.");
mwexec("/sbin/route add {$gre['remote-addr']}/{$gre['tunnel-remote-net']} {$realifip}");
- file_put_contents("/tmp/{$greif}_router", $gre['tunnel-remote-addr']);
+ file_put_contents("{$g['tmp_path']}/{$greif}_router", $gre['tunnel-remote-addr']);
return $greif;
}
@@ -629,7 +629,7 @@ function interface_gif_configure(&$gif) {
log_error("could not bring gifif up -- variable not defined");
mwexec("/sbin/route add {$gif['remote-addr']}/{$gif['tunnel-remote-net']} {$realifip}");
- file_put_contents("/tmp/{$gifif}_router", $gif['tunnel-remote-addr']);
+ file_put_contents("{$g['tmp_path']}/{$gifif}_router", $gif['tunnel-remote-addr']);
return $gifif;
}
@@ -783,7 +783,7 @@ function interface_bring_down($interface = "wan", $destroy = false) {
/* remove interface up file if it exists */
unlink_if_exists("{$g['tmp_path']}/{$realif}up");
unlink_if_exists("{$g['vardb_path']}/{$interface}ip");
- unlink_if_exists("/tmp/{$realif}_router");
+ unlink_if_exists("{$g['tmp_path']}/{$realif}_router");
interface_ppp_bring_down($realif);
@@ -1295,16 +1295,12 @@ EOD;
fclose($fd);
/* fire up dhclient */
- mwexec("/sbin/dhclient -c {$g['varetc_path']}/dhclient_{$vipif}.conf {$vipif} >/tmp/{$vipif}_output >/tmp/{$vipif}_error_output", false);
+ mwexec("/sbin/dhclient -c {$g['varetc_path']}/dhclient_{$vipif}.conf {$vipif} > {$g['tmp_path']}/{$vipif}_output > {$g['tmp_path']}/{$vipif}_error_output", false);
} else {
log_error("Error: cannot open dhclient_{$vipif}.conf in interfaces_carpdev_configure() for writing.\n");
mwexec("/sbin/dhclient -b {$vipif}");
}
- $fout = fopen("/tmp/ifconfig_{$vipif}","w");
- fwrite($fout, "/sbin/dhclient -c {$g['varetc_path']}/dhclient_{$vipif}.conf {$vipif}");
- fclose($fout);
-
return $vipif;
}
@@ -1384,7 +1380,7 @@ function interface_wireless_configure($if, &$wl, &$wlcfg) {
// Clone wireless nic if needed.
interface_wireless_clone($if, $wl);
- $fd_set = fopen("/tmp/{$if}_setup.sh","w");
+ $fd_set = fopen("{$g['tmp_path']}/{$if}_setup.sh","w");
fwrite($fd_set, "#!/bin/sh\n");
fwrite($fd_set, "# {$g['product_name']} wireless configuration script.\n\n");
@@ -1607,7 +1603,7 @@ EOD;
sleep(1);
/* execute hostapd and wpa_supplicant if required in shell */
- mwexec("/bin/sh /tmp/{$if}_setup.sh");
+ mwexec("/bin/sh {$g['tmp_path']}/{$if}_setup.sh");
return 0;
@@ -1711,7 +1707,7 @@ function interface_configure($interface = "wan", $reloadall = false) {
}
if (is_ipaddr($wancfg['gateway']))
- file_put_contents("/tmp/{$realif}_router", $wancfg['gateway']);
+ file_put_contents("{$g['tmp_path']}/{$realif}_router", $wancfg['gateway']);
}
if(does_interface_exist($wancfg['if']))
@@ -1847,11 +1843,7 @@ EOD;
log_error("Could not bring realwanif up in interface_dhcp_configure()");
/* fire up dhclient */
- mwexec("/sbin/dhclient -c {$g['varetc_path']}/dhclient_{$interface}.conf {$wanif} >/tmp/{$wanif}_output >/tmp/{$wanif}_error_output");
-
- $fout = fopen("/tmp/ifconfig_{$wanif}","w");
- fwrite($fout, "/sbin/dhclient -c {$g['varetc_path']}/dhclient_{$interface}.conf {$wanif}");
- fclose($fout);
+ mwexec("/sbin/dhclient -c {$g['varetc_path']}/dhclient_{$interface}.conf {$wanif} > {$g['tmp_path']}/{$wanif}_output > {$g['tmp_path']}/{$wanif}_error_output");
return 0;
}
diff --git a/etc/inc/notices.inc b/etc/inc/notices.inc
index 7f2e199..069b281 100644
--- a/etc/inc/notices.inc
+++ b/etc/inc/notices.inc
@@ -99,8 +99,10 @@ function file_notice($id, $notice, $category = "General", $url = "", $priority =
* Returns a specific notices text
******/
function get_notices($category = "all") {
- if(file_exists('/tmp/notices')) {
- $queue = unserialize(file_get_contents('/tmp/notices'));
+ global $g;
+
+ if(file_exists("{$g['tmp_path']}/notices")) {
+ $queue = unserialize(file_get_contents("{$g['tmp_path']}/notices"));
if(!$queue) return false;
if($category != 'all') {
foreach($queue as $time => $notice) {
@@ -357,4 +359,4 @@ function register_via_growl() {
}
}
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc
index 8cabced..47bd7dc 100644
--- a/etc/inc/pkg-utils.inc
+++ b/etc/inc/pkg-utils.inc
@@ -374,7 +374,7 @@ function pkg_fetch_recursive($pkgname, $filename, $dependlevel = 0, $base_url =
global $pkgent, $static_output, $g, $fd_log;
$pkg_extension = strrchr($filename, '.');
$static_output .= "\n" . str_repeat(" ", $dependlevel * 2) . $pkgname . " ";
- $fetchto = "/tmp/apkg_" . $pkgname . $pkg_extension;
+ $fetchto = "{$g['tmp_path']}/apkg_" . $pkgname . $pkg_extension;
download_file_with_progress_bar($base_url . '/' . $filename, $fetchto);
$static_output .= " (extracting)";
update_output_window($static_output);
@@ -777,6 +777,7 @@ function delete_package_recursive($pkg) {
function delete_package_xml($pkg) {
global $g, $config, $fd_log, $static_output, $pkg_interface;
+
if(($pkgid = get_pkg_id($pkg)) == -1) {
$static_output .= "The {$pkg} package is not installed.\n\nDeletion aborted.";
update_output_window($static_output);
@@ -929,12 +930,12 @@ function delete_package_xml($pkg) {
foreach($ctag as $line) {
if(trim($line) != "") $towrite[] = $line;
}
- $tmptab = fopen("/tmp/crontab", "w");
+ $tmptab = fopen("{$g['tmp_path']}/crontab", "w");
foreach($towrite as $line) {
fwrite($tmptab, $line);
}
fclose($tmptab);
- rename("/tmp/crontab", "/etc/crontab");
+ rename("{$g['tmp_path']}/crontab", "/etc/crontab");
}
function expand_to_bytes($size) {
@@ -1002,4 +1003,4 @@ function squash_from_bytes($size, $round = "") {
return;
}
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/services.inc b/etc/inc/services.inc
index 2e54a2a..91f03b1 100644
--- a/etc/inc/services.inc
+++ b/etc/inc/services.inc
@@ -74,7 +74,7 @@ function services_dhcpd_configure() {
$is_olsr_enabled = true;
/* configure DHCPD chroot */
- $fd = fopen("/tmp/dhcpd.sh","w");
+ $fd = fopen("{$g['tmp_path']}/dhcpd.sh","w");
$status = `mount | grep "{$g['dhcpd_chroot_path']}/dev"`;
fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}\n");
fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/dev\n");
@@ -92,7 +92,7 @@ function services_dhcpd_configure() {
if(!trim($status))
fwrite($fd, "mount -t devfs devfs {$g['dhcpd_chroot_path']}/dev\n");
fclose($fd);
- mwexec("/bin/sh /tmp/dhcpd.sh");
+ mwexec("/bin/sh {$g['tmp_path']}/dhcpd.sh");
$syscfg = $config['system'];
$dhcpdcfg = $config['dhcpd'];
diff --git a/etc/inc/shaper.inc b/etc/inc/shaper.inc
index ac492c5..ce314c3 100644
--- a/etc/inc/shaper.inc
+++ b/etc/inc/shaper.inc
@@ -3550,7 +3550,7 @@ function read_layer7_config() {
}
function generate_layer7_files() {
- global $layer7_rules_list;
+ global $layer7_rules_list, $g;
read_layer7_config();
@@ -3558,13 +3558,13 @@ function generate_layer7_files() {
if (!is_module_loaded("ipdivert.ko"))
mwexec("/sbin/kldload ipdivert.ko");
- mwexec("rm -f /tmp/*.l7");
+ mwexec("rm -f {$g['tmp_path']}/*.l7");
}
foreach($layer7_rules_list as $l7rules) {
if($l7rules->GetREnabled()) {
$filename = $l7rules->GetRName() . ".l7";
- $path = "/tmp/" . $filename;
+ $path = "{$g['tmp_path']}/" . $filename;
$rules = $l7rules->build_l7_rules();
@@ -3576,7 +3576,7 @@ function generate_layer7_files() {
}
function layer7_start_l7daemon() {
- global $layer7_rules_list;
+ global $layer7_rules_list, $g;
/*
* XXX: ermal - Needed ?!
@@ -3586,7 +3586,7 @@ function layer7_start_l7daemon() {
foreach($layer7_rules_list as $l7rules) {
if($l7rules->GetREnabled()) {
$filename = $l7rules->GetRName() . ".l7";
- $path = "/tmp/" . $filename;
+ $path = "{$g['tmp_path']}/" . $filename;
unset($l7pid);
/* Only reread the configuration rather than restart to avoid loosing information. */
@@ -3924,4 +3924,4 @@ $dn_default_shaper_msg .= "</td></tr>";
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index f62dfba..3fa8ff3 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -651,12 +651,12 @@ function system_webgui_start() {
$cert = array();
$cert['refid'] = uniqid();
$cert['name'] = "webConfigurator default";
- mwexec("/usr/bin/openssl genrsa 1024 > /tmp/ssl.key");
- mwexec("/usr/bin/openssl req -new -x509 -nodes -sha1 -days 2000 -key /tmp/ssl.key > /tmp/ssl.crt");
- $crt = file_get_contents("/tmp/ssl.crt");
- $key = file_get_contents("/tmp/ssl.key");
- unlink("/tmp/ssl.key");
- unlink("/tmp/ssl.crt");
+ mwexec("/usr/bin/openssl genrsa 1024 > {$g['tmp_path']}/ssl.key");
+ mwexec("/usr/bin/openssl req -new -x509 -nodes -sha1 -days 2000 -key {$g['tmp_path']}/ssl.key > {$g['tmp_path']}/ssl.crt");
+ $crt = file_get_contents("{$g['tmp_path']}/ssl.crt");
+ $key = file_get_contents("{$g['tmp_path']}/ssl.key");
+ unlink("{$g['tmp_path']}/ssl.key");
+ unlink("{$g['tmp_path']}/ssl.crt");
cert_import($cert, $crt, $key);
$a_cert[] = $cert;
$config['system']['webgui']['ssl-certref'] = $cert['refid'];
@@ -708,8 +708,8 @@ function system_generate_lighty_config($filename,
global $config, $g;
- if(!is_dir("/tmp/lighttpdcompress"))
- mkdir("/tmp/lighttpdcompress");
+ if(!is_dir("{$g['tmp_path']}/lighttpdcompress"))
+ mkdir("{$g['tmp_path']}/lighttpdcompress");
if(isset($config['system']['developerspew'])) {
$mt = microtime();
@@ -725,14 +725,14 @@ function system_generate_lighty_config($filename,
$captive_portal_mod_evasive = "evasive.max-conns-per-ip = {$maxprocperip}";
else
$captive_portal_mod_evasive = "";
- $server_upload_dirs = "server.upload-dirs = ( \"/tmp/captiveportal/\" )\n";
- exec("mkdir -p /tmp/captiveportal");
- exec("chmod a-w /tmp/captiveportal");
+ $server_upload_dirs = "server.upload-dirs = ( \"{$g['tmp_path']}/captiveportal/\" )\n";
+ exec("mkdir -p {$g['tmp_path']}/captiveportal");
+ exec("chmod a-w {$g['tmp_path']}/captiveportal");
$server_max_request_size = "server.max-request-size = 384";
} else {
$captive_portal_module = "";
$captive_portal_mod_evasive = "";
- $server_upload_dirs = "server.upload-dirs = ( \"{$g['upload_path']}/\", \"/tmp/\", \"/var/\" )\n";
+ $server_upload_dirs = "server.upload-dirs = ( \"{$g['upload_path']}/\", \"{$g['tmp_path']}/\", \"/var/\" )\n";
$server_max_request_size = "server.max-request-size = 2097152";
}
@@ -801,7 +801,7 @@ EOC;
fastcgi.server = ( ".php" =>
( "localhost" =>
(
- "socket" => "/tmp/php-fastcgi.socket",
+ "socket" => "{$g['tmp_path']}/php-fastcgi.socket",
"min-procs" => 0,
"max-procs" => {$max_procs},
{$bin_environment}
@@ -968,7 +968,7 @@ debug.log-request-handling = "disable"
debug.log-file-not-found = "disable"
# gzip compression
-compress.cache-dir = "/tmp/lighttpdcompress/"
+compress.cache-dir = "{$g['tmp_path']}/lighttpdcompress/"
compress.filetype = ("text/plain","text/css", "text/xml", "text/javascript" )
{$server_upload_dirs}
@@ -1345,4 +1345,4 @@ function enable_watchdog() {
}
}
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index 35ac8cc..169fb7d 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -941,10 +941,12 @@ function unmute_kernel_msgs() {
}
function start_devd() {
+ global $g;
+
exec("/sbin/devd");
sleep(1);
- if(file_exists("/tmp/rc.linkup"))
- unlink("/tmp/rc.linkup");
+ if(file_exists("{$g['tmp_path']}/rc.linkup"))
+ unlink("{$g['tmp_path']}/rc.linkup");
}
function is_interface_mismatch() {
OpenPOWER on IntegriCloud