From fd8ebadc0c28878851ba560961beeffc92ea8f69 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 11 Aug 2015 19:54:30 +0200 Subject: syslog-ng - code style fixes - Fix copyright header - Fix indentation - Fix permissions - Sanitize package version and make it consistent across XML files --- config/syslog-ng/syslog-ng.xml | 97 +++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 49 deletions(-) (limited to 'config') diff --git a/config/syslog-ng/syslog-ng.xml b/config/syslog-ng/syslog-ng.xml index 7d58a2ef..9b0ccffc 100644 --- a/config/syslog-ng/syslog-ng.xml +++ b/config/syslog-ng/syslog-ng.xml @@ -2,47 +2,47 @@ - - + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + 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. +*/ +/* ====================================================================================== */ + ]]> + Syslog-ng - 3.5.4.1_1 pkg.v.1.0.1 + 1.0.8 Services: Syslog-ng /usr/local/pkg/syslog-ng.inc @@ -72,18 +72,15 @@ - /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/syslog-ng/syslog-ng.inc + /usr/local/pkg/ + https://packages.pfsense.org/packages/config/syslog-ng/syslog-ng.inc - /usr/local/pkg/ - 0755 + /usr/local/pkg/ https://packages.pfsense.org/packages/config/syslog-ng/syslog-ng_advanced.xml - + - /usr/local/www/ - 0755 + /usr/local/www/ https://packages.pfsense.org/packages/config/syslog-ng/syslog-ng_log_viewer.php @@ -108,8 +105,8 @@ select udp - - + + @@ -144,7 +141,7 @@ select daily - + @@ -163,8 +160,8 @@ select gz - - + + @@ -175,7 +172,7 @@ 30 - + syslogng_validate_general($_POST, $input_errors); @@ -188,5 +185,7 @@ syslogng_deinstall_command(); - syslogng_generate_rules + + syslogng_generate_rules(); + -- cgit v1.2.3 From 353c7fd50e5deef66c26cb93663296aeb43dda85 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 11 Aug 2015 19:56:48 +0200 Subject: syslog-ng - code style fixes - Fix copyright header - Sanitize package version and make it consistent across XML files --- config/syslog-ng/syslog-ng_advanced.xml | 74 ++++++++++++++++----------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'config') diff --git a/config/syslog-ng/syslog-ng_advanced.xml b/config/syslog-ng/syslog-ng_advanced.xml index b1290544..94067580 100644 --- a/config/syslog-ng/syslog-ng_advanced.xml +++ b/config/syslog-ng/syslog-ng_advanced.xml @@ -1,48 +1,48 @@ - - + + - - + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + 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. +*/ +/* ====================================================================================== */ + ]]> + Syslog-ng Advanced - 0.1.0 + 1.0.8 Services: Syslog-ng Advanced /usr/local/pkg/syslog-ng.inc An object has been deleted. @@ -133,4 +133,4 @@ syslogng_resync(); - \ No newline at end of file + -- cgit v1.2.3 From de2bb6cf79b2426b9d5cf745f09d3bba37dcc6c7 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 11 Aug 2015 20:06:16 +0200 Subject: syslog-ng - code style fixes - Update copyright header - Code style fixes - Fix indentation - Use get_interface_ip() instead of parsing ifconfig output - Use {start,stop,restart}_service() instead of exec() - Use rename() instead of mv. - Use platform_booting() to check whether system is booting --- config/syslog-ng/syslog-ng.inc | 262 ++++++++++++++++++++++------------------- 1 file changed, 141 insertions(+), 121 deletions(-) (limited to 'config') diff --git a/config/syslog-ng/syslog-ng.inc b/config/syslog-ng/syslog-ng.inc index 56decfad..f0c17ff1 100644 --- a/config/syslog-ng/syslog-ng.inc +++ b/config/syslog-ng/syslog-ng.inc @@ -1,8 +1,9 @@ $post['objecttype'], "objectname"=>$post['objectname'], "objectparameters"=>$post['objectparameters']); - - if(empty($objects)) { + + if (empty($objects)) { $objects = $new_object; } else { $objects = syslogng_merge_objects($objects, $new_object); } - - if($errors = syslogng_test_object_syntax($objects)) + + if ($errors = syslogng_test_object_syntax($objects)) { $input_errors[] = "Syslog-ng syntax test failed:\n" . $errors; + } } function syslogng_install_cron($should_install) { - global $config, $g; - - if($g['booting']==true) + global $config; + + if (platform_booting()) { return; - - if(!$config['cron']['item']) + } + + if (!$config['cron']['item']) { return; + } $x=0; $rotate_job_id=-1; $rotate_is_installed = false; - - foreach($config['cron']['item'] as $item) { - if(strstr($item['task_name'], "syslogng_rotate_logs")) { + + foreach ($config['cron']['item'] as $item) { + if (strstr($item['task_name'], "syslogng_rotate_logs")) { $rotate_job_id = $x; } $x++; } $need_write = false; - switch($should_install) { + switch ($should_install) { case true: - if($rotate_job_id < 0) { + if ($rotate_job_id < 0) { $cron_item = array(); $cron_item['task_name'] = "syslogng_rotate_logs"; $cron_item['minute'] = "0"; @@ -167,21 +176,21 @@ function syslogng_install_cron($should_install) { $cron_item['month'] = "*"; $cron_item['wday'] = "*"; $cron_item['who'] = "root"; - $cron_item['command'] = "/usr/bin/nice -n20 " . SYSLOGNG_BASEDIR . "local/sbin/logrotate /usr/local/etc/logrotate.conf"; + $cron_item['command'] = "/usr/bin/nice -n20 " . SYSLOGNG_BASEDIR . "local/sbin/logrotate /usr/local/etc/logrotate.conf"; $config['cron']['item'][] = $cron_item; $need_write = true; } - if($need_write) { + if ($need_write) { parse_config(true); write_config("Adding syslog-ng Cron Jobs"); } break; case false: - if($rotate_job_id >= 0) { + if ($rotate_job_id >= 0) { unset($config['cron']['item'][$rotate_job_id]); $need_write = true; } - if($need_write) { + if ($need_write) { parse_config(true); write_config("Removing syslog-ng Cron Jobs"); } @@ -192,17 +201,17 @@ function syslogng_install_cron($should_install) { function syslogng_build_default_objects($settings) { $default_objects = array(); - + $interfaces = $settings['interfaces']; $default_protocol = $settings['default_protocol']; $default_port = $settings['default_port']; $default_logdir = $settings['default_logdir']; $default_logfile = $settings['default_logfile']; - + $default_objects[0] = array("objecttype"=>"source", "objectname"=>"_DEFAULT", "objectparameters"=>"{ internal(); syslog(transport($default_protocol) port($default_port)"); foreach (explode(",", $interfaces) as $interface) { $interface_address = syslogng_get_real_interface_address($interface); - if($interface_address[0]) { + if ($interface_address[0]) { $default_objects[0]['objectparameters'] .= " ip({$interface_address[0]})"; } } @@ -212,51 +221,52 @@ function syslogng_build_default_objects($settings) { $default_objects[1]['objectparameters'] = base64_encode($default_objects[1]['objectparameters']); $default_objects[2] = array("objecttype"=>"log", "objectname"=>"_DEFAULT", "objectparameters"=>"{ source(_DEFAULT); destination(_DEFAULT); };"); $default_objects[2]['objectparameters'] = base64_encode($default_objects[2]['objectparameters']); - + return $default_objects; } -function syslogng_merge_objects($objects1, $objects2) -{ - foreach($objects2 as $object2) { +function syslogng_merge_objects($objects1, $objects2) { + + foreach ($objects2 as $object2) { $match = 0; - foreach($objects1 as &$object1) { - if(($object2['objecttype'] == $object1['objecttype']) && ($object2['objectname'] == $object1['objectname'])) { + foreach ($objects1 as &$object1) { + if (($object2['objecttype'] == $object1['objecttype']) && ($object2['objectname'] == $object1['objectname'])) { $object1 = $object2; $match = 1; } } - if($match == 0) + if ($match == 0) { array_push($objects1, $object2); + } } return $objects1; } function syslogng_test_object_syntax($objects) { - exec("mv /usr/local/etc/syslog-ng.conf /usr/local/etc/syslog-ng.conf.backup"); + rename("/usr/local/etc/syslog-ng.conf", "/usr/local/etc/syslog-ng.conf.backup"); syslogng_build_conf($objects); $errors = trim(shell_exec('/usr/local/sbin/syslog-ng --syntax-only 2>&1')); - exec("mv /usr/local/etc/syslog-ng.conf /usr/local/etc/syslog-ng.conf.tested"); - exec("mv /usr/local/etc/syslog-ng.conf.backup /usr/local/etc/syslog-ng.conf"); - + rename("/usr/local/etc/syslog-ng.conf", "/usr/local/etc/syslog-ng.conf.tested"); + rename("/usr/local/etc/syslog-ng.conf.backup", "/usr/local/etc/syslog-ng.conf"); + return $errors; } function syslogng_get_log_files($objects) { $log_files = array(); - - foreach($objects as $object) { - if($object['objecttype'] == 'destination') { + + foreach ($objects as $object) { + if ($object['objecttype'] == 'destination') { preg_match("/\bfile\b\(['\"]([^'\"]*)['\"]/", base64_decode($object['objectparameters']), $match); - if($match) { + if ($match) { $log_file = $match[1]; array_push($log_files, $log_file); } } } - + return $log_files; } @@ -264,15 +274,15 @@ function syslogng_build_conf($objects) { $conf = "# This file is automatically generated by pfSense\n"; $conf .= "# Do not edit manually !\n"; $conf .= "@version:3.6\n"; - - foreach($objects as $object) { - if($object['objecttype'] == 'log' || $object['objecttype'] == 'options') { + + foreach ($objects as $object) { + if ($object['objecttype'] == 'log' || $object['objecttype'] == 'options') { $conf .= $object['objecttype'] . " " . base64_decode($object['objectparameters']) . "\n"; } else { $conf .= $object['objecttype'] . " " . $object['objectname'] . " " . base64_decode($object['objectparameters']) . "\n"; } } - + file_put_contents('/usr/local/etc/syslog-ng.conf', $conf); } @@ -287,7 +297,7 @@ function syslogng_build_logrotate_conf($settings, $objects) { $log_files = syslogng_get_log_files($objects); - foreach($log_files as $log_file) { + foreach ($log_files as $log_file) { $conf .= "$log_file "; } @@ -295,9 +305,9 @@ function syslogng_build_logrotate_conf($settings, $objects) { $conf .= "\trotate $max_archives\n"; $conf .= "\t$archive_frequency\n"; - if($compress_archives == 'on') { + if ($compress_archives == 'on') { $conf .= "\tcompress\n"; - if($compress_type == 'bz2') { + if ($compress_type == 'bz2') { $conf .= "\tcompresscmd bzip2\n"; } } @@ -312,103 +322,113 @@ function syslogng_build_logrotate_conf($settings, $objects) { function syslogng_generate_rules($type) { global $config; - + $settings = $config['installedpackages']['syslogng']['config'][0]; - + $interfaces = ($settings['interfaces'] ? $settings['interfaces'] : 'lan'); $default_protocol = ($settings['default_protocol'] ? $settings['default_protocol'] : 'udp'); $default_port = ($settings['default_port'] ? $settings['default_port'] : 5140); - + $rules = ""; - switch($type) { + switch ($type) { case 'rule': foreach ($interfaces as $interface) { $rules .= "pass in quick on $interface proto $default_protocol from any to !($interface) port $default_port no state label\n"; } break; } - + return $rules; } - + function syslogng_resync() { global $config; conf_mount_rw(); - + $settings = $config['installedpackages']['syslogng']['config'][0]; $objects = $config['installedpackages']['syslogngadvanced']['config']; - - if(!isset($settings['enable'])) + + if (!isset($settings['enable'])) { $settings['enable'] = 'off'; - if(!isset($settings['interfaces'])) + } + if (!isset($settings['interfaces'])) { $settings['interfaces'] = 'lan'; - if(!isset($settings['default_protocol'])) + } + if (!isset($settings['default_protocol'])) { $settings['default_protocol'] = 'udp'; - if(!isset($settings['default_port'])) + } + if (!isset($settings['default_port'])) { $settings['default_port'] = 5140; - if(!isset($settings['default_logdir'])) + } + if (!isset($settings['default_logdir'])) { $settings['default_logdir'] = '/var/syslog-ng'; - if(!isset($settings['default_logfile'])) + } + if (!isset($settings['default_logfile'])) { $settings['default_logfile'] = 'default.log'; - if(!isset($settings['archive_frequency'])) + } + if (!isset($settings['archive_frequency'])) { $settings['archive_frequency'] = 'daily'; - if(!isset($settings['compress_archives'])) + } + if (!isset($settings['compress_archives'])) { $settings['compress_archives'] = 'on'; - if(!isset($settings['compress_type'])) + } + if (!isset($settings['compress_type'])) { $settings['compress_type'] = 'gz'; - if(!isset($settings['max_archives'])) + } + if (!isset($settings['max_archives'])) { $settings['max_archives'] = 30; - + } + $default_objects = syslogng_build_default_objects($settings); - - if(empty($objects)) { + + if (empty($objects)) { $objects = $default_objects; } else { $objects = syslogng_merge_objects($objects, $default_objects); } - - $sort = array(); - foreach($objects as $k=>$v) { - $sort['objecttype'][$k] = $v['objecttype']; - $sort['objectname'][$k] = $v['objectname']; - } - array_multisort($sort['objecttype'], SORT_ASC, $sort['objectname'], SORT_ASC, $objects); + + $sort = array(); + foreach ($objects as $k=>$v) { + $sort['objecttype'][$k] = $v['objecttype']; + $sort['objectname'][$k] = $v['objectname']; + } + array_multisort($sort['objecttype'], SORT_ASC, $sort['objectname'], SORT_ASC, $objects); syslogng_build_conf($objects); syslogng_build_logrotate_conf($settings, $objects); $config['installedpackages']['syslogng']['config'][0] = $settings; $config['installedpackages']['syslogngadvanced']['config'] = $objects; - - if($settings['enable'] == 'on') { - if(!file_exists($settings['default_logdir'])) { + + if ($settings['enable'] == 'on') { + if (!file_exists($settings['default_logdir'])) { exec("mkdir -p " . $settings['default_logdir']); } - + syslogng_write_rcfile(); - - if(!is_service_running('syslog-ng')) { + + if (!is_service_running('syslog-ng')) { log_error("Starting syslog-ng"); - exec("/usr/local/etc/rc.d/syslog-ng.sh start"); + start_service("syslog-ng"); } else { log_error("Reloading syslog-ng for configuration sync"); - exec("/usr/local/etc/rc.d/syslog-ng.sh restart"); + restart_service("syslog-ng"); } - + // Sleep for a couple seconds to give syslog-ng a chance to fire up fully. for ($i=0; $i < 10; $i++) { - if(!is_service_running('syslog-ng')) + if (!is_service_running('syslog-ng')) { sleep(1); + } } } else { - if(is_service_running('syslog-ng')) { + if (is_service_running('syslog-ng')) { log_error("Stopping syslog-ng"); - exec("/usr/local/etc/rc.d/syslog-ng.sh stop"); - + stop_service("syslog-ng"); unlink_if_exists("/usr/local/etc/rc.d/syslog-ng.sh"); } } - + write_config(); conf_mount_ro(); filter_configure(); -- cgit v1.2.3 From c55025096e3b4f78280ab06e79a4537273375e7d Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 11 Aug 2015 20:08:06 +0200 Subject: syslog-ng - code style fixes - Fix copyright header - Code style and indentation fixes - Valid XHTML --- config/syslog-ng/syslog-ng_log_viewer.php | 114 +++++++++++++++--------------- 1 file changed, 58 insertions(+), 56 deletions(-) (limited to 'config') diff --git a/config/syslog-ng/syslog-ng_log_viewer.php b/config/syslog-ng/syslog-ng_log_viewer.php index c8183f14..c914110a 100644 --- a/config/syslog-ng/syslog-ng_log_viewer.php +++ b/config/syslog-ng/syslog-ng_log_viewer.php @@ -1,37 +1,32 @@ 0)) { +if (file_exists($logfile) && (filesize($logfile) > 0)) { $grep = "grep -ih"; - - if(($compress_archives == 'on') && glob($logfile . "*" . $compress_type) && $archives) { + + if (($compress_archives == 'on') && glob($logfile . "*" . $compress_type) && $archives) { if($compress_type == 'bz2') { $grep = "bzgrep -ih"; } else { $grep = "zgrep -ih"; } } - - if(isset($filter) && $not) { + + if (isset($filter) && $not) { $grepcmd = "$grep -v '$filter' $logfile"; } else { $grepcmd = "$grep '$filter' $logfile"; } - - if($archives) + + if ($archives) { $grepcmd = $grepcmd . "*"; - + } + $log_lines = trim(shell_exec("$grepcmd | wc -l")); $log_output = trim(shell_exec("$grepcmd | sort -M | tail -n $limit")); - - if(!empty($log_output)) { + + if (!empty($log_output)) { $log_messages = explode("\n", $log_output); $log_messages_count = sizeof($log_messages); } @@ -92,7 +93,7 @@ if(file_exists($logfile) && (filesize($logfile) > 0)) { $pgtitle = "Services: Syslog-ng Log Viewer"; include("head.inc"); -?> +?> @@ -107,11 +108,11 @@ include("head.inc"); display_top_tabs($tab_array); ?> - +
- +
- + \n"; - foreach($log_messages as $log_message) { + foreach($log_messages as $log_message) { echo "\n"; } } else { @@ -156,7 +157,7 @@ include("head.inc");
Log FileShowing $log_messages_count of $log_lines messages
$log_message
Inverse Filter (NOT) />
- +
@@ -164,4 +165,5 @@ include("head.inc"); - \ No newline at end of file + + -- cgit v1.2.3