From 84fbc1eb3b39d5f7f902a4b57caed2c9501e7baf Mon Sep 17 00:00:00 2001 From: Ryan Wagoner Date: Sat, 16 Feb 2008 01:26:59 +0000 Subject: bump imspector version --- packages/imspector/imspector.inc | 73 +++++++++++++++++------- packages/imspector/imspector.xml | 78 +++++++++++++++++++++----- packages/imspector/services_imspector_logs.php | 12 ++-- 3 files changed, 123 insertions(+), 40 deletions(-) (limited to 'packages/imspector') diff --git a/packages/imspector/imspector.inc b/packages/imspector/imspector.inc index 2bf61909..09974363 100644 --- a/packages/imspector/imspector.inc +++ b/packages/imspector/imspector.inc @@ -34,7 +34,8 @@ /* IMSpector */ define('IMSPECTOR_RCFILE', '/usr/local/etc/rc.d/imspector.sh'); - define('IMSPECTOR_CONFIG', '/usr/local/etc/imspector/imspector.conf'); + define('IMSPECTOR_ETC', '/usr/local/etc/imspector'); + define('IMSPECTOR_CONFIG', IMSPECTOR_ETC . '/imspector.conf'); function imspector_notice ($msg) { syslog(LOG_NOTICE, "imspector: {$msg}"); } function imspector_warn ($msg) { syslog(LOG_WARNING, "imspector: {$msg}"); } @@ -96,8 +97,11 @@ @unlink(IMSPECTOR_RCFILE); @unlink(IMSPECTOR_CONFIG); + @unlink(IMSPECTOR_ETC . '/badwords_custom.txt'); + @unlink(IMSPECTOR_ETC . '/acl_blacklist.txt'); + @unlink(IMSPECTOR_ETC . '/acl_whitelist.txt'); - exec('pkg_delete imspector-0.3'); + //exec('pkg_delete imspector-0.4'); } function sync_package_imspector() { @@ -150,31 +154,59 @@ if($pf_rules) { exec("echo \"{$pf_rules}\" | /sbin/pfctl -a imspector -f -"); - $configtext = "plugin_dir=/usr/local/lib/imspector\n"; + conf_mount_rw(); - foreach($proto_array as $proto) - $configtext .= "{$proto}_protocol=on\n"; + /* generate configuration files */ - if($imspector_config["filter_badwords"]) - $configtext .= "badwords_filename=/usr/local/etc/imspector/badwords.txt\n"; + $conf['plugin_dir'] = '/usr/local/lib/imspector'; + + foreach($proto_array as $proto) + $conf[$proto . '_protocol'] = 'on'; - if($imspector_config["log_file"]) { + if($imspector_config['log_file']) { @mkdir('/var/imspector'); - $configtext .= "file_logging_dir=/var/imspector\n"; + $conf['file_logging_dir'] = '/var/imspector'; } - if($imspector_config["log_mysql"]) { - $configtext .= "mysql_server={$imspector_config["mysql_server"]}\n"; - $configtext .= "mysql_database={$imspector_config["mysql_database"]}\n"; - $configtext .= "mysql_username={$imspector_config["mysql_username"]}\n"; - $configtext .= "mysql_password={$imspector_config["mysql_password"]}\n"; + if($imspector_config['log_mysql']) { + $conf['mysql_server'] = $imspector_config['mysql_server']; + $conf['mysql_database'] = $imspector_config['mysql_database']; + $conf['mysql_username'] = $imspector_config['mysql_username']; + $conf['mysql_password'] = $imspector_config['mysql_password']; } - if(0) { - @mkdir('/tmp/trace'); - $configtext .= "icq_trace_error=on\n"; + if($imspector_config['filter_badwords']) { + if(!empty($imspector_config["badwords_list"])) { + $conf['badwords_filename'] = IMSPECTOR_ETC . '/badwords_custom.txt'; + write_imspector_config(IMSPECTOR_ETC . '/badwords_custom.txt', + str_replace("\r", '', base64_decode($imspector_config["badwords_list"]))); + } else + $conf['badwords_filename'] = IMSPECTOR_ETC . '/badwords.txt'; } + if($imspector_config['block_files']) + $conf['block_files'] = 'on'; + + if($imspector_config['block_unlisted']) + $conf['block_unlisted'] = 'on'; + + if(!empty($imspector_config['acl_whitelist'])) { + $conf['whitelist_filename'] = IMSPECTOR_ETC . '/acl_whitelist.txt'; + write_imspector_config(IMSPECTOR_ETC . '/acl_whitelist.txt', + str_replace("\r", '', base64_decode($imspector_config["acl_whitelist"]))); + } + + if(!empty($imspector_config['acl_blacklist'])) { + $conf['blacklist_filename'] = IMSPECTOR_ETC . '/acl_blacklist.txt'; + write_imspector_config(IMSPECTOR_ETC . '/acl_blacklist.txt', + str_replace("\r", '', base64_decode($imspector_config["acl_blacklist"]))); + } + + $conftext = ''; + foreach($conf as $var => $key) + $conftext .= "{$var}={$key}\n"; + write_imspector_config(IMSPECTOR_CONFIG, $conftext); + /* generate rc file start and stop */ $stop = << 'imspector.sh', 'start' => $start, 'stop' => $stop ) ); + conf_mount_ro(); /* if imspector not running start it */ @@ -226,6 +256,9 @@ EOD; conf_mount_rw(); unlink(IMSPECTOR_RCFILE); unlink(IMSPECTOR_CONFIG); + @unlink(IMSPECTOR_ETC . '/badwords_custom.txt'); + @unlink(IMSPECTOR_ETC . '/acl_blacklist.txt'); + @unlink(IMSPECTOR_ETC . '/acl_whitelist.txt'); conf_mount_ro(); } } diff --git a/packages/imspector/imspector.xml b/packages/imspector/imspector.xml index ceff0ae3..076dca13 100644 --- a/packages/imspector/imspector.xml +++ b/packages/imspector/imspector.xml @@ -46,7 +46,7 @@ Describe your package requirements here Currently there are no FAQ items provided. imspector - 0.3.1 + 0.4 Services: IMSpector Change /services_imspector_logs.php @@ -126,44 +126,92 @@ - - Enable filtering of bad words - filter_badwords - Replaces words specified in /usr/local/etc/imspector/badwords.txt with * - checkbox - Enable file logging log_file - Log files stored in /var/imspector + Log files stored in /var/imspector. checkbox - Enable MySQL logging + Enable mySQL logging log_mysql - Make sure to specify your MySQL credentials below + Make sure to specify your MySQL credentials below. checkbox - MySQL Server + mySQL server mysql_server input - MySQL Database + mySQL database mysql_database input - MySQL Username + mySQL username mysql_username input - MySQL Password + mySQL password mysql_password password - + + + Enable bad word filtering + filter_badwords + Replace characters of matched bad word with *. + checkbox + + + Bad words list + badwords_list + + Place one word or phrase to match per line.<br /> + If left blank the default list in /usr/local/etc/imspector/badwords.txt will be used. + + textarea + base64 + 5 + 40 + + + Block file transfers + block_files + Block file transfers on supported protocols. + checkbox + + + Block non ACL defined + block_unlisted + Overide the default of allowing user's not defined the whitelist or blacklist ACLs. + checkbox + + + ACL whitelist + acl_whitelist + + Example (allow specifc access): localuser: remoteuser1 remoteuser2<br /> + Example (allow full access): localuser: + + textarea + base64 + 5 + 40 + + + ACL blacklist + acl_blacklist + + Example (block specifc access): localuser: remoteuser1 remoteuser2<br /> + Example (block all access): localuser: + + textarea + base64 + 5 + 40 + validate_form_imspector($_POST, &$input_errors); diff --git a/packages/imspector/services_imspector_logs.php b/packages/imspector/services_imspector_logs.php index 85df991e..616d3dfc 100644 --- a/packages/imspector/services_imspector_logs.php +++ b/packages/imspector/services_imspector_logs.php @@ -102,17 +102,19 @@ if ($_POST['mode'] == "render") { $line = fgets($fd); if(feof($fd)) continue; - preg_match('/([^,]*),([^,]*),([^,]*),(.*)/', $line, $matches); + preg_match('/([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),(.*)/', $line, $matches); $address = $matches[1]; $timestamp = $matches[2]; - $type = $matches[3]; - $data = $matches[4]; + $direction = $matches[3]; + $type = $matches[4]; + $filtered = $matches[5]; + $data = $matches[6]; - if($type == '1') { + if($direction == '0') { $bgcolor = $convo_remote_bgcolor; $user = "<$remoteuser>"; } - if($type == '2') { + if($direction == '1') { $bgcolor = $convo_local_bgcolor; $user = "<$localuser>"; } -- cgit v1.2.3