From 746bfc7e2fd0c246b880b529d02af264a1744e1d Mon Sep 17 00:00:00 2001 From: Jonathan Steel Date: Tue, 13 Jun 2017 14:15:42 +0100 Subject: [PATCH] gcc7 fix and run with --daemon journalctl was very noisy without --daemon --- .SRCINFO | 8 +- PKGBUILD | 16 +++- gcc7.patch | 211 +++++++++++++++++++++++++++++++++++++++++++++++++ naemon.service | 6 +- 4 files changed, 232 insertions(+), 9 deletions(-) create mode 100644 gcc7.patch diff --git a/.SRCINFO b/.SRCINFO index a2da202..d2c1bd8 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,9 +1,9 @@ # Generated by mksrcinfo v8 -# Tue May 16 07:43:28 UTC 2017 +# Tue Jun 13 13:14:33 UTC 2017 pkgbase = naemon pkgdesc = System and network monitoring application pkgver = 1.0.6 - pkgrel = 3 + pkgrel = 4 url = http://naemon.org install = naemon.install arch = i686 @@ -26,9 +26,11 @@ pkgbase = naemon backup = etc/naemon/naemon.cfg backup = etc/naemon/resource.cfg source = http://labs.consol.de/naemon/release/v1.0.6/src/naemon-1.0.6.tar.gz + source = gcc7.patch source = naemon.service md5sums = 6c9b95a737a8f232e114f4cff200ff92 - md5sums = d6a77534e612e8f65ff3360336faec77 + md5sums = 4a6d8f9b39335dfe3348a1a20df10dfd + md5sums = 29f1d11c1a7f4f1515b7993c540dabe8 pkgname = naemon diff --git a/PKGBUILD b/PKGBUILD index 1511b42..4ade4bd 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -2,7 +2,7 @@ pkgname=naemon pkgver=1.0.6 -pkgrel=3 +pkgrel=4 pkgdesc="System and network monitoring application" arch=('i686' 'x86_64') url="http://naemon.org" @@ -16,14 +16,22 @@ provides=('naemon-core' 'naemon-livestatus') conflicts=('naemon-core' 'naemon-livestatus') replaces=('naemon-core' 'naemon-livestatus') source=(http://labs.consol.de/naemon/release/v$pkgver/src/$pkgname-$pkgver.tar.gz + gcc7.patch $pkgname.service) md5sums=('6c9b95a737a8f232e114f4cff200ff92' - 'd6a77534e612e8f65ff3360336faec77') + '4a6d8f9b39335dfe3348a1a20df10dfd' + '29f1d11c1a7f4f1515b7993c540dabe8') backup=('etc/logrotate.d/naemon' 'etc/naemon/naemon.cfg' 'etc/naemon/resource.cfg') install=$pkgname.install +prepare() { + cd $pkgname-$pkgver/naemon-core + + patch -Np1 -i "$srcdir"/gcc7.patch +} + build() { cd $pkgname-$pkgver @@ -44,7 +52,7 @@ build() { --with-logrotatedir="/etc/logrotate.d" \ --with-naemon-user="naemon" \ --with-naemon-group="naemon" \ - --with-lockfile="/run/naemon.pid" \ + --with-lockfile="/run/naemon/naemon.pid" \ --with-thruk-user="http" \ --with-thruk-group="naemon" \ --with-thruk-libs="/usr/lib/naemon/perl5" \ @@ -76,6 +84,8 @@ package() { install -Dm644 "$srcdir"/$pkgname.service \ "$pkgdir"/usr/lib/systemd/system/$pkgname.service + install -Dm644 naemon-core/naemon.tmpfiles.conf \ + "$pkgdir"/usr/lib/tmpfiles.d/naemon.conf # Move sample config files mv "$pkgdir"/etc/naemon/conf.d "$pkgdir"/etc/naemon/examples diff --git a/gcc7.patch b/gcc7.patch new file mode 100644 index 0000000..113140e --- /dev/null +++ b/gcc7.patch @@ -0,0 +1,211 @@ +From 0390d827eab62ad2d84f0d6db8278d683659c0ba Mon Sep 17 00:00:00 2001 +From: Oleg Pereverzev +Date: Mon, 12 Jun 2017 23:20:59 +0300 +Subject: [PATCH] Support for GCC 7 + +--- + lib/runcmd.c | 3 +++ + lib/snprintf.c | 6 ++++++ + src/naemon/checks.c | 12 +++++++++++- + src/naemon/configuration.c | 13 +++++++++++-- + src/naemon/macros.c | 18 ++++++++++++++++++ + src/naemon/xodtemplate.c | 11 ++++++++++- + 6 files changed, 59 insertions(+), 4 deletions(-) + +diff --git a/lib/runcmd.c b/lib/runcmd.c +index eb6668fe..4e55fbd7 100644 +--- a/lib/runcmd.c ++++ b/lib/runcmd.c +@@ -199,6 +199,9 @@ int runcmd_cmd2strv(const char *str, int *out_argc, char **out_argv) + set_state(STATE_INSQ | STATE_INARG); + continue; + } ++#if __GNUC__ >= 7 ++ __attribute__((fallthrough)); ++#endif + case '"': + if (have_state(STATE_INSQ)) + break; +diff --git a/lib/snprintf.c b/lib/snprintf.c +index 49bf8962..80b69dbf 100644 +--- a/lib/snprintf.c ++++ b/lib/snprintf.c +@@ -493,6 +493,9 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args + break; + case 'X': + cnk->flags |= DP_F_UP; ++#if __GNUC__ >= 7 ++ __attribute__((fallthrough)); ++#endif + case 'x': + cnk->type = CNK_HEX; + cnk->flags |= DP_F_UNSIGNED; +@@ -503,6 +506,9 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args + case 'G': + case 'F': + cnk->flags |= DP_F_UP; ++#if __GNUC__ >= 7 ++ __attribute__((fallthrough)); ++#endif + case 'a': + /* hex float not supported yet */ + case 'e': +diff --git a/src/naemon/checks.c b/src/naemon/checks.c +index 97bd9f73..91d83ef1 100644 +--- a/src/naemon/checks.c ++++ b/src/naemon/checks.c +@@ -207,6 +207,9 @@ int process_check_result_queue(char *dirname) + char *temp_buffer = NULL; + int result = OK, check_result_files = 0; + time_t start; ++#if __GNUC__ >= 7 ++ unsigned int writesize; ++#endif + + /* make sure we have what we need */ + if (dirname == NULL) { +@@ -240,9 +243,16 @@ int process_check_result_queue(char *dirname) + } + + /* create /path/to/file */ ++ ++#if __GNUC__ >= 7 ++ writesize = snprintf(file, sizeof(file), "%s/%s", dirname, dirfile->d_name); ++ if (writesize < (strlen(dirname) + strlen(dirfile->d_name) + 2)) ++ nm_log(NSLOG_RUNTIME_WARNING, "Warning: truncated path to file in check result queue directory '%s'", dirfile->d_name); ++#else + snprintf(file, sizeof(file), "%s/%s", dirname, dirfile->d_name); ++#endif + file[sizeof(file) - 1] = '\x0'; +- ++ + /* process this if it's a check result file... */ + x = strlen(dirfile->d_name); + if (x == 7 && dirfile->d_name[0] == 'c') { +diff --git a/src/naemon/configuration.c b/src/naemon/configuration.c +index a2a8d3ed..c4dc97dd 100644 +--- a/src/naemon/configuration.c ++++ b/src/naemon/configuration.c +@@ -59,6 +59,9 @@ read_config_file(const char *main_config_file, nagios_macros *mac) + char *argptr = NULL; + mmapfile *thefile = NULL; + DIR *tmpdir = NULL; ++#if __GNUC__ >= 7 ++ unsigned int writesize; ++#endif + + /* open the config file for reading */ + if ((thefile = mmap_fopen(main_config_file)) == NULL) { +@@ -1021,10 +1024,16 @@ read_config_file(const char *main_config_file, nagios_macros *mac) + if (strcmp(dirfile->d_name + strlen(dirfile->d_name) - 4, ".cfg")) + continue; + +- /* create /path/to/file */ ++ /* create /path/to/file */ ++#if __GNUC__ >= 7 ++ writesize = snprintf(file, sizeof(file), "%s/%s", include_dir, dirfile->d_name); ++ if (writesize < (strlen(include_dir) + strlen(dirfile->d_name) + 2)) ++ nm_log(NSLOG_RUNTIME_WARNING, "Warning: truncated path to sub-configuration file '%s'", dirfile->d_name); ++#else + snprintf(file, sizeof(file), "%s/%s", include_dir, dirfile->d_name); ++#endif + file[sizeof(file) - 1] = '\x0'; +- ++ + error |= read_config_file(file, mac); + } + closedir(dirp); +diff --git a/src/naemon/macros.c b/src/naemon/macros.c +index 700bc821..13d817cf 100644 +--- a/src/naemon/macros.c ++++ b/src/naemon/macros.c +@@ -1518,6 +1518,9 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c + /***************/ + case MACRO_HOSTGROUPNAMES: + *free_macro = TRUE; ++#if __GNUC__ >= 7 ++ __attribute__((fallthrough)); ++#endif + case MACRO_HOSTNAME: + case MACRO_HOSTALIAS: + case MACRO_HOSTADDRESS: +@@ -1612,6 +1615,9 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c + /********************/ + case MACRO_HOSTGROUPMEMBERS: + *free_macro = TRUE; ++#if __GNUC__ >= 7 ++ __attribute__((fallthrough)); ++#endif + case MACRO_HOSTGROUPNAME: + case MACRO_HOSTGROUPALIAS: + case MACRO_HOSTGROUPNOTES: +@@ -1640,6 +1646,9 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c + /******************/ + case MACRO_SERVICEGROUPNAMES: + *free_macro = TRUE; ++#if __GNUC__ >= 7 ++ __attribute__((fallthrough)); ++#endif + case MACRO_SERVICEDESC: + case MACRO_SERVICESTATE: + case MACRO_SERVICESTATEID: +@@ -1757,6 +1766,9 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c + case MACRO_SERVICEGROUPNOTESURL: + case MACRO_SERVICEGROUPACTIONURL: + *free_macro = TRUE; ++#if __GNUC__ >= 7 ++ __attribute__((fallthrough)); ++#endif + case MACRO_SERVICEGROUPNAME: + case MACRO_SERVICEGROUPALIAS: + /* a standard servicegroup macro */ +@@ -1781,6 +1793,9 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c + /******************/ + case MACRO_CONTACTGROUPNAMES: + *free_macro = TRUE; ++#if __GNUC__ >= 7 ++ __attribute__((fallthrough)); ++#endif + case MACRO_CONTACTNAME: + case MACRO_CONTACTALIAS: + case MACRO_CONTACTEMAIL: +@@ -1841,6 +1856,9 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c + /***********************/ + case MACRO_CONTACTGROUPMEMBERS: + *free_macro = TRUE; ++#if __GNUC__ >= 7 ++ __attribute__((fallthrough)); ++#endif + case MACRO_CONTACTGROUPNAME: + case MACRO_CONTACTGROUPALIAS: + /* a standard contactgroup macro */ +diff --git a/src/naemon/xodtemplate.c b/src/naemon/xodtemplate.c +index d5fd1cda..225fc40a 100644 +--- a/src/naemon/xodtemplate.c ++++ b/src/naemon/xodtemplate.c +@@ -8443,7 +8443,10 @@ static int xodtemplate_process_config_dir(char *dir_name) + int result = OK; + register int x = 0; + struct stat stat_buf; +- ++#if __GNUC__ >= 7 ++ unsigned int writesize; ++#endif ++ + if (verify_config >= 2) + printf("Processing object config directory '%s'...\n", dir_name); + +@@ -8462,7 +8465,13 @@ static int xodtemplate_process_config_dir(char *dir_name) + continue; + + /* create /path/to/file */ ++#if __GNUC__ >= 7 ++ writesize = snprintf(file, sizeof(file), "%s/%s", dir_name, dirfile->d_name); ++ if (writesize < (strlen(dir_name) + strlen(dirfile->d_name) + 2)) ++ nm_log(NSLOG_RUNTIME_WARNING, "Warning: truncated path to file '%s' in config directory '%s'", dirfile->d_name, dir_name); ++#else + snprintf(file, sizeof(file), "%s/%s", dir_name, dirfile->d_name); ++#endif + file[sizeof(file) - 1] = '\x0'; + + /* process this if it's a non-hidden config file... */ diff --git a/naemon.service b/naemon.service index 6b3edc8..0c3a0da 100644 --- a/naemon.service +++ b/naemon.service @@ -4,10 +4,10 @@ Documentation=http://naemon.org/documentation After=network.target [Service] -Type=simple -PIDFile=/run/naemon.pid +Type=forking +PIDFile=/run/naemon/naemon.pid ExecStartPre=/usr/bin/naemon -vp /etc/naemon/naemon.cfg -ExecStart=/usr/bin/naemon /etc/naemon/naemon.cfg +ExecStart=/usr/bin/naemon --daemon /etc/naemon/naemon.cfg ExecReload=/bin/kill -HUP $MAINPID User=naemon Group=naemon -- 2.41.0