Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syslogng - Remove PBI crap, add missing includes, fix logrotate path, use full paths to binaries #6

Merged
merged 7 commits into from
Dec 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sysutils/pfSense-pkg-syslog-ng/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# $FreeBSD$

PORTNAME= pfSense-pkg-syslog-ng
PORTVERSION= 1.1.1
PORTVERSION= 1.1.2
CATEGORIES= sysutils
MASTER_SITES= # empty
DISTFILES= # empty
Expand Down
42 changes: 15 additions & 27 deletions sysutils/pfSense-pkg-syslog-ng/files/usr/local/pkg/syslog-ng.inc
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,19 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once('globals.inc');
require_once('config.inc');
require_once('util.inc');
require_once('globals.inc');
require_once('interfaces.inc');
require_once('pfsense-utils.inc');
require_once('pkg-utils.inc');
require_once('services.inc');
require_once('service-utils.inc');

require_once('util.inc');
if (!function_exists("filter_configure")) {
require_once("filter.inc");
}

$pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3);
if ($pf_version == "2.1" || $pf_version == "2.2") {
define("SYSLOGNG_BASEDIR", "/usr/pbi/syslog-ng-" . php_uname("m") . "/");
} else {
define("SYSLOGNG_BASEDIR", "/usr/local/");
}
define("SYSLOGNG_BASEDIR", "/usr/local/");

