--- nagios3-3.4.1.orig/debian/patches/30_fix_p1_debug_path.dpatch
+++ nagios3-3.4.1/debian/patches/30_fix_p1_debug_path.dpatch
@@ -0,0 +1,19 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 30_fix_p1_debug_path.dpatch by Alexander Wirt
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+@DPATCH@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' pkg-nagios3~/p1.pl pkg-nagios3/p1.pl
+--- pkg-nagios3~/p1.pl 2012-05-07 20:43:10.000000000 +0200
++++ pkg-nagios3/p1.pl 2012-05-07 20:50:14.000000000 +0200
+@@ -16,7 +16,7 @@
+ # use constant DEBUG_LEVEL => LEAVE_MSG | CACHE_DUMP ;
+ # use constant DEBUG_LEVEL => LEAVE_MSG | CACHE_DUMP | PLUGIN_DUMP ;
+
+-use constant DEBUG_LOG_PATH => '/usr/local/nagios/var/' ;
++use constant DEBUG_LOG_PATH => '/var/log/nagios3/' ;
+ # use constant DEBUG_LOG_PATH => './' ;
+ use constant LEAVE_MSG_STREAM => DEBUG_LOG_PATH . 'epn_leave-msgs.log' ;
+ use constant CACHE_DUMP_STREAM => DEBUG_LOG_PATH . 'epn_cache-dump.log' ;
--- nagios3-3.4.1.orig/debian/patches/40_fix_spurious_dollar_signs_added_to_command_lines.dpatch
+++ nagios3-3.4.1/debian/patches/40_fix_spurious_dollar_signs_added_to_command_lines.dpatch
@@ -0,0 +1,20 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 40_fix_spurious_dollar_signs_added_to_command_lines.dpatch by Alexander Wirt
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fixes the output of spurious $ signs in commandoutput (#480001)
+
+@DPATCH@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' pkg-nagios3~/common/macros.c pkg-nagios3/common/macros.c
+--- pkg-nagios3~/common/macros.c 2012-05-07 20:43:10.000000000 +0200
++++ pkg-nagios3/common/macros.c 2012-05-07 21:51:23.191049586 +0200
+@@ -185,7 +185,8 @@
+ *output_buffer = (char *)realloc(*output_buffer, strlen(*output_buffer) + strlen(temp_buffer) + 3);
+ strcat(*output_buffer, "$");
+ strcat(*output_buffer, temp_buffer);
+- strcat(*output_buffer, "$");
++ if (buf_ptr!=NULL)
++ strcat(*output_buffer,"$");
+ }
+
+ /* insert macro */
--- nagios3-3.4.1.orig/debian/patches/90_fix_forced_servicechecks.dpatch
+++ nagios3-3.4.1/debian/patches/90_fix_forced_servicechecks.dpatch
@@ -0,0 +1,20 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 90_fix_forced_servicechecks.dpatch by Alexander Wirt
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fixes handling of forced checks
+
+@DPATCH@
+diff -urNad nagios3-3.0.6~/cgi/cmd.c nagios3-3.0.6/cgi/cmd.c
+--- nagios3-3.0.6~/cgi/cmd.c 2008-11-30 18:22:58.000000000 +0100
++++ nagios3-3.0.6/cgi/cmd.c 2008-12-12 13:50:46.000000000 +0100
+@@ -2033,7 +2033,8 @@
+ break;
+
+ case CMD_SCHEDULE_SVC_CHECK:
+- case CMD_SCHEDULE_FORCED_SVC_CHECK:
++ if (force_check == TRUE)
++ cmd = CMD_SCHEDULE_FORCED_SVC_CHECK;
+ result = cmd_submitf(cmd,"%s;%s;%lu",host_name,service_desc,start_time);
+ break;
+
--- nagios3-3.4.1.orig/debian/patches/55_strip_logarchivepath.dpatch
+++ nagios3-3.4.1/debian/patches/55_strip_logarchivepath.dpatch
@@ -0,0 +1,18 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 55_strip_logarchivepath.dpatch by Omni Flux
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: stripping the log_archive_path value from cgi.cfg (#578232)
+@DPATCH@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' pkg-nagios3~/cgi/cgiutils.c pkg-nagios3/cgi/cgiutils.c
+--- pkg-nagios3~/cgi/cgiutils.c 2012-05-07 20:43:10.000000000 +0200
++++ pkg-nagios3/cgi/cgiutils.c 2012-05-07 22:00:06.155062976 +0200
+@@ -500,7 +500,7 @@
+ temp_buffer = strtok(NULL, "\n");
+ strncpy(log_archive_path, (temp_buffer == NULL) ? "" : temp_buffer, sizeof(log_archive_path));
+ log_archive_path[sizeof(log_archive_path) - 1] = '\x0';
+- strip(physical_html_path);
++ strip(log_archive_path);
+ if(log_archive_path[strlen(log_archive_path) - 1] != '/' && (strlen(log_archive_path) < sizeof(log_archive_path) - 1))
+ strcat(log_archive_path, "/");
+ }
--- nagios3-3.4.1.orig/debian/patches/99_security_status_cgi_servicegroup.dpatch
+++ nagios3-3.4.1/debian/patches/99_security_status_cgi_servicegroup.dpatch
@@ -0,0 +1,56 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 99_security_status_cgi_servicegroup.dpatch by Jonas Meurer
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Stop cgi-bin/status.c from listing unauthorized hosts and
+## DP: services in servicegroup view
+## DP: Upstream bugreport: http://tracker.nagios.org/view.php?id=456
+
+@DPATCH@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' nagios3-3.4.1~/cgi/status.c nagios3-3.4.1/cgi/status.c
+--- nagios3-3.4.1~/cgi/status.c 2012-02-13 21:40:42.000000000 +0100
++++ nagios3-3.4.1/cgi/status.c 2013-06-26 16:52:37.668132234 +0200
+@@ -2534,6 +2534,10 @@
+ if(temp_host == NULL)
+ continue;
+
++ /* make sure user has rights to view this host */
++ if(is_authorized_for_host(temp_host, ¤t_authdata) == FALSE)
++ continue;
++
+ /* skip this if it isn't a new host... */
+ if(temp_host == last_host)
+ continue;
+@@ -2739,6 +2743,10 @@
+ if(temp_host == NULL)
+ continue;
+
++ /* make sure user has rights to view this host */
++ if(is_authorized_for_host(temp_host, ¤t_authdata) == FALSE)
++ continue;
++
+ /* skip this if it isn't a new host... */
+ if(temp_host == last_host)
+ continue;
+@@ -2918,6 +2926,10 @@
+ if(temp_service == NULL)
+ continue;
+
++ /* make sure user has rights to view this service */
++ if(is_authorized_for_service(temp_service, ¤t_authdata) == FALSE)
++ continue;
++
+ /* find the service status */
+ temp_servicestatus = find_servicestatus(temp_service->host_name, temp_service->description);
+ if(temp_servicestatus == NULL)
+@@ -3270,6 +3282,10 @@
+ if(temp_host == NULL)
+ continue;
+
++ /* make sure user has rights to view this host */
++ if(is_authorized_for_host(temp_host, ¤t_authdata) == FALSE)
++ continue;
++
+ /* get the status of the host */
+ temp_hoststatus = find_hoststatus(temp_host->name);
+ if(temp_hoststatus == NULL)
--- nagios3-3.4.1.orig/debian/patches/99_security_cve_2012_6096.dpatch
+++ nagios3-3.4.1/debian/patches/99_security_cve_2012_6096.dpatch
@@ -0,0 +1,128 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 99_securit_cve_2012_6096.dpatch by Alexander Wirt
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fix overflows in getcgi.c and history.cgi (CVE 2012-6096)
+## DP: Debian Bug #697930
+## DP: http://nagios.svn.sourceforge.net/viewvc/nagios?view=revision&revision=2547
+
+@DPATCH@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' nagios3-3.4.1~/cgi/getcgi.c nagios3-3.4.1/cgi/getcgi.c
+--- nagios3-3.4.1~/cgi/getcgi.c 2011-08-17 09:36:27.000000000 +0200
++++ nagios3-3.4.1/cgi/getcgi.c 2013-01-27 17:10:41.725700070 +0100
+@@ -137,14 +137,15 @@
+ /* check for NULL query string environment variable - 04/28/00 (Ludo Bosmans) */
+ if(getenv("QUERY_STRING") == NULL) {
+ cgiinput = (char *)malloc(1);
+- if(cgiinput == NULL) {
+- printf("getcgivars(): Could not allocate memory for CGI input.\n");
+- exit(1);
+- }
+- cgiinput[0] = '\x0';
++ if(cgiinput != NULL)
++ cgiinput[0] = '\x0';
+ }
+ else
+ cgiinput = strdup(getenv("QUERY_STRING"));
++ if(cgiinput == NULL) {
++ printf("getcgivars(): Could not allocate memory for CGI input.\n");
++ exit(1);
++ }
+ }
+
+ else if(!strcmp(request_method, "POST") || !strcmp(request_method, "PUT")) {
+@@ -220,7 +221,12 @@
+ paircount = 0;
+ nvpair = strtok(cgiinput, "&");
+ while(nvpair) {
+- pairlist[paircount++] = strdup(nvpair);
++ pairlist[paircount] = strdup(nvpair);
++ if( NULL == pairlist[paircount]) {
++ printf("getcgivars(): Could not allocate memory for name-value pair #%d.\n", paircount);
++ exit(1);
++ }
++ paircount++;
+ if(!(paircount % 256)) {
+ pairlist = (char **)realloc(pairlist, (paircount + 256) * sizeof(char **));
+ if(pairlist == NULL) {
+@@ -245,13 +251,29 @@
+ /* get the variable name preceding the equal (=) sign */
+ if((eqpos = strchr(pairlist[i], '=')) != NULL) {
+ *eqpos = '\0';
+- unescape_cgi_input(cgivars[i * 2 + 1] = strdup(eqpos + 1));
++ cgivars[i * 2 + 1] = strdup(eqpos + 1);
++ if( NULL == cgivars[ i * 2 + 1]) {
++ printf("getcgivars(): Could not allocate memory for cgi value #%d.\n", i);
++ exit(1);
++ }
++ unescape_cgi_input(cgivars[i * 2 + 1]);
++ }
++ else {
++ cgivars[i * 2 + 1] = strdup("");
++ if( NULL == cgivars[ i * 2 + 1]) {
++ printf("getcgivars(): Could not allocate memory for empty stringfor variable value #%d.\n", i);
++ exit(1);
++ }
++ unescape_cgi_input(cgivars[i * 2 + 1]);
+ }
+- else
+- unescape_cgi_input(cgivars[i * 2 + 1] = strdup(""));
+
+ /* get the variable value (or name/value of there was no real "pair" in the first place) */
+- unescape_cgi_input(cgivars[i * 2] = strdup(pairlist[i]));
++ cgivars[i * 2] = strdup(pairlist[i]);
++ if( NULL == cgivars[ i * 2]) {
++ printf("getcgivars(): Could not allocate memory for cgi name #%d.\n", i);
++ exit(1);
++ }
++ unescape_cgi_input(cgivars[i * 2]);
+ }
+
+ /* terminate the name-value list */
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' nagios3-3.4.1~/cgi/history.c nagios3-3.4.1/cgi/history.c
+--- nagios3-3.4.1~/cgi/history.c 2011-08-17 09:36:27.000000000 +0200
++++ nagios3-3.4.1/cgi/history.c 2013-01-27 17:10:41.721700070 +0100
+@@ -805,16 +805,22 @@
+ else if(display_type == DISPLAY_HOSTS) {
+
+ if(history_type == HOST_HISTORY || history_type == SERVICE_HISTORY) {
+- sprintf(match1, " HOST ALERT: %s;", host_name);
+- sprintf(match2, " SERVICE ALERT: %s;", host_name);
++ snprintf(match1, sizeof( match1),
++ " HOST ALERT: %s;", host_name);
++ snprintf(match2, sizeof( match2),
++ " SERVICE ALERT: %s;", host_name);
+ }
+ else if(history_type == HOST_FLAPPING_HISTORY || history_type == SERVICE_FLAPPING_HISTORY) {
+- sprintf(match1, " HOST FLAPPING ALERT: %s;", host_name);
+- sprintf(match2, " SERVICE FLAPPING ALERT: %s;", host_name);
++ snprintf(match1, sizeof( match1),
++ " HOST FLAPPING ALERT: %s;", host_name);
++ snprintf(match2, sizeof( match2),
++ " SERVICE FLAPPING ALERT: %s;", host_name);
+ }
+ else if(history_type == HOST_DOWNTIME_HISTORY || history_type == SERVICE_DOWNTIME_HISTORY) {
+- sprintf(match1, " HOST DOWNTIME ALERT: %s;", host_name);
+- sprintf(match2, " SERVICE DOWNTIME ALERT: %s;", host_name);
++ snprintf(match1, sizeof( match1),
++ " HOST DOWNTIME ALERT: %s;", host_name);
++ snprintf(match2, sizeof( match2),
++ " SERVICE DOWNTIME ALERT: %s;", host_name);
+ }
+
+ if(show_all_hosts == TRUE)
+@@ -853,11 +859,11 @@
+ else if(display_type == DISPLAY_SERVICES) {
+
+ if(history_type == SERVICE_HISTORY)
+- sprintf(match1, " SERVICE ALERT: %s;%s;", host_name, svc_description);
++ snprintf(match1, sizeof( match1), " SERVICE ALERT: %s;%s;", host_name, svc_description);
+ else if(history_type == SERVICE_FLAPPING_HISTORY)
+- sprintf(match1, " SERVICE FLAPPING ALERT: %s;%s;", host_name, svc_description);
++ snprintf(match1, sizeof( match1), " SERVICE FLAPPING ALERT: %s;%s;", host_name, svc_description);
+ else if(history_type == SERVICE_DOWNTIME_HISTORY)
+- sprintf(match1, " SERVICE DOWNTIME ALERT: %s;%s;", host_name, svc_description);
++ snprintf(match1, sizeof( match1), " SERVICE DOWNTIME ALERT: %s;%s;", host_name, svc_description);
+
+ if(strstr(temp_buffer, match1) && (history_type == SERVICE_HISTORY || history_type == SERVICE_FLAPPING_HISTORY || history_type == SERVICE_DOWNTIME_HISTORY))
+ display_line = TRUE;
--- nagios3-3.4.1.orig/debian/patches/52_nagios.cfg-debianize.dpatch
+++ nagios3-3.4.1/debian/patches/52_nagios.cfg-debianize.dpatch
@@ -0,0 +1,152 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 52_nagios.cfg-debianize.dpatch by Alexander Wirt
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Debianize nagios.cfg
+
+@DPATCH@
+diff -urNad nagios3-3.2.0~/sample-config/nagios.cfg.in nagios3-3.2.0/sample-config/nagios.cfg.in
+--- nagios3-3.2.0~/sample-config/nagios.cfg.in 2008-12-14 15:52:23.000000000 +0100
++++ nagios3-3.2.0/sample-config/nagios.cfg.in 2009-08-27 07:28:59.000000000 +0200
+@@ -2,10 +2,6 @@
+ #
+ # NAGIOS.CFG - Sample Main Config File for Nagios @VERSION@
+ #
+-# Read the documentation for more information on this configuration
+-# file. I've provided some comments here, but things may not be so
+-# clear without further explanation.
+-#
+ # Last Modified: 12-14-2008
+ #
+ ##############################################################################
+@@ -16,9 +12,19 @@
+ # for historical purposes. This should be the first option specified
+ # in the config file!!!
+
+-log_file=@localstatedir@/nagios.log
++log_file=/var/log/nagios3/nagios.log
+
++# Commands definitions
++cfg_file=/etc/nagios3/commands.cfg
+
++# Debian also defaults to using the check commands defined by the debian
++# nagios-plugins package
++cfg_dir=/etc/nagios-plugins/config
++
++# Debian uses by default a configuration directory where nagios3-common,
++# other packages and the local admin can dump or link configuration
++# files into.
++cfg_dir=/etc/nagios3/conf.d
+
+ # OBJECT CONFIGURATION FILE(S)
+ # These are the object configuration files in which you define hosts,
+@@ -27,13 +33,10 @@
+ # if you wish (as shown below), or keep them all in a single config file.
+
+ # You can specify individual object config files as shown below:
+-cfg_file=@sysconfdir@/objects/commands.cfg
+-cfg_file=@sysconfdir@/objects/contacts.cfg
+-cfg_file=@sysconfdir@/objects/timeperiods.cfg
+-cfg_file=@sysconfdir@/objects/templates.cfg
+-
+-# Definitions for monitoring the local (Linux) host
+-cfg_file=@sysconfdir@/objects/localhost.cfg
++#cfg_file=@sysconfdir@/objects/commands.cfg
++#cfg_file=@sysconfdir@/objects/contacts.cfg
++#cfg_file=@sysconfdir@/objects/timeperiods.cfg
++#cfg_file=@sysconfdir@/objects/templates.cfg
+
+ # Definitions for monitoring a Windows machine
+ #cfg_file=@sysconfdir@/objects/windows.cfg
+@@ -64,7 +67,7 @@
+ # directly) in order to prevent inconsistencies that can occur
+ # when the config files are modified after Nagios starts.
+
+-object_cache_file=@localstatedir@/objects.cache
++object_cache_file=/var/cache/nagios3/objects.cache
+
+
+
+@@ -103,7 +106,7 @@
+ # The contents of the status file are deleted every time Nagios
+ # restarts.
+
+-status_file=@localstatedir@/status.dat
++status_file=/var/cache/nagios3/status.dat
+
+
+
+@@ -140,7 +143,7 @@
+ # you will have to enable this.
+ # Values: 0 = disable commands, 1 = enable commands
+
+-check_external_commands=1
++check_external_commands=0
+
+
+
+@@ -169,6 +172,8 @@
+ # is running as (usually 'nobody'). Permissions should be set at the
+ # directory level instead of on the file, as the file is deleted every
+ # time its contents are processed.
++# Debian Users: In case you didn't read README.Debian yet, _NOW_ is the
++# time to do it.
+
+ command_file=@localstatedir@/rw/nagios.cmd
+
+@@ -198,7 +203,7 @@
+ # is created, used, and deleted throughout the time that Nagios is
+ # running.
+
+-temp_file=@localstatedir@/nagios.tmp
++temp_file=/var/cache/nagios3/nagios.tmp
+
+
+
+@@ -264,7 +269,7 @@
+ # This is the directory where archived (rotated) log files should be
+ # placed (assuming you've chosen to do log rotation).
+
+-log_archive_path=@localstatedir@/archives
++log_archive_path=/var/log/nagios3/archives
+
+
+
+@@ -1084,7 +1089,7 @@
+ # strict-iso8601 (YYYY-MM-DDTHH:MM:SS)
+ #
+
+-date_format=us
++date_format=iso8601
+
+
+
+@@ -1114,7 +1119,7 @@
+ # embedded Perl interpreter) is located. If you didn't compile
+ # Nagios with embedded Perl support, this option has no effect.
+
+-p1_file=@bindir@/p1.pl
++p1_file=/usr/lib/nagios3/p1.pl
+
+
+
+@@ -1198,8 +1203,8 @@
+ # using the $ADMINEMAIL$ and $ADMINPAGER$ macros in your notification
+ # commands.
+
+-admin_email=@nagios_user@@localhost
+-admin_pager=page@nagios_user@@localhost
++admin_email=root@localhost
++admin_pager=pageroot@localhost
+
+
+
+@@ -1306,7 +1311,7 @@
+ # DEBUG FILE
+ # This option determines where Nagios should write debugging information.
+
+-debug_file=@localstatedir@/nagios.debug
++debug_file=/var/log/nagios3/nagios.debug
+
+
+
--- nagios3-3.4.1.orig/debian/patches/60_fix_p1.pl_patch_mini_epn.dpatch
+++ nagios3-3.4.1/debian/patches/60_fix_p1.pl_patch_mini_epn.dpatch
@@ -0,0 +1,19 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 60_fix_p1.pl_patch_mini_epn.dpatch by Alexander Wirt
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Call p1.pl from /usr/lib/nagios3
+
+@DPATCH@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' pkg-nagios3~/contrib/mini_epn.c pkg-nagios3/contrib/mini_epn.c
+--- pkg-nagios3~/contrib/mini_epn.c 2012-05-07 20:43:10.000000000 +0200
++++ pkg-nagios3/contrib/mini_epn.c 2012-05-07 22:06:49.835073313 +0200
+@@ -19,7 +19,7 @@
+ #endif
+ */
+
+- char *embedding[] = { "", "p1.pl" };
++ char *embedding[] = { "", "/usr/lib/nagios3/p1.pl" };
+ char *plugin_output ;
+ char fname[MAX_INPUT_CHARS];
+ char *args[] = {"", "0", "", "", NULL };
--- nagios3-3.4.1.orig/debian/patches/50_cgi.cfg-debianize.dpatch
+++ nagios3-3.4.1/debian/patches/50_cgi.cfg-debianize.dpatch
@@ -0,0 +1,42 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## cfg.cfg-debianize.dpatch by Alexander Wirt
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Debianize cgi.cfg
+
+@DPATCH@
+diff -urNad nagios3-3.0.6~/sample-config/cgi.cfg.in nagios3-3.0.6/sample-config/cgi.cfg.in
+--- nagios3-3.0.6~/sample-config/cgi.cfg.in 2008-11-30 19:13:11.000000000 +0100
++++ nagios3-3.0.6/sample-config/cgi.cfg.in 2009-03-12 07:39:50.000000000 +0100
+@@ -43,7 +43,7 @@
+ # Values: 0 = disables context-sensitive help
+ # 1 = enables context-sensitive help
+
+-show_context_help=0
++show_context_help=1
+
+
+
+@@ -55,7 +55,22 @@
+
+ use_pending_states=1
+
++# NAGIOS PROCESS CHECK COMMAND
++# This is the full path and filename of the program used to check
++# the status of the Nagios process. It is used only by the CGIs
++# and is completely optional. However, if you don't use it, you'll
++# see warning messages in the CGIs about the Nagios process
++# not running and you won't be able to execute any commands from
++# the web interface. The program should follow the same rules
++# as plugins; the return codes are the same as for the plugins,
++# it should have timeout protection, it should output something
++# to STDIO, etc.
++#
++# Note: The command line for the check_nagios plugin below may
++# have to be tweaked a bit, as different versions of the plugin
++# use different command line arguments/syntaxes.
+
++nagios_check_command=/usr/lib/nagios/plugins/check_nagios /var/cache/nagios3/status.dat 5 '/usr/sbin/nagios3'
+
+
+ # AUTHENTICATION USAGE
--- nagios3-3.4.1.orig/debian/patches/70_fix_eventhandler_paths.dpatch
+++ nagios3-3.4.1/debian/patches/70_fix_eventhandler_paths.dpatch
@@ -0,0 +1,125 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 70_fix_eventhandler_paths.dpatch by Alexander Wirt
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fixes paths for all contributed eventhandlers
+
+@DPATCH@
+diff -urNad nagios3-3.0.5~/contrib/eventhandlers/disable_active_service_checks nagios3-3.0.5/contrib/eventhandlers/disable_active_service_checks
+--- nagios3-3.0.5~/contrib/eventhandlers/disable_active_service_checks 2008-10-15 18:12:09.000000000 +0200
++++ nagios3-3.0.5/contrib/eventhandlers/disable_active_service_checks 2008-11-28 21:48:00.000000000 +0100
+@@ -16,7 +16,7 @@
+
+ printfcmd="/usr/bin/printf"
+
+-CommandFile="/usr/local/nagios/var/rw/nagios.cmd"
++CommandFile="/var/lib/nagios3/rw/nagios.cmd"
+
+ # get the current date/time in seconds since UNIX epoch
+ datetime=`date +%s`
+diff -urNad nagios3-3.0.5~/contrib/eventhandlers/disable_notifications nagios3-3.0.5/contrib/eventhandlers/disable_notifications
+--- nagios3-3.0.5~/contrib/eventhandlers/disable_notifications 2008-10-15 18:12:09.000000000 +0200
++++ nagios3-3.0.5/contrib/eventhandlers/disable_notifications 2008-11-28 21:48:35.000000000 +0100
+@@ -14,7 +14,7 @@
+
+ printfcmd="/usr/bin/printf"
+
+-CommandFile="/usr/local/nagios/var/rw/nagios.cmd"
++CommandFile="/var/lib/nagios3/rw/nagios.cmd"
+
+ # get the current date/time in seconds since UNIX epoch
+ datetime=`date +%s`
+diff -urNad nagios3-3.0.5~/contrib/eventhandlers/distributed-monitoring/obsessive_svc_handler nagios3-3.0.5/contrib/eventhandlers/distributed-monitoring/obsessive_svc_handler
+--- nagios3-3.0.5~/contrib/eventhandlers/distributed-monitoring/obsessive_svc_handler 2002-02-26 05:03:37.000000000 +0100
++++ nagios3-3.0.5/contrib/eventhandlers/distributed-monitoring/obsessive_svc_handler 2008-11-28 21:47:11.000000000 +0100
+@@ -21,7 +21,7 @@
+ #
+
+ # Location of the submit_check_result_via_nsca script
+-SubmitCmd="/usr/local/nagios/libexec/eventhandlers/submit_check_result_via_nsca"
++SubmitCmd="/usr/share/nagios3/plugins/eventhandlers/distributed-monitoring/submit_check_result_via_nsca"
+
+ # Convert the state string to the corresponding return code
+ return_code=-1
+diff -urNad nagios3-3.0.5~/contrib/eventhandlers/distributed-monitoring/submit_check_result_via_nsca nagios3-3.0.5/contrib/eventhandlers/distributed-monitoring/submit_check_result_via_nsca
+--- nagios3-3.0.5~/contrib/eventhandlers/distributed-monitoring/submit_check_result_via_nsca 2008-10-15 18:12:09.000000000 +0200
++++ nagios3-3.0.5/contrib/eventhandlers/distributed-monitoring/submit_check_result_via_nsca 2008-11-28 21:50:14.000000000 +0100
+@@ -28,8 +28,8 @@
+
+ printfcmd="/usr/bin/printf"
+
+-NscaBin="/usr/local/nagios/libexec/send_nsca"
+-NscaCfg="/usr/local/nagios/etc/send_nsca.cfg"
++NscaBin="/usr/sbin/send_nsca"
++NscaCfg="/etc/send_nsca.cfg"
+ NagiosHost="nagioshost"
+
+ # Fire the data off to the NSCA daemon using the send_nsca script
+diff -urNad nagios3-3.0.5~/contrib/eventhandlers/enable_active_service_checks nagios3-3.0.5/contrib/eventhandlers/enable_active_service_checks
+--- nagios3-3.0.5~/contrib/eventhandlers/enable_active_service_checks 2008-10-15 18:12:09.000000000 +0200
++++ nagios3-3.0.5/contrib/eventhandlers/enable_active_service_checks 2008-11-28 21:48:52.000000000 +0100
+@@ -16,7 +16,7 @@
+
+ printfcmd="/usr/bin/printf"
+
+-CommandFile="/usr/local/nagios/var/rw/nagios.cmd"
++CommandFile="/var/lib/nagios3/rw/nagios.cmd"
+
+ # get the current date/time in seconds since UNIX epoch
+ datetime=`date +%s`
+diff -urNad nagios3-3.0.5~/contrib/eventhandlers/enable_notifications nagios3-3.0.5/contrib/eventhandlers/enable_notifications
+--- nagios3-3.0.5~/contrib/eventhandlers/enable_notifications 2008-10-15 18:12:09.000000000 +0200
++++ nagios3-3.0.5/contrib/eventhandlers/enable_notifications 2008-11-28 21:49:40.000000000 +0100
+@@ -14,7 +14,7 @@
+
+ printfcmd="/usr/bin/printf"
+
+-CommandFile="/usr/local/nagios/var/rw/nagios.cmd"
++CommandFile="/var/lib/nagios3/rw/nagios.cmd"
+
+ # get the current date/time in seconds since UNIX epoch
+ datetime=`date +%s`
+diff -urNad nagios3-3.0.5~/contrib/eventhandlers/redundancy-scenario1/handle-master-host-event nagios3-3.0.5/contrib/eventhandlers/redundancy-scenario1/handle-master-host-event
+--- nagios3-3.0.5~/contrib/eventhandlers/redundancy-scenario1/handle-master-host-event 2004-02-20 05:37:01.000000000 +0100
++++ nagios3-3.0.5/contrib/eventhandlers/redundancy-scenario1/handle-master-host-event 2008-11-28 21:47:11.000000000 +0100
+@@ -10,10 +10,10 @@
+
+ # Location of the echo and mail commands
+ echocmd="/bin/echo"
+-mailcmd="/bin/mail"
++mailcmd="/usr/bin/mail"
+
+ # Location of the event handlers
+-eventhandlerdir="/usr/local/nagios/libexec/eventhandlers"
++eventhandlerdir="/usr/share/nagios3/plugins/eventhandlers"
+
+
+ # Only take action on hard host states...
+diff -urNad nagios3-3.0.5~/contrib/eventhandlers/redundancy-scenario1/handle-master-proc-event nagios3-3.0.5/contrib/eventhandlers/redundancy-scenario1/handle-master-proc-event
+--- nagios3-3.0.5~/contrib/eventhandlers/redundancy-scenario1/handle-master-proc-event 2006-05-30 18:38:01.000000000 +0200
++++ nagios3-3.0.5/contrib/eventhandlers/redundancy-scenario1/handle-master-proc-event 2008-11-28 21:47:11.000000000 +0100
+@@ -10,10 +10,10 @@
+
+ # Location of the echo and mail commands
+ echocmd="/bin/echo"
+-mailcmd="/bin/mail"
++mailcmd="/usr/bin/mail"
+
+ # Location of the event handlers
+-eventhandlerdir="/usr/local/nagios/libexec/eventhandlers"
++eventhandlerdir="/usr/share/nagios3/plugins/eventhandlers"
+
+
+ # Only take action on hard service states...
+diff -urNad nagios3-3.0.5~/contrib/eventhandlers/submit_check_result nagios3-3.0.5/contrib/eventhandlers/submit_check_result
+--- nagios3-3.0.5~/contrib/eventhandlers/submit_check_result 2002-02-26 05:03:37.000000000 +0100
++++ nagios3-3.0.5/contrib/eventhandlers/submit_check_result 2008-11-28 21:47:11.000000000 +0100
+@@ -24,7 +24,7 @@
+
+ echocmd="/bin/echo"
+
+-CommandFile="/usr/local/nagios/var/rw/nagios.cmd"
++CommandFile="/var/lib/nagios3/rw/nagios.cmd"
+
+ # get the current date/time in seconds since UNIX epoch
+ datetime=`date +%s`
--- nagios3-3.4.1.orig/debian/patches/00list
+++ nagios3-3.4.1/debian/patches/00list
@@ -0,0 +1,13 @@
+10_p1_pl_shebang.dpatch
+40_fix_spurious_dollar_signs_added_to_command_lines.dpatch
+50_cgi.cfg-debianize.dpatch
+51_commands.cfg-debianize.dpatch
+52_nagios.cfg-debianize.dpatch
+55_strip_logarchivepath.dpatch
+60_fix_p1.pl_patch_mini_epn.dpatch
+70_fix_eventhandler_paths.dpatch
+99_remove_update-check.dpatch
+99_fix_php_warning.dpatch
+99_security_status_cgi_servicegroup.dpatch
+99_security_cve_2012_6096.dpatch
+999_daemon-downtime-Handle-loading-effective-downtime-fr.dpatch
--- nagios3-3.4.1.orig/debian/patches/95_security_statuswml_SA35543.dpatch
+++ nagios3-3.4.1/debian/patches/95_security_statuswml_SA35543.dpatch
@@ -0,0 +1,59 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 95_security_statuswml_SA35543.dpatch by Alexander Wirt
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+@DPATCH@
+diff -urNad nagios3-3.0.6~/cgi/statuswml.c nagios3-3.0.6/cgi/statuswml.c
+--- nagios3-3.0.6~/cgi/statuswml.c 2008-11-30 19:13:11.000000000 +0100
++++ nagios3-3.0.6/cgi/statuswml.c 2009-06-29 13:54:28.000000000 +0200
+@@ -67,6 +67,8 @@
+ void document_header(void);
+ void document_footer(void);
+ int process_cgivars(void);
++int validate_arguments(void);
++int is_valid_hostip(char *hostip);
+
+ int display_type=DISPLAY_INDEX;
+ int hostgroup_style=DISPLAY_HOSTGROUP_SUMMARY;
+@@ -108,6 +110,13 @@
+
+ document_header();
+
++ /* validate arguments in URL */
++ result=validate_arguments();
++ if(result==ERROR){
++ document_footer();
++ return ERROR;
++ }
++
+ /* read the CGI configuration file */
+ result=read_cgi_config_file(get_cgi_config_location());
+ if(result==ERROR){
+@@ -334,7 +343,25 @@
+ return error;
+ }
+
++int validate_arguments(void){
++ int result=OK;
++ if((strcmp(ping_address,"")) && !is_valid_hostip(ping_address)) {
++ printf("Invalid host name/ip
\n");
++ result=ERROR;
++ }
++ if(strcmp(traceroute_address,"") && !is_valid_hostip(traceroute_address)){
++ printf("Invalid host name/ip
\n");
++ result=ERROR;
++ }
++ return result;
++ }
+
++int is_valid_hostip(char *hostip) {
++ char *valid_domain_chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-";
++ if(strcmp(hostip,"") && strlen(hostip)==strspn(hostip,valid_domain_chars) && hostip[0] != '-' && hostip[strlen(hostip)-1] != '-')
++ return TRUE;
++ return FALSE;
++ }
+
+ /* main intro screen */
+ void display_index(void){
--- nagios3-3.4.1.orig/debian/patches/80_fix_encoding_trends.cgi.dpatch
+++ nagios3-3.4.1/debian/patches/80_fix_encoding_trends.cgi.dpatch
@@ -0,0 +1,20 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 80_fix_encoding_trends.cgi.dpatch by Alexander Wirt
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+@DPATCH@
+diff -urNad trunk~/cgi/getcgi.c trunk/cgi/getcgi.c
+--- trunk~/cgi/getcgi.c 2006-05-15 18:59:24.000000000 +0200
++++ trunk/cgi/getcgi.c 2008-09-23 09:19:04.000000000 +0200
+@@ -96,6 +96,9 @@
+ break;
+ else if(input[x]=='%'){
+ input[y]=hex_to_char(&input[x+1]);
++ if (input[y]=='+'){
++ input[y]=' ';
++ }
+ x+=2;
+ }
+ else
--- nagios3-3.4.1.orig/debian/patches/10_p1_pl_shebang.dpatch
+++ nagios3-3.4.1/debian/patches/10_p1_pl_shebang.dpatch
@@ -0,0 +1,18 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 10_p1_pl_shebang.dpatch by Marc Haber
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fix shebang of perl interpreter
+
+@DPATCH@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' pkg-nagios3~/p1.pl pkg-nagios3/p1.pl
+--- pkg-nagios3~/p1.pl 2012-05-07 20:43:10.000000000 +0200
++++ pkg-nagios3/p1.pl 2012-05-07 20:48:31.118953001 +0200
+@@ -1,4 +1,6 @@
+- package Embed::Persistent;
++#!/usr/bin/perl
++
++package Embed::Persistent;
+
+ # p1.pl for Nagios
+
--- nagios3-3.4.1.orig/debian/patches/99_fix_php_warning.dpatch
+++ nagios3-3.4.1/debian/patches/99_fix_php_warning.dpatch
@@ -0,0 +1,60 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 99_fix_php_warning.dpatch by Alexander Wirt
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+@DPATCH@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' pkg-nagios3~/html/index.php pkg-nagios3/html/index.php
+--- pkg-nagios3~/html/index.php 2012-05-07 20:43:10.000000000 +0200
++++ pkg-nagios3/html/index.php 2012-06-30 10:38:21.107241485 +0200
+@@ -8,6 +8,7 @@
+
+
+
+\ No newline at end of file
++?>
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' pkg-nagios3~/html/rss-newsfeed.php pkg-nagios3/html/rss-newsfeed.php
+--- pkg-nagios3~/html/rss-newsfeed.php 2012-05-07 20:43:10.000000000 +0200
++++ pkg-nagios3/html/rss-newsfeed.php 2012-06-30 10:37:58.347240902 +0200
+@@ -1,5 +1,4 @@
+
+\ No newline at end of file
++?>
--- nagios3-3.4.1.orig/debian/patches/999_daemon-downtime-Handle-loading-effective-downtime-fr.dpatch
+++ nagios3-3.4.1/debian/patches/999_daemon-downtime-Handle-loading-effective-downtime-fr.dpatch
@@ -0,0 +1,74 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## daemon downtime: Handle loading effective downtime from retention
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: From 9f18395268dda948265722984097735d48d72197 Mon Sep 17 00:00:00 2001
+## DP: From: Andreas Ericsson
+## DP: Date: Wed, 6 Jun 2012 09:38:06 +0000
+## DP: Subject: [PATCH] daemon downtime: Handle loading effective downtime from
+## DP: retention
+## DP:
+## DP: Without this patch, Nagios would forget about downtime that starts
+## DP: before the core is stopped and ends after the core is restarted.
+## DP:
+## DP: According to testers, the original problem with notifications being
+## DP: re-sent does not crop up again when this patch is applied.
+## DP:
+## DP: Tested-by: Mark Elsen
+## DP: Tested-by: Phil Randal
+## DP: Patched-by: Carlos Velasco
+## DP: Signed-off-by: Andreas Ericsson
+## DP:
+## DP: git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@1953 5f96b256-904b-4d8d-8c98-d829582c6739
+## DP: ---
+## DP: THANKS | 1 +
+## DP: common/downtime.c | 31 +++++++++++++++++++++++++++----
+## DP: 2 files changed, 28 insertions(+), 4 deletions(-)
+
+@DPATCH@
+diff --git a/common/downtime.c b/common/downtime.c
+index 09a0333..0193c50 100644
+--- a/common/downtime.c
++++ b/common/downtime.c
+@@ -401,11 +401,34 @@ int handle_scheduled_downtime(scheduled_downtime *temp_downtime) {
+ }
+
+ /* if downtime handler gets triggerd in between then there seems to be a restart */
+- /* Don't do anything just return */
+- time( ¤t_time);
+- if( temp_downtime->start_time < current_time && current_time < temp_downtime->end_time && temp_downtime->is_in_effect == TRUE)
+- return OK;
++ time(¤t_time);
++ if(temp_downtime->start_time < current_time && current_time < temp_downtime->end_time && temp_downtime->is_in_effect == TRUE) {
++#ifdef USE_EVENT_BROKER
++ /* send data to event broker */
++ broker_downtime_data(NEBTYPE_DOWNTIME_START, NEBFLAG_NONE, NEBATTR_NONE, temp_downtime->type, temp_downtime->host_name, temp_downtime->service_description, temp_downtime->entry_time, temp_downtime->author, temp_downtime->comment, temp_downtime->start_time, temp_downtime->end_time, temp_downtime->fixed, temp_downtime->triggered_by, temp_downtime->duration, temp_downtime->downtime_id, NULL);
++#endif
++
++ /* increment the downtime depth variable */
++ if(temp_downtime->type == HOST_DOWNTIME) {
++ hst->scheduled_downtime_depth++;
++ update_host_status(hst, FALSE);
++ }
++ else {
++ svc->scheduled_downtime_depth++;
++ update_service_status(svc, FALSE);
++ }
+
++ /* schedule an event */
++ if(temp_downtime->fixed == FALSE)
++ event_time = (time_t)((unsigned long)time(NULL) + temp_downtime->duration);
++ else
++ event_time = temp_downtime->end_time;
++ if((new_downtime_id = (unsigned long *)malloc(sizeof(unsigned long)))) {
++ *new_downtime_id = temp_downtime->downtime_id;
++ schedule_new_event(EVENT_SCHEDULED_DOWNTIME, TRUE, event_time, FALSE, 0, NULL, FALSE, (void *)new_downtime_id, NULL, 0);
++ }
++ return OK;
++ }
+
+ /* have we come to the end of the scheduled downtime? */
+ if(temp_downtime->is_in_effect == TRUE) {
+--
+1.8.2
+