aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Wagoner <rsw686@pfsense.org>2007-02-18 04:50:48 +0000
committerRyan Wagoner <rsw686@pfsense.org>2007-02-18 04:50:48 +0000
commit51025a20c0d308e46ebc879909cbba00d19e7c52 (patch)
tree67f4b0e2718493e2de1eaa7b1b4562a98da1a833
parentf496485b5f78bfc67e463853ca18072b6a217c24 (diff)
downloadpfsense-packages-51025a20c0d308e46ebc879909cbba00d19e7c52.tar.gz
pfsense-packages-51025a20c0d308e46ebc879909cbba00d19e7c52.tar.bz2
pfsense-packages-51025a20c0d308e46ebc879909cbba00d19e7c52.zip
-move logs to /var/imsepctor to deal with logs being cleared on restart
-rw-r--r--packages/imspector/imspector.inc95
-rw-r--r--packages/imspector/imspector.xml10
-rw-r--r--packages/imspector/services_imspector_logs.php2
3 files changed, 67 insertions, 40 deletions
diff --git a/packages/imspector/imspector.inc b/packages/imspector/imspector.inc
index 62ec3b5a..38e1444d 100644
--- a/packages/imspector/imspector.inc
+++ b/packages/imspector/imspector.inc
@@ -1,4 +1,33 @@
<?php
+/*
+ imspector.inc
+ part of pfSense (http://www.pfsense.com/)
+
+ Copyright (C) 2007 Ryan Wagoner <ryan@wgnrs.dynu.com>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ 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.
+ */
+
require_once("config.inc");
require_once("functions.inc");
@@ -7,8 +36,8 @@
define('IMSPECTOR_RCFILE', '/usr/local/etc/rc.d/imspector.sh');
define('IMSPECTOR_CONFIG','/usr/local/etc/imspector/imspector.conf');
- function imspector_notice ($msg) { syslog(LOG_NOTICE, "imspector: $msg"); return; }
- function imspector_warn ($msg) { syslog(LOG_WARNING, "imspector: $msg"); return; }
+ function imspector_notice ($msg) { syslog(LOG_NOTICE, "imspector: {$msg}"); return; }
+ function imspector_warn ($msg) { syslog(LOG_WARNING, "imspector: {$msg}"); return; }
function imspector_action ($action) {
if (file_exists(IMSPECTOR_RCFILE))
@@ -25,16 +54,16 @@
global $config;
if($config['installedpackages']['imspector']['config'][0]["{$name}"])
return $config['installedpackages']['imspector']['config'][0]["{$name}"];
- return NULL;
+ return null;
}
- function write_imspector_config($conf_file, $conf_text) {
- $conf = fopen($conf_file, "w");
+ function write_imspector_config($file, $text) {
+ $conf = fopen($file, "w");
if(!$conf) {
- imspector_warn("Could not open $conf_file for writing.");
+ imspector_warn("Could not open {$file} for writing.");
exit;
}
- fwrite($conf, $conf_text);
+ fwrite($conf, $text);
fclose($conf);
}
@@ -58,15 +87,10 @@
case "irc":
return 6667;
default:
- return NULL;
+ return null;
}
}
- function before_form_imspector($pkg) {
- global $config;
-
- }
-
function validate_form_imspector($post, $input_errors) {
if($post['iface_array'])
foreach($post['iface_array'] as $iface)
@@ -74,6 +98,15 @@
$input_errors[] = 'It is a security risk to specify WAN in the \'Interface\' field';
}
+ function deinstall_package_imspector() {
+ imspector_action('stop');
+
+ @unlink(IMSPECTOR_RCFILE);
+ @unlink(IMSPECTOR_CONFIG);
+
+ exec("pkg_delete imspector-0.3");
+ }
+
function sync_package_imspector() {
global $config;
global $input_errors;
@@ -84,11 +117,11 @@
exec("/sbin/pfctl -a imspector -Fr");
exec("/sbin/pfctl -a imspector -Fn");
- if(imspector_config("enable") && imspector_config("proto_array"))
- $proto_array = explode(",",imspector_config("proto_array"));
+ if(imspector_config('enable') && imspector_config('proto_array'))
+ $proto_array = explode(',', imspector_config('proto_array'));
- if(imspector_config("enable") && imspector_config("iface_array"))
- $iface_array = explode(",",imspector_config("iface_array"));
+ if(imspector_config('enable') && imspector_config('iface_array'))
+ $iface_array = explode(',', imspector_config('iface_array'));
if($iface_array && $proto_array) {
foreach($iface_array as $iface) {
@@ -129,8 +162,8 @@
$configtext .= "badwords_filename=/usr/local/etc/imspector/badwords.txt\n";
if(imspector_config("log_file")) {
- exec("mkdir -p /var/log/imspector");
- $configtext .= "file_logging_dir=/var/log/imspector\n";
+ @mkdir('/var/imspector');
+ $configtext .= "file_logging_dir=/var/imspector\n";
}
if(imspector_config("log_mysql")) {
@@ -142,7 +175,7 @@
/* XXX: for now just enable tracing of errors */
if(1) {
- exec("mkdir -p /tmp/trace");
+ @mkdir('/tmp/trace');
$configtext .= "icq_trace_error=on\n";
}
@@ -161,11 +194,11 @@ EOD;
/* write out the configuration */
conf_mount_rw();
- write_imspector_config(IMSPECTOR_CONFIG,$configtext);
+ write_imspector_config(IMSPECTOR_CONFIG, $configtext);
write_rcfile(array(
- "file" => "imspector.sh",
- "start" => $start,
- "stop" => $stop
+ 'file' => 'imspector.sh',
+ 'start' => $start,
+ 'stop' => $stop
)
);
conf_mount_ro();
@@ -173,12 +206,12 @@ EOD;
/* if imspector not running start it */
if(!imspector_running()) {
imspector_notice("Starting service on interface: {$ifaces_active}");
- imspector_action("start");
+ imspector_action('start');
}
/* or restart imspector if settings were changed */
elseif($_POST['iface_array']) {
imspector_notice("Restarting service on interface: {$ifaces_active}");
- imspector_action("restart");
+ imspector_action('restart');
}
}
}
@@ -187,13 +220,13 @@ EOD;
/* no parameters user does not want imspector running */
/* lets stop the service and remove the rc file */
- if(file_exists("/usr/local/etc/rc.d/imspector.sh")) {
- if(!imspector_config("enable"))
- imspector_notice("Stopping service: imspector disabled");
+ if(file_exists(IMSPECTOR_RCFILE)) {
+ if(!imspector_config('enable'))
+ imspector_notice('Stopping service: imspector disabled');
else
- imspector_notice("Stopping service: no interfaces and/or protocols selected");
+ imspector_notice('Stopping service: no interfaces and/or protocols selected');
- imspector_action("stop");
+ imspector_action('stop');
conf_mount_rw();
unlink(IMSPECTOR_RCFILE);
diff --git a/packages/imspector/imspector.xml b/packages/imspector/imspector.xml
index 8663799b..d434dd99 100644
--- a/packages/imspector/imspector.xml
+++ b/packages/imspector/imspector.xml
@@ -91,7 +91,7 @@
<fielddescr>Enable file logging</fielddescr>
<fieldname>log_file</fieldname>
<type>checkbox</type>
- <description>Log files stored in /var/log/imspector</description>
+ <description>Log files stored in /var/imspector</description>
</field>
<field>
<fielddescr>Enable MySQL logging</fielddescr>
@@ -120,19 +120,13 @@
<type>password</type>
</field>
</fields>
- <custom_php_command_before_form>
- before_form_imspector(&amp;$pkg);
- </custom_php_command_before_form>
<custom_php_validation_command>
validate_form_imspector($_POST, &amp;$input_errors);
</custom_php_validation_command>
<custom_php_resync_config_command>
sync_package_imspector();
</custom_php_resync_config_command>
- <custom_php_install_command>
-
- </custom_php_install_command>
<custom_php_deinstall_command>
- exec("rm -f /usr/local/etc/rc.d/imspector*");
+ deinstall_package_imspector();
</custom_php_deinstall_command>
</packagegui>
diff --git a/packages/imspector/services_imspector_logs.php b/packages/imspector/services_imspector_logs.php
index dbfac494..18dbe470 100644
--- a/packages/imspector/services_imspector_logs.php
+++ b/packages/imspector/services_imspector_logs.php
@@ -33,7 +33,7 @@
require("guiconfig.inc");
/* variables */
-$log_dir = '/var/log/imspector';
+$log_dir = '/var/imspector';
$imspector_config = $config['installedpackages']['imspector']['config'][0];
$border_color = '#c0c0c0';