function syslogng_get_real_interface_address($interface) {
$interface = convert_friendly_interface_to_real_interface_name($interface);
Expand All @@ -52,13 +48,7 @@ function syslogng_get_real_interface_address($interface) {
}

function syslogng_install_command() {
if (is_link("/usr/local/lib/syslog-ng")) {
unlink("/usr/local/lib/syslog-ng");
}
if (!file_exists("/usr/local/lib/syslog-ng")) {
@symlink(SYSLOGNG_BASEDIR . "local/lib/syslog-ng", "/usr/local/lib/syslog-ng");
}
$crontask = "/usr/bin/nice -n20 " . SYSLOGNG_BASEDIR . "local/sbin/logrotate /usr/local/etc/logrotate.conf";
$crontask = "/usr/bin/nice -n20 " . SYSLOGNG_BASEDIR . "sbin/logrotate /usr/local/etc/logrotate.conf";
install_cron_job("${crontask}", true, "0");
syslogng_resync();
}
Expand All @@ -67,7 +57,7 @@ function syslogng_deinstall_command() {
if (is_link("/usr/local/lib/syslog-ng")) {
unlink("/usr/local/lib/syslog-ng");
}
$crontask = "/usr/bin/nice -n20 " . SYSLOGNG_BASEDIR . "local/sbin/logrotate /usr/local/etc/logrotate.conf";
$crontask = "/usr/bin/nice -n20 " . SYSLOGNG_BASEDIR . "sbin/logrotate /usr/local/etc/logrotate.conf";
install_cron_job("${crontask}", false);
unlink_if_exists("/usr/local/etc/logrotate.conf");
unlink_if_exists("/usr/local/etc/syslog-ng.conf");
Expand All @@ -89,7 +79,7 @@ function syslogng_validate_general($post, &$input_errors) {
$input_errors[] = 'You must enter a valid port number in the \'Default Port\' field';
}

$sockstat = trim(shell_exec("sockstat -l -P " . $post['default_protocol'] . " -p " . $post['default_port'] . " | grep -v ^USER | grep -v syslog-ng"));
$sockstat = trim(shell_exec("/usr/bin/sockstat -l -P " . $post['default_protocol'] . " -p " . $post['default_port'] . " | /usr/bin/grep -v ^USER | /usr/bin/grep -v syslog-ng"));
if (!empty($sockstat)) {
$input_errors[] = 'The port specified in the \'Default Port\' field is already in use';
}
Expand Down Expand Up @@ -342,9 +332,7 @@ function syslogng_resync() {
$config['installedpackages']['syslogngadvanced']['config'] = $objects;

if ($settings['enable'] == 'on') {
if (!file_exists($settings['default_logdir'])) {
exec("mkdir -p " . $settings['default_logdir']);
}
safe_mkdir("{$settings['default_logdir']}", 0755);

syslogng_write_rcfile();

Expand Down Expand Up @@ -380,27 +368,27 @@ function syslogng_write_rcfile() {
$pid_file = "/var/run/syslog-ng.pid";
$rc['file'] = 'syslog-ng.sh';
$rc['start'] = <<<EOD
if [ -z "`ps auxw | grep "syslog-ng" | grep -v "syslog-ng.sh" | grep -v "grep"`" ]; then
if [ -z "`/bin/ps auxw | /usr/bin/grep "syslog-ng" | /usr/bin/grep -v "syslog-ng.sh" | /usr/bin/grep -v "grep"`" ]; then
/usr/local/sbin/syslog-ng -p {$pid_file}
fi

EOD;
$rc['stop'] = <<<EOD
if [ -s "{$pid_file}" ]; then
kill `cat {$pid_file}` 2>/dev/null
/bin/kill `cat {$pid_file}` 2>/dev/null
fi
# Just in case pid file didn't exist or process is still running...
sleep 5
killall -9 syslog-ng 2>/dev/null
/usr/bin/killall -9 syslog-ng 2>/dev/null

EOD;
$rc['restart'] = <<<EOD
if [ -z "`ps auxw | grep "syslog-ng" | grep -v "syslog-ng.sh"`" ]; then
if [ -z "`/bin/ps auxw | /usr/bin/grep "syslog-ng" | /usr/bin/grep -v "syslog-ng.sh"`" ]; then
/usr/local/sbin/syslog-ng -p {$pid_file}
elif [ -s "{$pid_file}" ]; then
kill -s HUP `cat {$pid_file}` 2>/dev/null
/bin/kill -s HUP `cat {$pid_file}` 2>/dev/null
else
killall -9 syslog-ng 2>/dev/null
/usr/bin/killall -9 syslog-ng 2>/dev/null
/usr/local/sbin/syslog-ng -p {$pid_file}
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
]]>
</copyright>
<name>Syslog-ng</name>
<version>1.1.1</version>
<version>1.1.2</version>
<title>Services: Syslog-ng</title>
<include_file>/usr/local/pkg/syslog-ng.inc</include_file>
<menu>
Expand Down Expand Up @@ -190,6 +190,6 @@
syslogng_deinstall_command();
</custom_php_deinstall_command>
<filter_rules_needed>
syslogng_generate_rules();
syslogng_generate_rules
</filter_rules_needed>
</packagegui>
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
]]>
</copyright>
<name>Syslog-ng Advanced</name>
<version>1.0.8</version>
<version>1.1.2</version>
<title>Services: Syslog-ng Advanced</title>
<include_file>/usr/local/pkg/syslog-ng.inc</include_file>
<delete_string>An object has been deleted.</delete_string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@
<website>http://www.balabit.com/network-security/syslog-ng/</website>
<descr><![CDATA[Syslog-ng syslog server. This service is not intended to replace the default pfSense syslog server but rather acts as an independent syslog server.]]></descr>
<category>System</category>
<version>1.1.1</version>
<version>1.1.2</version>
<status>BETA</status>
<required_version>2.2</required_version>
<depends_on_package_pbi>syslog-ng-3.6.2_3-##ARCH##.pbi</depends_on_package_pbi>
<port_category>sysutils</port_category>
<run_depends>sbin/syslog-ng:sysutils/syslog-ng</run_depends>
<build_pbi>
<ports_before>sysutils/logrotate</ports_before>
<port>sysutils/syslog-ng</port>
</build_pbi>
<required_version>2.3</required_version>
<maintainer>[email protected]</maintainer>
<config_file>https://packages.pfsense.org/packages/config/syslog-ng/syslog-ng.xml</config_file>
<configurationfile>syslog-ng.xml</configurationfile>
</package>
</pfsensepkgs>
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
$pgtitle = "Services: Syslog-ng Log Viewer";
include("head.inc");
?>
<body link="#000000" vlink="#000000" alink="#000000">
<?php include("fbegin.inc"); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
<form action="syslog-ng_log_viewer.php" method="post" name="iform">
Expand Down Expand Up @@ -164,6 +163,4 @@
</td></tr>
</table>
</form>
<?php include("fend.inc"); ?>
</body>
</html>
<?php include("foot.inc"); ?>