From ae3b0a664652fadb39a6cfbf22c9b67d5ab11f9a Mon Sep 17 00:00:00 2001 From: Mohan Boddu Date: Thu, 1 Aug 2019 12:30:23 -0400 Subject: [PATCH 01/11] Adding package.cfg file Signed-off-by: Mohan Boddu --- package.cfg | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 package.cfg diff --git a/package.cfg b/package.cfg new file mode 100644 index 0000000..7e5a05b --- /dev/null +++ b/package.cfg @@ -0,0 +1,2 @@ +[koji] +targets = epel8 epel8-playground From ce790c9866ebfe24006fb881953f3f178b81af27 Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Wed, 12 Feb 2020 15:32:48 +0100 Subject: [PATCH 02/11] change pid dir from /var/run/nut to /run/nut --- nut-client.tmpfiles | 2 +- nut.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nut-client.tmpfiles b/nut-client.tmpfiles index 8db0516..df35b88 100644 --- a/nut-client.tmpfiles +++ b/nut-client.tmpfiles @@ -1 +1 @@ -D /var/run/nut 0770 root nut - +D /run/nut 0770 root nut - diff --git a/nut.spec b/nut.spec index 7ac1d95..9db44da 100644 --- a/nut.spec +++ b/nut.spec @@ -7,7 +7,7 @@ %global nut_gid 57 %global cgidir /var/www/nut-cgi-bin -%global piddir /var/run/nut +%global piddir /run/nut %global modeldir /usr/sbin # powerman is retired on Fedora, therefore disable it by default %bcond_with powerman From 42618a530332c43ef5d5f07a462c9330511d47cf Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Tue, 2 Jun 2020 20:18:15 +0200 Subject: [PATCH 03/11] nut user needs tty group for wall (#1774591) --- 504.patch | 333 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ nut.spec | 23 ++-- 2 files changed, 348 insertions(+), 8 deletions(-) create mode 100644 504.patch diff --git a/504.patch b/504.patch new file mode 100644 index 0000000..71e1bf4 --- /dev/null +++ b/504.patch @@ -0,0 +1,333 @@ +From da1f5aa699f54e0f6977ab64a3bc2f90a51c3104 Mon Sep 17 00:00:00 2001 +From: Arjen de Korte +Date: Mon, 27 Nov 2017 21:10:13 +0100 +Subject: [PATCH 1/7] Add support for openssl-1.1.0 + +--- + clients/upsclient.c | 4 ++++ + m4/nut_check_libopenssl.m4 | 5 +++-- + server/netssl.c | 4 ++++ + 3 files changed, 11 insertions(+), 2 deletions(-) + +diff --git a/clients/upsclient.c b/clients/upsclient.c +index b90587b00..fc5e7523c 100644 +--- a/clients/upsclient.c ++++ b/clients/upsclient.c +@@ -316,7 +316,11 @@ int upscli_init(int certverify, const char *certpath, + + #ifdef WITH_OPENSSL + ++#if OPENSSL_VERSION_NUMBER < 0x10100000L + SSL_library_init(); ++#else ++ OPENSSL_init_ssl(0, NULL); ++#endif + SSL_load_error_strings(); + + ssl_method = TLSv1_client_method(); +diff --git a/m4/nut_check_libopenssl.m4 b/m4/nut_check_libopenssl.m4 +index 1b875077b..5f29f4a38 100644 +--- a/m4/nut_check_libopenssl.m4 ++++ b/m4/nut_check_libopenssl.m4 +@@ -57,8 +57,9 @@ if test -z "${nut_have_libopenssl_seen}"; then + AC_MSG_RESULT([${LIBS}]) + + dnl check if openssl is usable +- AC_CHECK_HEADERS(openssl/ssl.h, [nut_have_openssl=yes], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT]) +- AC_CHECK_FUNCS(SSL_library_init, [], [nut_have_openssl=no]) ++ AC_CHECK_FUNCS(OPENSSL_init_ssl, [nut_have_openssl=yes], [nut_have_openssl=no]) ++ AC_CHECK_FUNCS(SSL_library_init, [nut_have_openssl=yes], []) ++ AC_CHECK_HEADERS(openssl/ssl.h, [], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT]) + + if test "${nut_have_openssl}" = "yes"; then + nut_with_ssl="yes" +diff --git a/server/netssl.c b/server/netssl.c +index c2f409899..0f9a70acf 100644 +--- a/server/netssl.c ++++ b/server/netssl.c +@@ -388,7 +388,11 @@ void ssl_init(void) + #ifdef WITH_OPENSSL + + SSL_load_error_strings(); ++#if OPENSSL_VERSION_NUMBER < 0x10100000L + SSL_library_init(); ++#else ++ OPENSSL_init_ssl(0, NULL); ++#endif + + if ((ssl_method = TLSv1_server_method()) == NULL) { + ssl_debug(); + +From b15656efb2575647ca0e0b6439b6380373767b8f Mon Sep 17 00:00:00 2001 +From: Arjen de Korte +Date: Tue, 28 Nov 2017 20:00:52 +0100 +Subject: [PATCH 2/7] Allow TLSv1 and higher (not just TLSv1) + +--- + clients/upsclient.c | 30 +++++++++++++++++------------- + server/netssl.c | 26 +++++++++++++++----------- + 2 files changed, 32 insertions(+), 24 deletions(-) + +diff --git a/clients/upsclient.c b/clients/upsclient.c +index fc5e7523c..bd951e854 100644 +--- a/clients/upsclient.c ++++ b/clients/upsclient.c +@@ -299,11 +299,6 @@ int upscli_init(int certverify, const char *certpath, + { + #ifdef WITH_OPENSSL + int ret, ssl_mode = SSL_VERIFY_NONE; +-#if OPENSSL_VERSION_NUMBER >= 0x10000000L +- const SSL_METHOD *ssl_method; +-#else +- SSL_METHOD *ssl_method; +-#endif + #elif defined(WITH_NSS) /* WITH_OPENSSL */ + SECStatus status; + #endif /* WITH_OPENSSL | WITH_NSS */ +@@ -315,26 +310,35 @@ int upscli_init(int certverify, const char *certpath, + } + + #ifdef WITH_OPENSSL ++ ++ SSL_load_error_strings(); + + #if OPENSSL_VERSION_NUMBER < 0x10100000L + SSL_library_init(); ++ ++ ssl_ctx = SSL_CTX_new(SSLv23_client_method()); + #else + OPENSSL_init_ssl(0, NULL); +-#endif +- SSL_load_error_strings(); + +- ssl_method = TLSv1_client_method(); +- +- if (!ssl_method) { +- return 0; +- } ++ ssl_ctx = SSL_CTX_new(TLS_client_method()); ++#endif + +- ssl_ctx = SSL_CTX_new(ssl_method); + if (!ssl_ctx) { + upslogx(LOG_ERR, "Can not initialize SSL context"); + return -1; + } + ++#if OPENSSL_VERSION_NUMBER < 0x10100000L ++ /* set minimum protocol TLSv1 */ ++ SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); ++#else ++ ret = SSL_CTX_set_min_proto_version(ssl_ctx, TLS1_VERSION); ++ if (ret != 1) { ++ upslogx(LOG_ERR, "Can not set minimum protocol to TLSv1"); ++ return -1; ++ } ++#endif ++ + if (!certpath) { + if (certverify == 1) { + upslogx(LOG_ERR, "Can not verify certificate if any is specified"); +diff --git a/server/netssl.c b/server/netssl.c +index 0f9a70acf..98680d25e 100644 +--- a/server/netssl.c ++++ b/server/netssl.c +@@ -371,13 +371,7 @@ void ssl_init(void) + { + #ifdef WITH_NSS + SECStatus status; +-#elif defined(WITH_OPENSSL) +-#if OPENSSL_VERSION_NUMBER >= 0x10000000L +- const SSL_METHOD *ssl_method; +-#else +- SSL_METHOD *ssl_method; +-#endif +-#endif /* WITH_NSS|WITH_OPENSSL */ ++#endif /* WITH_NSS */ + + if (!certfile) { + return; +@@ -388,21 +382,31 @@ void ssl_init(void) + #ifdef WITH_OPENSSL + + SSL_load_error_strings(); ++ + #if OPENSSL_VERSION_NUMBER < 0x10100000L + SSL_library_init(); ++ ++ ssl_ctx = SSL_CTX_new(SSLv23_server_method()); + #else + OPENSSL_init_ssl(0, NULL); ++ ++ ssl_ctx = SSL_CTX_new(TLS_server_method()); + #endif + +- if ((ssl_method = TLSv1_server_method()) == NULL) { ++ if (!ssl_ctx) { + ssl_debug(); +- fatalx(EXIT_FAILURE, "TLSv1_server_method failed"); ++ fatalx(EXIT_FAILURE, "SSL_CTX_new failed"); + } + +- if ((ssl_ctx = SSL_CTX_new(ssl_method)) == NULL) { ++#if OPENSSL_VERSION_NUMBER < 0x10100000L ++ /* set minimum protocol TLSv1 */ ++ SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); ++#else ++ if (SSL_CTX_set_min_proto_version(ssl_ctx, TLS1_VERSION) != 1) { + ssl_debug(); +- fatalx(EXIT_FAILURE, "SSL_CTX_new failed"); ++ fatalx(EXIT_FAILURE, "SSL_CTX_set_min_proto_version(TLS1_VERSION)"); + } ++#endif + + if (SSL_CTX_use_certificate_chain_file(ssl_ctx, certfile) != 1) { + ssl_debug(); + +From 5a8308aef9884017754fb70620c8ded34fa44290 Mon Sep 17 00:00:00 2001 +From: Arjen de Korte +Date: Tue, 28 Nov 2017 22:01:41 +0100 +Subject: [PATCH 3/7] Fix check for empty string + +--- + clients/upssched.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/clients/upssched.c b/clients/upssched.c +index 97b3ed42d..3fdf118ed 100644 +--- a/clients/upssched.c ++++ b/clients/upssched.c +@@ -794,7 +794,7 @@ static void parse_at(const char *ntype, const char *un, const char *cmd, + } + + if (!strcmp(cmd, "EXECUTE")) { +- if (ca1 == '\0') { ++ if (ca1[0] == '\0') { + upslogx(LOG_ERR, "Empty EXECUTE command argument"); + return; + } + +From 5ecfb0ffe3d89a5116dd287ff2c3f60de67ecbb9 Mon Sep 17 00:00:00 2001 +From: Arjen de Korte +Date: Fri, 1 Dec 2017 12:24:00 +0100 +Subject: [PATCH 4/7] Report TLS handshake in debug mode + +--- + clients/upsclient.c | 2 +- + server/netssl.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/clients/upsclient.c b/clients/upsclient.c +index bd951e854..b7dd8f424 100644 +--- a/clients/upsclient.c ++++ b/clients/upsclient.c +@@ -745,7 +745,7 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert) + switch(res) + { + case 1: +- upsdebugx(3, "SSL connected"); ++ upsdebugx(3, "SSL connected (%s)", SSL_get_version(ups->ssl)); + break; + case 0: + upslog_with_errno(1, "SSL_connect do not accept handshake."); +diff --git a/server/netssl.c b/server/netssl.c +index 98680d25e..6ae13e8d3 100644 +--- a/server/netssl.c ++++ b/server/netssl.c +@@ -275,7 +275,7 @@ void net_starttls(nut_ctype_t *client, int numarg, const char **arg) + { + case 1: + client->ssl_connected = 1; +- upsdebugx(3, "SSL connected"); ++ upsdebugx(3, "SSL connected (%s)", SSL_get_version(client->ssl)); + break; + + case 0: + +From ab0c8b41c0530d3706e4997257939026cfd29ccc Mon Sep 17 00:00:00 2001 +From: Arjen de Korte +Date: Sun, 24 Feb 2019 18:31:21 +0100 +Subject: [PATCH 5/7] Update nut_check_libopenssl.m4 + +--- + m4/nut_check_libopenssl.m4 | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/m4/nut_check_libopenssl.m4 b/m4/nut_check_libopenssl.m4 +index 5f29f4a38..7eb401cd9 100644 +--- a/m4/nut_check_libopenssl.m4 ++++ b/m4/nut_check_libopenssl.m4 +@@ -57,9 +57,8 @@ if test -z "${nut_have_libopenssl_seen}"; then + AC_MSG_RESULT([${LIBS}]) + + dnl check if openssl is usable +- AC_CHECK_FUNCS(OPENSSL_init_ssl, [nut_have_openssl=yes], [nut_have_openssl=no]) +- AC_CHECK_FUNCS(SSL_library_init, [nut_have_openssl=yes], []) +- AC_CHECK_HEADERS(openssl/ssl.h, [], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT]) ++ AC_CHECK_HEADERS(openssl/ssl.h, [nut_have_openssl=yes], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT]) ++ AC_CHECK_FUNCS(SSL_CTX_new, [], [nut_have_openssl=no]) + + if test "${nut_have_openssl}" = "yes"; then + nut_with_ssl="yes" + +From 1dc34a5da7308f0f85537a6761fefb3ff3098863 Mon Sep 17 00:00:00 2001 +From: Arjen de Korte +Date: Sun, 24 Feb 2019 18:34:53 +0100 +Subject: [PATCH 6/7] Update upsclient.c + +--- + clients/upsclient.c | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +diff --git a/clients/upsclient.c b/clients/upsclient.c +index b7dd8f424..541664f36 100644 +--- a/clients/upsclient.c ++++ b/clients/upsclient.c +@@ -311,15 +311,12 @@ int upscli_init(int certverify, const char *certpath, + + #ifdef WITH_OPENSSL + +- SSL_load_error_strings(); +- + #if OPENSSL_VERSION_NUMBER < 0x10100000L ++ SSL_load_error_strings(); + SSL_library_init(); + + ssl_ctx = SSL_CTX_new(SSLv23_client_method()); + #else +- OPENSSL_init_ssl(0, NULL); +- + ssl_ctx = SSL_CTX_new(TLS_client_method()); + #endif + + +From 108c31c9b170da2ee34a25fd373d21837d4d10a3 Mon Sep 17 00:00:00 2001 +From: Arjen de Korte +Date: Sun, 24 Feb 2019 18:37:42 +0100 +Subject: [PATCH 7/7] Update netssl.c + +--- + server/netssl.c | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +diff --git a/server/netssl.c b/server/netssl.c +index 6ae13e8d3..cf9419edf 100644 +--- a/server/netssl.c ++++ b/server/netssl.c +@@ -381,15 +381,12 @@ void ssl_init(void) + + #ifdef WITH_OPENSSL + +- SSL_load_error_strings(); +- + #if OPENSSL_VERSION_NUMBER < 0x10100000L ++ SSL_load_error_strings(); + SSL_library_init(); + + ssl_ctx = SSL_CTX_new(SSLv23_server_method()); + #else +- OPENSSL_init_ssl(0, NULL); +- + ssl_ctx = SSL_CTX_new(TLS_server_method()); + #endif + diff --git a/nut.spec b/nut.spec index 9db44da..3c5491d 100644 --- a/nut.spec +++ b/nut.spec @@ -15,12 +15,14 @@ Summary: Network UPS Tools Name: nut Version: 2.7.4 -Release: 26%{?dist} +Release: 27%{?dist} License: GPLv2+ and GPLv3+ Url: http://www.networkupstools.org/ Source: http://www.networkupstools.org/source/2.7/%{name}-%{version}.tar.gz Source3: nut-client.tmpfiles Source4: libs.sh +# Upstream support for OpenSSL-1.1.0, TLS > 1.0 +Patch0: https://patch-diff.githubusercontent.com/raw/networkupstools/nut/pull/504.patch Patch1: nut-2.6.3-tmpfiles.patch #quick fix. TODO: fix it properly @@ -31,7 +33,7 @@ Patch8: nut-2.6.5-unreachable.patch Patch9: nut-2.6.5-rmpidf.patch Patch10: nut-2.7.4-cloexec.patch -Requires(pre): shadow-utils systemd-udev +Requires(pre): shadow-utils Requires(post): coreutils systemd Requires(preun): systemd Requires(postun): coreutils systemd @@ -88,7 +90,7 @@ live status tracking on web pages, and more. Summary: Network UPS Tools client monitoring utilities Requires(post): systemd Requires(preun): systemd -Requires(pre): shadow-utils systemd-udev +Requires(pre): shadow-utils %if %{with python2} Requires: pygtk2, pygtk2-libglade #only for python and gui part @@ -103,7 +105,7 @@ attached to a different computer on the network. %package cgi Summary: CGI utilities for the Network UPS Tools Requires: %{name}-client = %{version}-%{release} webserver -Requires(pre): shadow-utils udev +Requires(pre): shadow-utils %description cgi This package includes CGI programs for accessing UPS status via a web @@ -127,6 +129,7 @@ necessary to develop NUT client applications. %prep %setup -q +%patch0 -p1 -b .openssl %patch1 -p1 -b .tmpfiles %patch3 -p1 -b .quickfix %patch5 -p1 -b .dlfix @@ -157,7 +160,9 @@ export LDFLAGS="-Wl,-z,now" --without-powerman \ %endif --with-libltdl \ +%if (0%{?fedora} && 0%{?fedora} < 33) || 0%{?el8} --with-nss \ +%endif --without-wrap \ --with-cgi \ --datadir=%{_datadir}/%{name} \ @@ -238,7 +243,7 @@ ln -s %{_datadir}/nut/nut-monitor/nut-monitor %{buildroot}%{_bindir}/nut-monitor %pre /usr/sbin/useradd -c "Network UPS Tools" -u %{nut_uid} \ -s /bin/false -r -d %{_localstatedir}/lib/ups %{name} 2> /dev/null || : -/usr/sbin/usermod -G dialout %{name} +/usr/sbin/usermod -G dialout,tty %{name} # do not let upsmon run during upgrade rhbz#916472 # phase 1: stop upsmon before upsd changes @@ -251,7 +256,6 @@ fi %post /sbin/ldconfig -udevadm control --reload ||: %systemd_post nut-driver.service nut-server.service %preun @@ -264,12 +268,12 @@ udevadm control --reload ||: %pre client /usr/sbin/useradd -c "Network UPS Tools" -u %{nut_uid} \ -s /bin/false -r -d %{_localstatedir}/lib/ups %{name} 2> /dev/null || : -/usr/sbin/usermod -G dialout %{name} +/usr/sbin/usermod -G dialout,tty %{name} %pre cgi /usr/sbin/useradd -c "Network UPS Tools" -u %{nut_uid} \ -s /bin/false -r -d %{_localstatedir}/lib/ups %{name} 2> /dev/null || : -/usr/sbin/usermod -G dialout %{name} +/usr/sbin/usermod -G dialout,tty %{name} %post client /sbin/ldconfig @@ -441,6 +445,9 @@ fi %{_libdir}/pkgconfig/libnutscan.pc %changelog +* Tue Jun 02 2020 Michal Hlavinka - 2.7.4-27 +- nut user needs tty group for wall (#1774591) + * Fri Oct 04 2019 Michal Hlavinka - 2.7.4-26 - drop pygtk2 requirements From 308ab912ca5cd16a93ccd82d42f85866db728b57 Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Thu, 24 Sep 2020 16:58:08 +0000 Subject: [PATCH 04/11] remove package.cfg per new epel-playground policy --- package.cfg | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 package.cfg diff --git a/package.cfg b/package.cfg deleted file mode 100644 index 7e5a05b..0000000 --- a/package.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[koji] -targets = epel8 epel8-playground From 9d502dbf9eeaec667069c8f4b6e0ee7de2d6a50b Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Thu, 13 Jan 2022 19:33:19 -0700 Subject: [PATCH 05/11] Drop old conditional --- nut.spec | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/nut.spec b/nut.spec index fb873f2..a50d200 100644 --- a/nut.spec +++ b/nut.spec @@ -203,9 +203,7 @@ mkdir -p %{buildroot}%{modeldir} \ %make_install -%if 0%{?fedora} || 0%{?rhel} > 6 - install -p -D -m 644 %{SOURCE3} %{buildroot}%{_tmpfilesdir}/nut-client.conf -%endif +install -p -D -m 644 %{SOURCE3} %{buildroot}%{_tmpfilesdir}/nut-client.conf rm -rf %{buildroot}%{_prefix}/html rm -f %{buildroot}%{_libdir}/*.la @@ -388,9 +386,7 @@ fi %dir %{_sysconfdir}/ups %config(noreplace) %attr(640,root,nut) %{_sysconfdir}/ups/upsmon.conf %config(noreplace) %attr(640,root,nut) %{_sysconfdir}/ups/upssched.conf -%if 0%{?fedora} || 0%{?rhel} > 6 - %{_tmpfilesdir}/nut-client.conf -%endif +%{_tmpfilesdir}/nut-client.conf %dir %attr(750,nut,nut) %{_localstatedir}/lib/ups # upsmon.pid is written as root, so root needs access for now %ghost %attr(770,root,nut) %{piddir} From 5f339ebafff0ba5a26190cf5d6bcb5d341093ded Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Tue, 13 Sep 2022 20:28:16 +0200 Subject: [PATCH 06/11] update to 2.8.0 --- .gitignore | 1 + nut-2.6.3-tmpfiles.patch | 45 +++++++++++------- nut-2.6.5-rmpidf.patch | 60 +++++++++++------------ nut-2.6.5-unreachable.patch | 17 +++---- nut-2.7.4-nutscanner-FTBFS.patch | 20 ++++++++ nut-2.7.4-scratchdes.patch | 16 +++++++ nut.spec | 81 +++++++++++++++++++++----------- sources | 2 +- 8 files changed, 158 insertions(+), 84 deletions(-) create mode 100644 nut-2.7.4-nutscanner-FTBFS.patch create mode 100644 nut-2.7.4-scratchdes.patch diff --git a/.gitignore b/.gitignore index 01c65a3..b466deb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ nut-2.4.3.tar.gz /nut-2.7.2.tar.gz /nut-2.7.3.tar.gz /nut-2.7.4.tar.gz +/nut-2.8.0.tar.gz diff --git a/nut-2.6.3-tmpfiles.patch b/nut-2.6.3-tmpfiles.patch index 0b45e1c..7f7cd98 100644 --- a/nut-2.6.3-tmpfiles.patch +++ b/nut-2.6.3-tmpfiles.patch @@ -1,22 +1,33 @@ -diff -up nut-2.7.4/scripts/systemd/nut-driver.service.in.tmpfiles nut-2.7.4/scripts/systemd/nut-driver.service.in ---- nut-2.7.4/scripts/systemd/nut-driver.service.in.tmpfiles 2016-08-11 16:58:00.759001400 +0200 -+++ nut-2.7.4/scripts/systemd/nut-driver.service.in 2016-08-11 16:58:38.619248466 +0200 -@@ -4,6 +4,7 @@ After=local-fs.target network.target - StopWhenUnneeded=yes - - [Service] +diff -up nut-2.8.0/scripts/systemd/nut-driver-enumerator.service.in.tmpfiles nut-2.8.0/scripts/systemd/nut-driver-enumerator.service.in +--- nut-2.8.0/scripts/systemd/nut-driver-enumerator.service.in.tmpfiles 2022-05-09 16:42:37.296229637 +0200 ++++ nut-2.8.0/scripts/systemd/nut-driver-enumerator.service.in 2022-05-09 16:42:51.139030657 +0200 +@@ -23,6 +23,7 @@ Type=oneshot + # don't want it to fail the unit (when it can't restart). + Environment=REPORT_RESTART_42=no + EnvironmentFile=-@CONFPATH@/nut.conf +ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-client.conf - ExecStart=@SBINDIR@/upsdrvctl start - ExecStop=@SBINDIR@/upsdrvctl stop - Type=forking -diff -up nut-2.7.4/scripts/systemd/nut-monitor.service.in.tmpfiles nut-2.7.4/scripts/systemd/nut-monitor.service.in ---- nut-2.7.4/scripts/systemd/nut-monitor.service.in.tmpfiles 2015-12-29 09:42:34.000000000 +0100 -+++ nut-2.7.4/scripts/systemd/nut-monitor.service.in 2016-08-11 16:57:48.121918934 +0200 -@@ -3,6 +3,7 @@ Description=Network UPS Tools - power de - After=local-fs.target network.target nut-server.service + ExecStart=@NUT_LIBEXECDIR@/nut-driver-enumerator.sh + ExecReload=@NUT_LIBEXECDIR@/nut-driver-enumerator.sh +diff -up nut-2.8.0/scripts/systemd/nut-driver@.service.in.tmpfiles nut-2.8.0/scripts/systemd/nut-driver@.service.in +--- nut-2.8.0/scripts/systemd/nut-driver@.service.in.tmpfiles 2022-05-09 16:41:00.952614514 +0200 ++++ nut-2.8.0/scripts/systemd/nut-driver@.service.in 2022-05-09 16:41:42.783013227 +0200 +@@ -40,6 +40,7 @@ PartOf=nut-driver.target [Service] + EnvironmentFile=-@CONFPATH@/nut.conf + SyslogIdentifier=%N +ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-client.conf - ExecStart=@SBINDIR@/upsmon + ExecStart=/bin/sh -c 'NUTDEV="`@NUT_LIBEXECDIR@/nut-driver-enumerator.sh --get-device-for-service %i`" && [ -n "$NUTDEV" ] || { echo "FATAL: Could not find a NUT device section for service unit %i" >&2 ; exit 1 ; } ; @SBINDIR@/upsdrvctl start "$NUTDEV"' + ExecStop=/bin/sh -c 'NUTDEV="`@NUT_LIBEXECDIR@/nut-driver-enumerator.sh --get-device-for-service %i`" && [ -n "$NUTDEV" ] || { echo "FATAL: Could not find a NUT device section for service unit %i" >&2 ; exit 1 ; } ; @SBINDIR@/upsdrvctl stop "$NUTDEV"' + # Restart really always, do not stop trying: +diff -up nut-2.8.0/scripts/systemd/nut-monitor.service.in.tmpfiles nut-2.8.0/scripts/systemd/nut-monitor.service.in +--- nut-2.8.0/scripts/systemd/nut-monitor.service.in.tmpfiles 2022-05-09 12:57:35.160646121 +0200 ++++ nut-2.8.0/scripts/systemd/nut-monitor.service.in 2022-05-09 16:40:18.289227772 +0200 +@@ -18,6 +18,7 @@ PartOf=nut.target + [Service] + EnvironmentFile=-@CONFPATH@/nut.conf + SyslogIdentifier=%N ++ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-client.conf + ExecStart=@SBINDIR@/upsmon -F + ExecReload=@SBINDIR@/upsmon -c reload PIDFile=@PIDPATH@/upsmon.pid - Type=forking diff --git a/nut-2.6.5-rmpidf.patch b/nut-2.6.5-rmpidf.patch index 3041c6d..54c6e1e 100644 --- a/nut-2.6.5-rmpidf.patch +++ b/nut-2.6.5-rmpidf.patch @@ -1,7 +1,7 @@ -diff -up nut-2.7.1/clients/upsmon.c.rmpidf nut-2.7.1/clients/upsmon.c ---- nut-2.7.1/clients/upsmon.c.rmpidf 2014-02-27 11:41:09.139369295 +0100 -+++ nut-2.7.1/clients/upsmon.c 2014-02-27 11:41:09.145369344 +0100 -@@ -2027,6 +2027,7 @@ int main(int argc, char *argv[]) +diff -up nut-2.8.0/clients/upsmon.c.rmpidf nut-2.8.0/clients/upsmon.c +--- nut-2.8.0/clients/upsmon.c.rmpidf 2022-04-23 13:56:06.000000000 +0200 ++++ nut-2.8.0/clients/upsmon.c 2022-05-09 17:22:34.329547283 +0200 +@@ -2314,6 +2314,7 @@ int main(int argc, char *argv[]) upslogx(LOG_INFO, "Signal %d: exiting", exit_flag); upsmon_cleanup(); @@ -9,47 +9,47 @@ diff -up nut-2.7.1/clients/upsmon.c.rmpidf nut-2.7.1/clients/upsmon.c exit(EXIT_SUCCESS); } -diff -up nut-2.7.1/common/common.c.rmpidf nut-2.7.1/common/common.c ---- nut-2.7.1/common/common.c.rmpidf 2013-11-20 20:53:31.000000000 +0100 -+++ nut-2.7.1/common/common.c 2014-02-27 11:41:09.146369353 +0100 -@@ -229,6 +229,20 @@ void writepid(const char *name) - umask(mask); +diff -up nut-2.8.0/common/common.c.rmpidf nut-2.8.0/common/common.c +--- nut-2.8.0/common/common.c.rmpidf 2022-05-09 17:22:34.329547283 +0200 ++++ nut-2.8.0/common/common.c 2022-05-09 17:26:48.671847245 +0200 +@@ -358,6 +358,20 @@ pid_t parsepid(const char *buf) + return pid; } +/* remove pid file */ +void cleanpid(const char *name) +{ -+ char fn[SMALLBUF]; ++ char fn[SMALLBUF]; + -+ /* use full path if present, else build filename in PIDPATH */ -+ if (*name == '/') -+ snprintf(fn, sizeof(fn), "%s", name); -+ else -+ snprintf(fn, sizeof(fn), "%s/%s.pid", PIDPATH, name); ++ /* use full path if present, else build filename in PIDPATH */ ++ if (*name == '/') ++ snprintf(fn, sizeof(fn), "%s", name); ++ else ++ snprintf(fn, sizeof(fn), "%s/%s.pid", PIDPATH, name); + -+ unlink(fn); ++ unlink(fn); +} + - /* open pidfn, get the pid, then send it sig */ - int sendsignalfn(const char *pidfn, int sig) - { -diff -up nut-2.7.1/include/common.h.rmpidf nut-2.7.1/include/common.h ---- nut-2.7.1/include/common.h.rmpidf 2013-11-20 20:53:31.000000000 +0100 -+++ nut-2.7.1/include/common.h 2014-02-27 11:41:09.146369353 +0100 -@@ -70,6 +70,9 @@ void chroot_start(const char *path); + /* open pidfn, get the pid, then send it sig + * returns negative codes for errors, or + * zero for a successfully sent signal +diff -up nut-2.8.0/include/common.h.rmpidf nut-2.8.0/include/common.h +--- nut-2.8.0/include/common.h.rmpidf 2022-05-09 17:22:34.329547283 +0200 ++++ nut-2.8.0/include/common.h 2022-05-09 17:25:47.439740973 +0200 +@@ -103,6 +103,9 @@ void chroot_start(const char *path); /* write a pid file - is a full pathname *or* just the program name */ void writepid(const char *name); +/* remove pid file */ +void cleanpid(const char *name); + - /* send a signal to another running process */ - int sendsignal(const char *progname, int sig); - -diff -up nut-2.7.1/server/upsd.c.rmpidf nut-2.7.1/server/upsd.c ---- nut-2.7.1/server/upsd.c.rmpidf 2014-02-27 11:41:09.146369353 +0100 -+++ nut-2.7.1/server/upsd.c 2014-02-27 11:42:03.715818754 +0100 -@@ -1050,6 +1050,7 @@ int main(int argc, char **argv) + /* parses string buffer into a pid_t if it passes + * a few sanity checks; returns -1 on error */ + pid_t parsepid(const char *buf); +diff -up nut-2.8.0/server/upsd.c.rmpidf nut-2.8.0/server/upsd.c +--- nut-2.8.0/server/upsd.c.rmpidf 2022-04-23 13:56:07.000000000 +0200 ++++ nut-2.8.0/server/upsd.c 2022-05-09 17:22:34.330547269 +0200 +@@ -1515,6 +1515,7 @@ int main(int argc, char **argv) ssl_cleanup(); upslogx(LOG_INFO, "Signal %d: exiting", exit_flag); diff --git a/nut-2.6.5-unreachable.patch b/nut-2.6.5-unreachable.patch index 3c9db41..4166e84 100644 --- a/nut-2.6.5-unreachable.patch +++ b/nut-2.6.5-unreachable.patch @@ -1,7 +1,7 @@ -diff -up nut-2.6.5/scripts/python/app/NUT-Monitor.unreachable nut-2.6.5/scripts/python/app/NUT-Monitor ---- nut-2.6.5/scripts/python/app/NUT-Monitor.unreachable 2012-07-31 19:38:56.000000000 +0200 -+++ nut-2.6.5/scripts/python/app/NUT-Monitor 2013-01-07 18:04:26.532531441 +0100 -@@ -674,6 +674,11 @@ class interface : +diff -up nut-2.8.0/scripts/python/app/NUT-Monitor-py3qt5.in.unreachable nut-2.8.0/scripts/python/app/NUT-Monitor-py3qt5.in +--- nut-2.8.0/scripts/python/app/NUT-Monitor-py3qt5.in.unreachable 2022-05-09 17:20:11.629621005 +0200 ++++ nut-2.8.0/scripts/python/app/NUT-Monitor-py3qt5.in 2022-05-09 17:20:52.674024537 +0200 +@@ -693,6 +693,11 @@ along with this program. If not, see 1.0 @@ -26,12 +25,13 @@ Patch0: https://patch-diff.githubusercontent.com/raw/networkupstools/nut/pull/50 Patch1: nut-2.6.3-tmpfiles.patch #quick fix. TODO: fix it properly -Patch3: nut-2.6.5-quickfix.patch Patch5: nut-2.6.5-dlfix.patch Patch7: nut-2.6.5-foreground.patch Patch8: nut-2.6.5-unreachable.patch Patch9: nut-2.6.5-rmpidf.patch Patch10: nut-2.7.4-cloexec.patch +Patch11: nut-2.7.4-nutscanner-FTBFS.patch +Patch12: nut-2.7.4-scratchdes.patch Requires(pre): shadow-utils Requires(post): coreutils systemd @@ -39,8 +39,10 @@ Requires(preun): systemd Requires(postun): coreutils systemd Obsoletes: nut-hal < 2.6.0-7 +BuildRequires: make BuildRequires: autoconf BuildRequires: automake +BuildRequires: augeas-libs BuildRequires: avahi-devel BuildRequires: cppunit-devel BuildRequires: dbus-glib-devel @@ -70,6 +72,7 @@ BuildRequires: powerman-devel BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: /usr/bin/pathfix.py +BuildRequires: systemd-rpm-macros %ifnarch s390 s390x BuildRequires: libusb-devel @@ -77,7 +80,7 @@ BuildRequires: libusb-devel ExcludeArch: s390 s390x -%global restart_flag /var/run/%{name}/%{name}-restart-after-rpm-install +%global restart_flag /run/%{name}/%{name}-restart-after-rpm-install %description These programs are part of a developing project to monitor the assortment @@ -129,29 +132,27 @@ necessary to develop NUT client applications. %prep %setup -q -%patch0 -p1 -b .openssl +#patch0 -p1 -b .openssl %patch1 -p1 -b .tmpfiles -%patch3 -p1 -b .quickfix -%patch5 -p1 -b .dlfix -%patch7 -p1 -b .foreground +#patch5 -p1 -b .dlfix +#%patch7 -p1 -b .foreground %patch8 -p1 -b .unreachable %patch9 -p1 -b .rmpidf -%patch10 -p1 -b .cloexec +#%patch10 -p1 -b .cloexec +#%patch11 -p1 -b .nutscanner-FTBFS +#%patch12 -p1 -b .scratchdes -sed -i 's|=NUT-Monitor|=nut-monitor|' scripts/python/app/nut-monitor.desktop -sed -i 's|env python|env python3|' scripts/python/app/NUT-Monitor -sed -i "s|sys.argv\[0\]|'%{_datadir}/%{name}/nut-monitor/nut-monitor'|" scripts/python/app/NUT-Monitor +sed -i 's|=NUT-Monitor|=nut-monitor|' scripts/python/app/nut-monitor-py3qt5.desktop +sed -i "s|sys.argv\[0\]|'%{_datadir}/%{name}/nut-monitor/nut-monitor'|" scripts/python/app/NUT-Monitor-py3qt5.in sed -i 's|LIBSSL_LDFLAGS|LIBSSL_LIBS|' lib/libupsclient-config.in sed -i 's|LIBSSL_LDFLAGS|LIBSSL_LIBS|' lib/libupsclient.pc.in -# Fix python shbangs -pathfix.py -pni "%{__python3} %{py3_shbang_opts}" scripts/python scripts/python/app/NUT-Monitor - # workaround for multilib conflicts - caused by patch changing modification time of scripts find . -mtime -1 -print0 | xargs -0 touch --reference %{SOURCE0} %build autoreconf -i +export CXXFLAGS="-std=c++14 $RPM_OPT_FLAGS" # prevent assignment of default value, it would break configure's tests export LDFLAGS="-Wl,-z,now" %configure \ @@ -164,17 +165,21 @@ export LDFLAGS="-Wl,-z,now" --with-nss \ %endif --without-wrap \ + --without-modbus \ + --without-linux-i2c \ --with-cgi \ + --with-python3 \ --datadir=%{_datadir}/%{name} \ --with-user=%{name} \ --with-group=dialout \ - --with-statepath=%{piddir} \ - --with-pidpath=%{piddir} \ - --with-altpidpath=%{piddir} \ + --with-statepath=/run/nut \ + --with-pidpath=/run/nut \ + --with-altpidpath=/run/nut \ --sysconfdir=%{_sysconfdir}/ups \ --with-cgipath=%{cgidir} \ --with-drvpath=%{modeldir} \ --with-systemdsystemunitdir=%{_unitdir} \ + --with-systemdshutdowndir=/lib/systemd/system-shutdown \ --with-pkgconfig-dir=%{_libdir}/pkgconfig \ --disable-static \ --with-udev-dir=%{_usr}/lib/udev \ @@ -198,13 +203,16 @@ mkdir -p %{buildroot}%{modeldir} \ %make_install -%if 0%{?fedora} || 0%{?rhel} > 6 - install -p -D -m 644 %{SOURCE3} %{buildroot}%{_tmpfilesdir}/nut-client.conf -%endif +#if 0%{?fedora} || 0%{?rhel} > 6 +# install -p -D -m 644 %{SOURCE3} %{buildroot}%{_tmpfilesdir}/nut-client.conf +#endif + +mv %{buildroot}%{_tmpfilesdir}/nut-common.tmpfiles %{buildroot}%{_tmpfilesdir}/nut-common.conf rm -rf %{buildroot}%{_prefix}/html rm -f %{buildroot}%{_libdir}/*.la rm -rf docs/man +rm -rf %{buildroot}%{_datadir}/nut/solaris-init find docs/ -name 'Makefile*' -delete pushd conf; @@ -307,18 +315,26 @@ fi %attr(644,root,root) %{_usr}/lib/udev/rules.d/62-nut-ipmipsu.rules %{modeldir}/* %exclude %{modeldir}/netxml-ups -%{_unitdir}/nut-driver.service +%{_unitdir}/nut-driver-enumerator.path +%{_unitdir}/nut-driver-enumerator.service +%{_unitdir}/nut-driver@.service +%{_unitdir}/nut-driver.target %{_unitdir}/nut-server.service +%{_unitdir}/nut.target %{_sbindir}/upsd %{_bindir}/nut-scanner %{_bindir}/upslog %{_libdir}/libnutscan.so.* +%{_libexecdir}/nut-driver-enumerator.sh +%{_datadir}/augeas/lenses/dist/nut* %{_datadir}/%{name}/cmdvartab %{_datadir}/%{name}/driver.list %{_mandir}/man5/nut.conf.5.gz %{_mandir}/man5/ups.conf.5.gz %{_mandir}/man5/upsd.conf.5.gz %{_mandir}/man5/upsd.users.5.gz + + %{_mandir}/man8/al175.8.gz %{_mandir}/man8/apcsmart.8.gz %{_mandir}/man8/apcsmart-old.8.gz @@ -346,10 +362,13 @@ fi %{_mandir}/man8/masterguard.8.gz %{_mandir}/man8/metasys.8.gz %{_mandir}/man8/microdowell.8.gz +%{_mandir}/man8/microsol-apc.8.gz %{_mandir}/man8/mge-utalk.8.gz %{_mandir}/man8/mge-shut.8.gz %{_mandir}/man8/nutupsdrv.8.gz %{_mandir}/man8/nutdrv_atcl_usb.8.gz +%{_mandir}/man8/nutdrv_siemens_sitop.8.gz +%{_mandir}/man8/nut-driver-enumerator.8.gz %{_mandir}/man8/nut-ipmipsu.8.gz %{_mandir}/man8/nut-recorder.8.gz %{_mandir}/man8/nut-scanner.8.gz @@ -375,6 +394,7 @@ fi %{_mandir}/man8/upscode2.8* %{_mandir}/man8/upsd.8.gz %{_mandir}/man8/upsdrvctl.8.gz +%{_mandir}/man8/upsdrvsvcctl.8.gz %{_mandir}/man8/upslog.8.gz %{_mandir}/man8/usbhid-ups.8.gz @@ -383,9 +403,8 @@ fi %dir %{_sysconfdir}/ups %config(noreplace) %attr(640,root,nut) %{_sysconfdir}/ups/upsmon.conf %config(noreplace) %attr(640,root,nut) %{_sysconfdir}/ups/upssched.conf -%if 0%{?fedora} || 0%{?rhel} > 6 - %{_tmpfilesdir}/nut-client.conf -%endif +#{_tmpfilesdir}/nut-client.conf +%{_tmpfilesdir}/nut-common.conf %dir %attr(750,nut,nut) %{_localstatedir}/lib/ups # upsmon.pid is written as root, so root needs access for now %ghost %attr(770,root,nut) %{piddir} @@ -399,6 +418,7 @@ fi /lib/systemd/system-shutdown/nutshutdown %{_libdir}/libupsclient.so.* %{_libdir}/libnutclient.so.* +%{_libdir}/libnutclientstub.so.* %{_mandir}/man5/upsmon.conf.5.gz %{_mandir}/man5/upssched.conf.5.gz %{_mandir}/man8/upsc.8.gz @@ -406,7 +426,7 @@ fi %{_mandir}/man8/upsrw.8.gz %{_mandir}/man8/upsmon.8.gz %{_mandir}/man8/upssched.8.gz -%{python3_sitelib}/ +%pycached %{python3_sitelib}/PyNUT.py %{_datadir}/nut %if %{with python2} %{_bindir}/nut-monitor @@ -439,12 +459,17 @@ fi %{_mandir}/man3/libnutclient* %{_libdir}/libupsclient.so %{_libdir}/libnutclient.so +%{_libdir}/libnutclientstub.so %{_libdir}/libnutscan.so %{_libdir}/pkgconfig/libupsclient.pc %{_libdir}/pkgconfig/libnutclient.pc +%{_libdir}/pkgconfig/libnutclientstub.pc %{_libdir}/pkgconfig/libnutscan.pc %changelog +* Tue Sep 13 2022 Michal Hlavinka - 2.8.0-1 +- update to 2.8.0 + * Tue Jun 02 2020 Michal Hlavinka - 2.7.4-27 - nut user needs tty group for wall (#1774591) diff --git a/sources b/sources index b1483aa..3574636 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -3ba53656933d7471f95140b32a5b8d5c nut-2.7.4.tar.gz +SHA512 (nut-2.8.0.tar.gz) = 3c413ae54088045a713eb80cf1bdda474f41bb3b67c7c0248aa7a0c4d441dce1ff42627a2735273d7e36892d1f2eeb895220cf28af63fec2fa0c7a267f82d577 From 3aa7b876a5b555c6a1837a3bdea75d137e837674 Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Tue, 6 Dec 2022 22:53:51 +0100 Subject: [PATCH 07/11] fix STATEPATH location and creation (#2024651) merged C99 related changes to configure from fedora --- 504.patch | 333 ------------------------------- nut-2.6.5-dlfix.patch | 25 --- nut-2.6.5-foreground.patch | 129 ------------ nut-2.7.4-cloexec.patch | 82 -------- nut-2.7.4-nutscanner-FTBFS.patch | 20 -- nut-2.7.4-scratchdes.patch | 16 -- nut-2.8.0-piddir-owner.patch | 48 +++++ nut-c99-ax_c_printf_null.patch | 60 ++++++ nut-c99-c_attribute.patch | 17 ++ nut-c99-strdup.patch | 17 ++ nut-client.tmpfiles | 1 - nut.spec | 42 ++-- 12 files changed, 159 insertions(+), 631 deletions(-) delete mode 100644 504.patch delete mode 100644 nut-2.6.5-dlfix.patch delete mode 100644 nut-2.6.5-foreground.patch delete mode 100644 nut-2.7.4-cloexec.patch delete mode 100644 nut-2.7.4-nutscanner-FTBFS.patch delete mode 100644 nut-2.7.4-scratchdes.patch create mode 100644 nut-2.8.0-piddir-owner.patch create mode 100644 nut-c99-ax_c_printf_null.patch create mode 100644 nut-c99-c_attribute.patch create mode 100644 nut-c99-strdup.patch delete mode 100644 nut-client.tmpfiles diff --git a/504.patch b/504.patch deleted file mode 100644 index 71e1bf4..0000000 --- a/504.patch +++ /dev/null @@ -1,333 +0,0 @@ -From da1f5aa699f54e0f6977ab64a3bc2f90a51c3104 Mon Sep 17 00:00:00 2001 -From: Arjen de Korte -Date: Mon, 27 Nov 2017 21:10:13 +0100 -Subject: [PATCH 1/7] Add support for openssl-1.1.0 - ---- - clients/upsclient.c | 4 ++++ - m4/nut_check_libopenssl.m4 | 5 +++-- - server/netssl.c | 4 ++++ - 3 files changed, 11 insertions(+), 2 deletions(-) - -diff --git a/clients/upsclient.c b/clients/upsclient.c -index b90587b00..fc5e7523c 100644 ---- a/clients/upsclient.c -+++ b/clients/upsclient.c -@@ -316,7 +316,11 @@ int upscli_init(int certverify, const char *certpath, - - #ifdef WITH_OPENSSL - -+#if OPENSSL_VERSION_NUMBER < 0x10100000L - SSL_library_init(); -+#else -+ OPENSSL_init_ssl(0, NULL); -+#endif - SSL_load_error_strings(); - - ssl_method = TLSv1_client_method(); -diff --git a/m4/nut_check_libopenssl.m4 b/m4/nut_check_libopenssl.m4 -index 1b875077b..5f29f4a38 100644 ---- a/m4/nut_check_libopenssl.m4 -+++ b/m4/nut_check_libopenssl.m4 -@@ -57,8 +57,9 @@ if test -z "${nut_have_libopenssl_seen}"; then - AC_MSG_RESULT([${LIBS}]) - - dnl check if openssl is usable -- AC_CHECK_HEADERS(openssl/ssl.h, [nut_have_openssl=yes], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT]) -- AC_CHECK_FUNCS(SSL_library_init, [], [nut_have_openssl=no]) -+ AC_CHECK_FUNCS(OPENSSL_init_ssl, [nut_have_openssl=yes], [nut_have_openssl=no]) -+ AC_CHECK_FUNCS(SSL_library_init, [nut_have_openssl=yes], []) -+ AC_CHECK_HEADERS(openssl/ssl.h, [], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT]) - - if test "${nut_have_openssl}" = "yes"; then - nut_with_ssl="yes" -diff --git a/server/netssl.c b/server/netssl.c -index c2f409899..0f9a70acf 100644 ---- a/server/netssl.c -+++ b/server/netssl.c -@@ -388,7 +388,11 @@ void ssl_init(void) - #ifdef WITH_OPENSSL - - SSL_load_error_strings(); -+#if OPENSSL_VERSION_NUMBER < 0x10100000L - SSL_library_init(); -+#else -+ OPENSSL_init_ssl(0, NULL); -+#endif - - if ((ssl_method = TLSv1_server_method()) == NULL) { - ssl_debug(); - -From b15656efb2575647ca0e0b6439b6380373767b8f Mon Sep 17 00:00:00 2001 -From: Arjen de Korte -Date: Tue, 28 Nov 2017 20:00:52 +0100 -Subject: [PATCH 2/7] Allow TLSv1 and higher (not just TLSv1) - ---- - clients/upsclient.c | 30 +++++++++++++++++------------- - server/netssl.c | 26 +++++++++++++++----------- - 2 files changed, 32 insertions(+), 24 deletions(-) - -diff --git a/clients/upsclient.c b/clients/upsclient.c -index fc5e7523c..bd951e854 100644 ---- a/clients/upsclient.c -+++ b/clients/upsclient.c -@@ -299,11 +299,6 @@ int upscli_init(int certverify, const char *certpath, - { - #ifdef WITH_OPENSSL - int ret, ssl_mode = SSL_VERIFY_NONE; --#if OPENSSL_VERSION_NUMBER >= 0x10000000L -- const SSL_METHOD *ssl_method; --#else -- SSL_METHOD *ssl_method; --#endif - #elif defined(WITH_NSS) /* WITH_OPENSSL */ - SECStatus status; - #endif /* WITH_OPENSSL | WITH_NSS */ -@@ -315,26 +310,35 @@ int upscli_init(int certverify, const char *certpath, - } - - #ifdef WITH_OPENSSL -+ -+ SSL_load_error_strings(); - - #if OPENSSL_VERSION_NUMBER < 0x10100000L - SSL_library_init(); -+ -+ ssl_ctx = SSL_CTX_new(SSLv23_client_method()); - #else - OPENSSL_init_ssl(0, NULL); --#endif -- SSL_load_error_strings(); - -- ssl_method = TLSv1_client_method(); -- -- if (!ssl_method) { -- return 0; -- } -+ ssl_ctx = SSL_CTX_new(TLS_client_method()); -+#endif - -- ssl_ctx = SSL_CTX_new(ssl_method); - if (!ssl_ctx) { - upslogx(LOG_ERR, "Can not initialize SSL context"); - return -1; - } - -+#if OPENSSL_VERSION_NUMBER < 0x10100000L -+ /* set minimum protocol TLSv1 */ -+ SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); -+#else -+ ret = SSL_CTX_set_min_proto_version(ssl_ctx, TLS1_VERSION); -+ if (ret != 1) { -+ upslogx(LOG_ERR, "Can not set minimum protocol to TLSv1"); -+ return -1; -+ } -+#endif -+ - if (!certpath) { - if (certverify == 1) { - upslogx(LOG_ERR, "Can not verify certificate if any is specified"); -diff --git a/server/netssl.c b/server/netssl.c -index 0f9a70acf..98680d25e 100644 ---- a/server/netssl.c -+++ b/server/netssl.c -@@ -371,13 +371,7 @@ void ssl_init(void) - { - #ifdef WITH_NSS - SECStatus status; --#elif defined(WITH_OPENSSL) --#if OPENSSL_VERSION_NUMBER >= 0x10000000L -- const SSL_METHOD *ssl_method; --#else -- SSL_METHOD *ssl_method; --#endif --#endif /* WITH_NSS|WITH_OPENSSL */ -+#endif /* WITH_NSS */ - - if (!certfile) { - return; -@@ -388,21 +382,31 @@ void ssl_init(void) - #ifdef WITH_OPENSSL - - SSL_load_error_strings(); -+ - #if OPENSSL_VERSION_NUMBER < 0x10100000L - SSL_library_init(); -+ -+ ssl_ctx = SSL_CTX_new(SSLv23_server_method()); - #else - OPENSSL_init_ssl(0, NULL); -+ -+ ssl_ctx = SSL_CTX_new(TLS_server_method()); - #endif - -- if ((ssl_method = TLSv1_server_method()) == NULL) { -+ if (!ssl_ctx) { - ssl_debug(); -- fatalx(EXIT_FAILURE, "TLSv1_server_method failed"); -+ fatalx(EXIT_FAILURE, "SSL_CTX_new failed"); - } - -- if ((ssl_ctx = SSL_CTX_new(ssl_method)) == NULL) { -+#if OPENSSL_VERSION_NUMBER < 0x10100000L -+ /* set minimum protocol TLSv1 */ -+ SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); -+#else -+ if (SSL_CTX_set_min_proto_version(ssl_ctx, TLS1_VERSION) != 1) { - ssl_debug(); -- fatalx(EXIT_FAILURE, "SSL_CTX_new failed"); -+ fatalx(EXIT_FAILURE, "SSL_CTX_set_min_proto_version(TLS1_VERSION)"); - } -+#endif - - if (SSL_CTX_use_certificate_chain_file(ssl_ctx, certfile) != 1) { - ssl_debug(); - -From 5a8308aef9884017754fb70620c8ded34fa44290 Mon Sep 17 00:00:00 2001 -From: Arjen de Korte -Date: Tue, 28 Nov 2017 22:01:41 +0100 -Subject: [PATCH 3/7] Fix check for empty string - ---- - clients/upssched.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/clients/upssched.c b/clients/upssched.c -index 97b3ed42d..3fdf118ed 100644 ---- a/clients/upssched.c -+++ b/clients/upssched.c -@@ -794,7 +794,7 @@ static void parse_at(const char *ntype, const char *un, const char *cmd, - } - - if (!strcmp(cmd, "EXECUTE")) { -- if (ca1 == '\0') { -+ if (ca1[0] == '\0') { - upslogx(LOG_ERR, "Empty EXECUTE command argument"); - return; - } - -From 5ecfb0ffe3d89a5116dd287ff2c3f60de67ecbb9 Mon Sep 17 00:00:00 2001 -From: Arjen de Korte -Date: Fri, 1 Dec 2017 12:24:00 +0100 -Subject: [PATCH 4/7] Report TLS handshake in debug mode - ---- - clients/upsclient.c | 2 +- - server/netssl.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/clients/upsclient.c b/clients/upsclient.c -index bd951e854..b7dd8f424 100644 ---- a/clients/upsclient.c -+++ b/clients/upsclient.c -@@ -745,7 +745,7 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert) - switch(res) - { - case 1: -- upsdebugx(3, "SSL connected"); -+ upsdebugx(3, "SSL connected (%s)", SSL_get_version(ups->ssl)); - break; - case 0: - upslog_with_errno(1, "SSL_connect do not accept handshake."); -diff --git a/server/netssl.c b/server/netssl.c -index 98680d25e..6ae13e8d3 100644 ---- a/server/netssl.c -+++ b/server/netssl.c -@@ -275,7 +275,7 @@ void net_starttls(nut_ctype_t *client, int numarg, const char **arg) - { - case 1: - client->ssl_connected = 1; -- upsdebugx(3, "SSL connected"); -+ upsdebugx(3, "SSL connected (%s)", SSL_get_version(client->ssl)); - break; - - case 0: - -From ab0c8b41c0530d3706e4997257939026cfd29ccc Mon Sep 17 00:00:00 2001 -From: Arjen de Korte -Date: Sun, 24 Feb 2019 18:31:21 +0100 -Subject: [PATCH 5/7] Update nut_check_libopenssl.m4 - ---- - m4/nut_check_libopenssl.m4 | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - -diff --git a/m4/nut_check_libopenssl.m4 b/m4/nut_check_libopenssl.m4 -index 5f29f4a38..7eb401cd9 100644 ---- a/m4/nut_check_libopenssl.m4 -+++ b/m4/nut_check_libopenssl.m4 -@@ -57,9 +57,8 @@ if test -z "${nut_have_libopenssl_seen}"; then - AC_MSG_RESULT([${LIBS}]) - - dnl check if openssl is usable -- AC_CHECK_FUNCS(OPENSSL_init_ssl, [nut_have_openssl=yes], [nut_have_openssl=no]) -- AC_CHECK_FUNCS(SSL_library_init, [nut_have_openssl=yes], []) -- AC_CHECK_HEADERS(openssl/ssl.h, [], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT]) -+ AC_CHECK_HEADERS(openssl/ssl.h, [nut_have_openssl=yes], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT]) -+ AC_CHECK_FUNCS(SSL_CTX_new, [], [nut_have_openssl=no]) - - if test "${nut_have_openssl}" = "yes"; then - nut_with_ssl="yes" - -From 1dc34a5da7308f0f85537a6761fefb3ff3098863 Mon Sep 17 00:00:00 2001 -From: Arjen de Korte -Date: Sun, 24 Feb 2019 18:34:53 +0100 -Subject: [PATCH 6/7] Update upsclient.c - ---- - clients/upsclient.c | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -diff --git a/clients/upsclient.c b/clients/upsclient.c -index b7dd8f424..541664f36 100644 ---- a/clients/upsclient.c -+++ b/clients/upsclient.c -@@ -311,15 +311,12 @@ int upscli_init(int certverify, const char *certpath, - - #ifdef WITH_OPENSSL - -- SSL_load_error_strings(); -- - #if OPENSSL_VERSION_NUMBER < 0x10100000L -+ SSL_load_error_strings(); - SSL_library_init(); - - ssl_ctx = SSL_CTX_new(SSLv23_client_method()); - #else -- OPENSSL_init_ssl(0, NULL); -- - ssl_ctx = SSL_CTX_new(TLS_client_method()); - #endif - - -From 108c31c9b170da2ee34a25fd373d21837d4d10a3 Mon Sep 17 00:00:00 2001 -From: Arjen de Korte -Date: Sun, 24 Feb 2019 18:37:42 +0100 -Subject: [PATCH 7/7] Update netssl.c - ---- - server/netssl.c | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -diff --git a/server/netssl.c b/server/netssl.c -index 6ae13e8d3..cf9419edf 100644 ---- a/server/netssl.c -+++ b/server/netssl.c -@@ -381,15 +381,12 @@ void ssl_init(void) - - #ifdef WITH_OPENSSL - -- SSL_load_error_strings(); -- - #if OPENSSL_VERSION_NUMBER < 0x10100000L -+ SSL_load_error_strings(); - SSL_library_init(); - - ssl_ctx = SSL_CTX_new(SSLv23_server_method()); - #else -- OPENSSL_init_ssl(0, NULL); -- - ssl_ctx = SSL_CTX_new(TLS_server_method()); - #endif - diff --git a/nut-2.6.5-dlfix.patch b/nut-2.6.5-dlfix.patch deleted file mode 100644 index f93b5ea..0000000 --- a/nut-2.6.5-dlfix.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff -up nut-2.7.4/tools/nut-scanner/scan_avahi.c.dlfix nut-2.7.4/tools/nut-scanner/scan_avahi.c -diff -up nut-2.7.4/tools/nut-scanner/scan_ipmi.c.dlfix nut-2.7.4/tools/nut-scanner/scan_ipmi.c -diff -up nut-2.7.4/tools/nut-scanner/scan_nut.c.dlfix nut-2.7.4/tools/nut-scanner/scan_nut.c -diff -up nut-2.7.4/tools/nut-scanner/scan_snmp.c.dlfix nut-2.7.4/tools/nut-scanner/scan_snmp.c -diff -up nut-2.7.4/tools/nut-scanner/scan_usb.c.dlfix nut-2.7.4/tools/nut-scanner/scan_usb.c -diff -up nut-2.7.4/tools/nut-scanner/scan_xml_http.c.dlfix nut-2.7.4/tools/nut-scanner/scan_xml_http.c ---- nut-2.7.4/tools/nut-scanner/scan_xml_http.c.dlfix 2016-03-08 13:01:11.000000000 +0100 -+++ nut-2.7.4/tools/nut-scanner/scan_xml_http.c 2016-03-12 00:23:02.554826665 +0100 -@@ -37,7 +37,6 @@ - #include - - /* dynamic link library stuff */ --static char * libname = "libneon"; - static lt_dlhandle dl_handle = NULL; - static const char *dl_error = NULL; - -@@ -102,7 +101,7 @@ int nutscan_load_neon_library(const char - - return 1; - err: -- fprintf(stderr, "Cannot load XML library (%s) : %s. XML search disabled.\n", libname, dl_error); -+ fprintf(stderr, "Cannot load XML library (%s) : %s. XML search disabled.\n", libname_path, dl_error); - dl_handle = (void *)1; - lt_dlexit(); - return 0; diff --git a/nut-2.6.5-foreground.patch b/nut-2.6.5-foreground.patch deleted file mode 100644 index 4064b86..0000000 --- a/nut-2.6.5-foreground.patch +++ /dev/null @@ -1,129 +0,0 @@ -diff -up nut-2.7.1/clients/upsmon.c.foreground nut-2.7.1/clients/upsmon.c ---- nut-2.7.1/clients/upsmon.c.foreground 2013-07-26 21:41:10.000000000 +0200 -+++ nut-2.7.1/clients/upsmon.c 2014-02-27 11:39:58.158784578 +0100 -@@ -1645,6 +1645,7 @@ static void help(const char *progname) - printf(" - reload: reread configuration\n"); - printf(" - stop: stop monitoring and exit\n"); - printf(" -D raise debugging level\n"); -+ printf(" -F run in foreground, do not daemonize\n"); - printf(" -h display this help\n"); - printf(" -K checks POWERDOWNFLAG, sets exit code to 0 if set\n"); - printf(" -p always run privileged (disable privileged parent)\n"); -@@ -1859,7 +1860,7 @@ static void check_parent(void) - int main(int argc, char *argv[]) - { - const char *prog = xbasename(argv[0]); -- int i, cmd = 0, checking_flag = 0; -+ int i, cmd = 0, checking_flag = 0, foreground = 0; - - printf("Network UPS Tools %s %s\n", prog, UPS_VERSION); - -@@ -1870,7 +1871,7 @@ int main(int argc, char *argv[]) - - run_as_user = xstrdup(RUN_AS_USER); - -- while ((i = getopt(argc, argv, "+Dhic:f:pu:VK46")) != -1) { -+ while ((i = getopt(argc, argv, "+DFhic:f:pu:VK46")) != -1) { - switch (i) { - case 'c': - if (!strncmp(optarg, "fsd", strlen(optarg))) -@@ -1887,6 +1888,9 @@ int main(int argc, char *argv[]) - case 'D': - nut_debug_level++; - break; -+ case 'F': -+ foreground = 1; -+ break; - case 'f': - free(configfile); - configfile = xstrdup(optarg); -@@ -1962,9 +1966,9 @@ int main(int argc, char *argv[]) - exit(EXIT_FAILURE); - } - -- if (nut_debug_level < 1) { -+ if (!foreground && nut_debug_level < 1) { - background(); -- } else { -+ } else if (nut_debug_level >= 1) { - upsdebugx(1, "debug level is '%d'", nut_debug_level); - } - -diff -up nut-2.7.1/scripts/systemd/nut-monitor.service.in.foreground nut-2.7.1/scripts/systemd/nut-monitor.service.in ---- nut-2.7.1/scripts/systemd/nut-monitor.service.in.foreground 2014-02-27 11:39:58.141784438 +0100 -+++ nut-2.7.1/scripts/systemd/nut-monitor.service.in 2014-02-27 11:39:58.152784529 +0100 -@@ -4,9 +4,8 @@ After=local-fs.target network.target nut - - [Service] - ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-client.conf --ExecStart=@SBINDIR@/upsmon --PIDFile=@PIDPATH@/upsmon.pid --Type=forking -+ExecStart=@SBINDIR@/upsmon -F -+Type=simple - - [Install] - WantedBy=multi-user.target -diff -up nut-2.7.1/scripts/systemd/nut-server.service.in.foreground nut-2.7.1/scripts/systemd/nut-server.service.in ---- nut-2.7.1/scripts/systemd/nut-server.service.in.foreground 2013-07-26 21:41:11.000000000 +0200 -+++ nut-2.7.1/scripts/systemd/nut-server.service.in 2014-02-27 11:39:58.152784529 +0100 -@@ -5,8 +5,8 @@ Requires=nut-driver.service - Before=nut-monitor.service - - [Service] --ExecStart=@SBINDIR@/upsd --Type=forking -+ExecStart=@SBINDIR@/upsd -F -+Type=simple - - [Install] - WantedBy=multi-user.target -diff -up nut-2.7.1/server/upsd.c.foreground nut-2.7.1/server/upsd.c ---- nut-2.7.1/server/upsd.c.foreground 2013-07-26 21:41:11.000000000 +0200 -+++ nut-2.7.1/server/upsd.c 2014-02-27 11:39:58.153784537 +0100 -@@ -827,6 +827,7 @@ static void help(const char *progname) - printf(" - reload: reread configuration files\n"); - printf(" - stop: stop process and exit\n"); - printf(" -D raise debugging level\n"); -+ printf(" -F run in foreground, do not daemonize\n"); - printf(" -h display this help\n"); - printf(" -r chroots to \n"); - printf(" -q raise log level threshold\n"); -@@ -890,7 +891,7 @@ void check_perms(const char *fn) - - int main(int argc, char **argv) - { -- int i, cmd = 0; -+ int i, cmd = 0, foreground = 0; - char *chroot_path = NULL; - const char *user = RUN_AS_USER; - struct passwd *new_uid = NULL; -@@ -906,7 +907,7 @@ int main(int argc, char **argv) - - printf("Network UPS Tools %s %s\n", progname, UPS_VERSION); - -- while ((i = getopt(argc, argv, "+h46p:qr:i:fu:Vc:D")) != -1) { -+ while ((i = getopt(argc, argv, "+hF46p:qr:i:fu:Vc:D")) != -1) { - switch (i) { - case 'h': - help(progname); -@@ -944,6 +945,10 @@ int main(int argc, char **argv) - nut_debug_level++; - break; - -+ case 'F': -+ foreground = 1; -+ break; -+ - case '4': - opt_af = AF_INET; - break; -@@ -1031,7 +1036,7 @@ int main(int argc, char **argv) - /* handle upsd.users */ - user_load(); - -- if (!nut_debug_level) { -+ if (!nut_debug_level && !foreground) { - background(); - writepid(pidfn); - } else { diff --git a/nut-2.7.4-cloexec.patch b/nut-2.7.4-cloexec.patch deleted file mode 100644 index 1061e17..0000000 --- a/nut-2.7.4-cloexec.patch +++ /dev/null @@ -1,82 +0,0 @@ ---- nut-2.7.4/common/parseconf.c.cloexec 2018-12-07 15:56:22.989381441 -0800 -+++ nut-2.7.4/common/parseconf.c 2018-12-07 16:48:33.912337591 -0800 -@@ -83,6 +83,7 @@ - #include - #include - #include -+#include - - #include "parseconf.h" - -@@ -443,6 +444,9 @@ - return 0; - } - -+ /* prevent fd leaking to child processes */ -+ fcntl(fileno(ctx->f), F_SETFD, FD_CLOEXEC); -+ - return 1; /* OK */ - } - ---- nut-2.7.4/clients/upsmon.c.cloexec 2018-12-07 16:22:42.185376803 -0800 -+++ nut-2.7.4/clients/upsmon.c 2018-12-07 17:18:44.662093479 -0800 -@@ -24,6 +24,8 @@ - #include - #include - #include -+#include -+#include - - #include "upsclient.h" - #include "upsmon.h" -@@ -1432,6 +1434,9 @@ - /* we're definitely connected now */ - setflag(&ups->status, ST_CONNECTED); - -+ /* prevent connection leaking to NOTIFYCMD */ -+ fcntl(upscli_fd(&ups->conn), F_SETFD, FD_CLOEXEC); -+ - /* now try to authenticate to upsd */ - - ret = do_upsd_auth(ups); -@@ -1715,6 +1720,9 @@ - } - - close(pipefd[0]); -+ -+ /* prevent pipe leaking to NOTIFYCMD */ -+ fcntl(pipefd[1], F_SETFD, FD_CLOEXEC); - } - - static void delete_ups(utype_t *target) ---- nut-2.7.4/clients/upssched.c.cloexec 2018-12-07 17:09:13.081914570 -0800 -+++ nut-2.7.4/clients/upssched.c 2018-12-07 18:28:54.380512191 -0800 -@@ -46,6 +46,8 @@ - #include - #include - #include -+#include -+#include - - #include "upssched.h" - #include "timehead.h" -@@ -297,6 +299,9 @@ - if (ret < 0) - fatal_with_errno(EXIT_FAILURE, "listen(%d, %d) failed", fd, US_LISTEN_BACKLOG); - -+ /* don't leak socket to CMDSCRIPT */ -+ fcntl(fd, F_SETFD, FD_CLOEXEC); -+ - return fd; - } - -@@ -370,6 +375,9 @@ - return; - } - -+ /* don't leak connection to CMDSCRIPT */ -+ fcntl(acc, F_SETFD, FD_CLOEXEC); -+ - /* enable nonblocking I/O */ - - ret = fcntl(acc, F_GETFL, 0); diff --git a/nut-2.7.4-nutscanner-FTBFS.patch b/nut-2.7.4-nutscanner-FTBFS.patch deleted file mode 100644 index fcb4f37..0000000 --- a/nut-2.7.4-nutscanner-FTBFS.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff -urNp a/tools/nut-scanner/Makefile.am b/tools/nut-scanner/Makefile.am ---- a/tools/nut-scanner/Makefile.am 2020-09-02 10:16:27.304816091 +0200 -+++ b/tools/nut-scanner/Makefile.am 2020-09-02 10:17:58.119811844 +0200 -@@ -14,14 +14,14 @@ libnutscan_la_SOURCES = scan_nut.c scan_ - scan_avahi.c scan_eaton_serial.c nutscan-serial.c \ - ../../drivers/serial.c \ - ../../drivers/bcmxcp_ser.c \ -- ../../common/common.c -+ ../../common/common.c ../../common/str.c - libnutscan_la_LIBADD = $(NETLIBS) $(LIBLTDL_LIBS) - libnutscan_la_LDFLAGS = $(SERLIBS) -version-info 1:0:0 - libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include $(LIBLTDL_CFLAGS) -I$(top_srcdir)/drivers - - nut_scanner_SOURCES = nut-scanner.c - nut_scanner_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include --nut_scanner_LDADD = libnutscan.la ../../common/libcommon.la -+nut_scanner_LDADD = libnutscan.la - - if WITH_SSL - libnutscan_la_CFLAGS += $(LIBSSL_CFLAGS) diff --git a/nut-2.7.4-scratchdes.patch b/nut-2.7.4-scratchdes.patch deleted file mode 100644 index eb793d2..0000000 --- a/nut-2.7.4-scratchdes.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff -up nut-2.7.4/drivers/snmp-ups.c.scratchdes nut-2.7.4/drivers/snmp-ups.c ---- nut-2.7.4/drivers/snmp-ups.c.scratchdes 2021-06-08 13:56:32.608702337 +0200 -+++ nut-2.7.4/drivers/snmp-ups.c 2021-06-08 13:56:32.622702201 +0200 -@@ -471,11 +471,7 @@ void nut_snmp_init(const char *type, con - - privProtocol = testvar(SU_VAR_PRIVPROT) ? getval(SU_VAR_PRIVPROT) : "DES"; - -- if (strcmp(privProtocol, "DES") == 0) { -- g_snmp_sess.securityPrivProto = usmDESPrivProtocol; -- g_snmp_sess.securityPrivProtoLen = sizeof(usmDESPrivProtocol)/sizeof(oid); -- } -- else if (strcmp(privProtocol, "AES") == 0) { -+ if (strcmp(privProtocol, "AES") == 0) { - g_snmp_sess.securityPrivProto = usmAESPrivProtocol; - g_snmp_sess.securityPrivProtoLen = sizeof(usmAESPrivProtocol)/sizeof(oid); - } diff --git a/nut-2.8.0-piddir-owner.patch b/nut-2.8.0-piddir-owner.patch new file mode 100644 index 0000000..61fa75d --- /dev/null +++ b/nut-2.8.0-piddir-owner.patch @@ -0,0 +1,48 @@ +diff -up nut-2.8.0/configure.ac.piddir-owner nut-2.8.0/configure.ac +--- nut-2.8.0/configure.ac.piddir-owner 2022-04-26 18:03:36.000000000 -0400 ++++ nut-2.8.0/configure.ac 2022-11-30 13:29:58.418038393 -0500 +@@ -2833,23 +2833,23 @@ AS_IF([test -n "$systemdtmpfilesdir"], + [mkdir -p "${TOP_BUILDDIR}"/scripts/systemd + cat > "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF + # State file (e.g. upsd to driver) and pidfile location for NUT: +-d @STATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +-X @STATEPATH@/nut ++d @STATEPATH@ 0770 root @RUN_AS_GROUP@ - - ++X @STATEPATH@ + EOF + AS_IF([test "$STATEPATH" != "$PIDPATH"], + [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF +-d @PIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +-X @PIDPATH@/nut ++d @PIDPATH@ 0770 root @RUN_AS_GROUP@ - - ++X @PIDPATH@ + EOF]) + AS_IF([test -n "$ALTPIDPATH" && test "$STATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTPIDPATH"], + [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF +-d @ALTPIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +-X @ALTPIDPATH@/nut ++d @ALTPIDPATH@ 0770 root @RUN_AS_GROUP@ - - ++X @ALTPIDPATH@ + EOF]) + AS_IF([test -n "$ALTSTATEPATH" && test "$STATEPATH" != "$ALTSTATEPATH" && test "$ALTSTATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTSTATEPATH"], + [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF +-d @ALTSTATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +-X @ALTSTATEPATH@/nut ++d @ALTSTATEPATH@ 0770 root @RUN_AS_GROUP@ - - ++X @ALTSTATEPATH@ + EOF]) + ]) + AC_MSG_RESULT([done]) +diff -up nut-2.8.0/scripts/systemd/nut-common.tmpfiles.in.piddir-owner nut-2.8.0/scripts/systemd/nut-common.tmpfiles.in +--- nut-2.8.0/scripts/systemd/nut-common.tmpfiles.in.piddir-owner 2022-04-26 18:06:27.000000000 -0400 ++++ nut-2.8.0/scripts/systemd/nut-common.tmpfiles.in 2022-11-30 13:30:11.651106256 -0500 +@@ -1,5 +1,5 @@ + # State file (e.g. upsd to driver) and pidfile location for NUT: +-d @STATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +-X @STATEPATH@/nut +-d @PIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +-X @PIDPATH@/nut ++d @STATEPATH@ 0770 root @RUN_AS_GROUP@ - - ++X @STATEPATH@ ++d @PIDPATH@ 0770 root @RUN_AS_GROUP@ - - ++X @PIDPATH@ diff --git a/nut-c99-ax_c_printf_null.patch b/nut-c99-ax_c_printf_null.patch new file mode 100644 index 0000000..9db80b0 --- /dev/null +++ b/nut-c99-ax_c_printf_null.patch @@ -0,0 +1,60 @@ +Fix several issues with the AX_C_PRINTF_STRING_NULL check: + +Adjust quoting in the AX_C_PRINTF_STRING_NULL definition. Switch to +strstr from strcasestr (a GNU extension, requires -D_GNU_SOURCE) +and include instead of . Add missing braces +and parentheses. Use double-quote for string literals. + +Submitted upstream: + +diff --git a/m4/ax_c_pragmas.m4 b/m4/ax_c_pragmas.m4 +index 53c1aebf8ea35a1e..14ecd596d3b36573 100644 +--- a/m4/ax_c_pragmas.m4 ++++ b/m4/ax_c_pragmas.m4 +@@ -943,32 +943,32 @@ if test -z "${nut_have_ax_c_printf_string_null_seen}"; then + dnl ### To be sure, bolt the language + AC_LANG_PUSH([C]) + +- AC_CACHE_CHECK([for practical support to pritnf("%s", NULL)], ++ AC_CACHE_CHECK([for practical support to printf("%s", NULL)], + [ax_cv__printf_string_null], + [AX_RUN_OR_LINK_IFELSE( + [AC_LANG_PROGRAM([dnl + #include +-#include +-], [dnl ++#include ++], [[ + char buf[128]; + char *s = NULL; + int res = snprintf(buf, sizeof(buf), "%s", s); + buf[sizeof(buf)-1] = '\0'; + if (res < 0) { +- printf(stderr, "FAILED to snprintf() a NULL string argument"); +- exit 1; ++ fprintf(stderr, "FAILED to snprintf() a NULL string argument\n"); ++ return 1; + } +-if (buf[0] == '\0') +- printf(stderr, "RETURNED empty string from snprintf() with a NULL string argument"); +- exit 0; ++if (buf[0] == '\0') { ++ fprintf(stderr, "RETURNED empty string from snprintf() with a NULL string argument\n"); ++ return 0; + } +-if (strcasestr(buf, 'null') == NULL) +- printf(stderr, "RETURNED some string from snprintf() with a NULL string argument: '%s'", buf); +- exit 0; ++if (strstr(buf, "null") == NULL) { ++ fprintf(stderr, "RETURNED some string from snprintf() with a NULL string argument: '%s'\n", buf); ++ return 0; + } +-printf(stderr, "SUCCESS: RETURNED a string that contains something like 'null' from snprintf() with a NULL string argument: '%s'", buf); +-exit 0; +- ])], ++fprintf(stderr, "SUCCESS: RETURNED a string that contains something like 'null' from snprintf() with a NULL string argument: '%s'\n", buf); ++return 0; ++ ]])], + [ax_cv__printf_string_null=yes], + [ax_cv__printf_string_null=no] + )] diff --git a/nut-c99-c_attribute.patch b/nut-c99-c_attribute.patch new file mode 100644 index 0000000..aff6495 --- /dev/null +++ b/nut-c99-c_attribute.patch @@ -0,0 +1,17 @@ +Call the defined foo function instead of the undeclared func function. + +Submitted upstream: + +diff --git a/m4/ax_c___attribute__.m4 b/m4/ax_c___attribute__.m4 +index 0e952e7841c35b60..780bc2bb14ac5a78 100644 +--- a/m4/ax_c___attribute__.m4 ++++ b/m4/ax_c___attribute__.m4 +@@ -67,7 +67,7 @@ AC_DEFUN([AX_C___ATTRIBUTE__], [ + foo(__attribute__ ((unused)) int i) { + return; + } +- ]], [func(1);])], ++ ]], [foo(1);])], + [ax_cv___attribute__unused_arg=yes], + [ax_cv___attribute__unused_arg=no] + ) diff --git a/nut-c99-strdup.patch b/nut-c99-strdup.patch new file mode 100644 index 0000000..90c83db --- /dev/null +++ b/nut-c99-strdup.patch @@ -0,0 +1,17 @@ +Fix strdup configure test: Remove a call to the undeclared free +function. + +Submitted upstream: + +diff --git a/configure.ac b/configure.ac +index 3aa26c24ebc99bb6..c93ccd1e494874d5 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -294,7 +294,6 @@ AC_CACHE_CHECK([for strdup(s)], + char *t = "Test"; + char *s = strdup(t); + if (!s || !(s[0]=='T'&&s[1]=='e'&&s[2]=='s'&&s[3]=='t'&&s[4]=='\0') || s == t) res = 1; +-if (s) free (s); + if (res != 0) return res + /* autoconf adds ";return 0;" */ + ]])], diff --git a/nut-client.tmpfiles b/nut-client.tmpfiles deleted file mode 100644 index df35b88..0000000 --- a/nut-client.tmpfiles +++ /dev/null @@ -1 +0,0 @@ -D /run/nut 0770 root nut - diff --git a/nut.spec b/nut.spec index 97b5b08..170ba12 100644 --- a/nut.spec +++ b/nut.spec @@ -14,24 +14,20 @@ Summary: Network UPS Tools Name: nut Version: 2.8.0 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2+ and GPLv3+ -Url: http://www.networkupstools.org/ +Url: https://www.networkupstools.org/ Source: https://www.networkupstools.org/source/2.8/%{name}-%{version}.tar.gz -Source3: nut-client.tmpfiles Source4: libs.sh -# Upstream support for OpenSSL-1.1.0, TLS > 1.0 -Patch0: https://patch-diff.githubusercontent.com/raw/networkupstools/nut/pull/504.patch Patch1: nut-2.6.3-tmpfiles.patch +Patch2: nut-2.8.0-piddir-owner.patch #quick fix. TODO: fix it properly -Patch5: nut-2.6.5-dlfix.patch -Patch7: nut-2.6.5-foreground.patch Patch8: nut-2.6.5-unreachable.patch Patch9: nut-2.6.5-rmpidf.patch -Patch10: nut-2.7.4-cloexec.patch -Patch11: nut-2.7.4-nutscanner-FTBFS.patch -Patch12: nut-2.7.4-scratchdes.patch +Patch13: nut-c99-c_attribute.patch +Patch14: nut-c99-ax_c_printf_null.patch +Patch15: nut-c99-strdup.patch Requires(pre): shadow-utils Requires(post): coreutils systemd @@ -80,7 +76,7 @@ BuildRequires: libusb-devel ExcludeArch: s390 s390x -%global restart_flag /run/%{name}/%{name}-restart-after-rpm-install +%global restart_flag %{piddir}/%{name}-restart-after-rpm-install %description These programs are part of a developing project to monitor the assortment @@ -132,15 +128,12 @@ necessary to develop NUT client applications. %prep %setup -q -#patch0 -p1 -b .openssl %patch1 -p1 -b .tmpfiles -#patch5 -p1 -b .dlfix -#%patch7 -p1 -b .foreground %patch8 -p1 -b .unreachable %patch9 -p1 -b .rmpidf -#%patch10 -p1 -b .cloexec -#%patch11 -p1 -b .nutscanner-FTBFS -#%patch12 -p1 -b .scratchdes +%patch13 -p1 +%patch14 -p1 +%patch15 -p1 sed -i 's|=NUT-Monitor|=nut-monitor|' scripts/python/app/nut-monitor-py3qt5.desktop sed -i "s|sys.argv\[0\]|'%{_datadir}/%{name}/nut-monitor/nut-monitor'|" scripts/python/app/NUT-Monitor-py3qt5.in @@ -172,9 +165,9 @@ export LDFLAGS="-Wl,-z,now" --datadir=%{_datadir}/%{name} \ --with-user=%{name} \ --with-group=dialout \ - --with-statepath=/run/nut \ - --with-pidpath=/run/nut \ - --with-altpidpath=/run/nut \ + --with-statepath=%{piddir} \ + --with-pidpath=%{piddir} \ + --with-altpidpath=%{piddir} \ --sysconfdir=%{_sysconfdir}/ups \ --with-cgipath=%{cgidir} \ --with-drvpath=%{modeldir} \ @@ -203,10 +196,6 @@ mkdir -p %{buildroot}%{modeldir} \ %make_install -#if 0%{?fedora} || 0%{?rhel} > 6 -# install -p -D -m 644 %{SOURCE3} %{buildroot}%{_tmpfilesdir}/nut-client.conf -#endif - mv %{buildroot}%{_tmpfilesdir}/nut-common.tmpfiles %{buildroot}%{_tmpfilesdir}/nut-common.conf rm -rf %{buildroot}%{_prefix}/html @@ -403,7 +392,6 @@ fi %dir %{_sysconfdir}/ups %config(noreplace) %attr(640,root,nut) %{_sysconfdir}/ups/upsmon.conf %config(noreplace) %attr(640,root,nut) %{_sysconfdir}/ups/upssched.conf -#{_tmpfilesdir}/nut-client.conf %{_tmpfilesdir}/nut-common.conf %dir %attr(750,nut,nut) %{_localstatedir}/lib/ups # upsmon.pid is written as root, so root needs access for now @@ -467,6 +455,10 @@ fi %{_libdir}/pkgconfig/libnutscan.pc %changelog +* Tue Dec 06 2022 Michal Hlavinka - 2.8.0-2 +- fix STATEPATH location and creation (#2024651) +- merged C99 related changes to configure from fedora + * Tue Sep 13 2022 Michal Hlavinka - 2.8.0-1 - update to 2.8.0 From b761a2932ae8d20d298cbc140dd3fd02974ff9d4 Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Mon, 12 Dec 2022 23:06:36 +0100 Subject: [PATCH 08/11] apply missing patch --- nut.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nut.spec b/nut.spec index 170ba12..bd7e4fc 100644 --- a/nut.spec +++ b/nut.spec @@ -14,7 +14,7 @@ Summary: Network UPS Tools Name: nut Version: 2.8.0 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2+ and GPLv3+ Url: https://www.networkupstools.org/ Source: https://www.networkupstools.org/source/2.8/%{name}-%{version}.tar.gz @@ -129,6 +129,7 @@ necessary to develop NUT client applications. %prep %setup -q %patch1 -p1 -b .tmpfiles +%patch2 -p1 -b .piddir-owner %patch8 -p1 -b .unreachable %patch9 -p1 -b .rmpidf %patch13 -p1 @@ -455,6 +456,9 @@ fi %{_libdir}/pkgconfig/libnutscan.pc %changelog +* Mon Dec 12 2022 Michal Hlavinka - 2.8.0-3 +- apply missing patch + * Tue Dec 06 2022 Michal Hlavinka - 2.8.0-2 - fix STATEPATH location and creation (#2024651) - merged C99 related changes to configure from fedora From f37cf7411e1c50899d32c647d3f11c3fa89e2e64 Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Tue, 14 Feb 2023 21:13:52 +0100 Subject: [PATCH 09/11] add nut-xml to nut recommends (#1379382) --- nut.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nut.spec b/nut.spec index bd7e4fc..1010dc5 100644 --- a/nut.spec +++ b/nut.spec @@ -14,7 +14,7 @@ Summary: Network UPS Tools Name: nut Version: 2.8.0 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2+ and GPLv3+ Url: https://www.networkupstools.org/ Source: https://www.networkupstools.org/source/2.8/%{name}-%{version}.tar.gz @@ -33,6 +33,7 @@ Requires(pre): shadow-utils Requires(post): coreutils systemd Requires(preun): systemd Requires(postun): coreutils systemd +Recommends: nut-xml Obsoletes: nut-hal < 2.6.0-7 BuildRequires: make @@ -456,6 +457,9 @@ fi %{_libdir}/pkgconfig/libnutscan.pc %changelog +* Tue Feb 14 2023 Michal Hlavinka - 2.8.0-4 +- add nut-xml to nut recommends (#1379382) + * Mon Dec 12 2022 Michal Hlavinka - 2.8.0-3 - apply missing patch From 5e78cbec8ba1a21fb36597d657a4aa4d3a1dcabf Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Wed, 29 Nov 2023 10:36:24 +0100 Subject: [PATCH 10/11] fix tmpfiles path in unit file (#2227107) --- nut-2.6.3-tmpfiles.patch | 6 +++--- nut.spec | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nut-2.6.3-tmpfiles.patch b/nut-2.6.3-tmpfiles.patch index 7f7cd98..d1f09b4 100644 --- a/nut-2.6.3-tmpfiles.patch +++ b/nut-2.6.3-tmpfiles.patch @@ -5,7 +5,7 @@ diff -up nut-2.8.0/scripts/systemd/nut-driver-enumerator.service.in.tmpfiles nut # don't want it to fail the unit (when it can't restart). Environment=REPORT_RESTART_42=no EnvironmentFile=-@CONFPATH@/nut.conf -+ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-client.conf ++ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-common.conf ExecStart=@NUT_LIBEXECDIR@/nut-driver-enumerator.sh ExecReload=@NUT_LIBEXECDIR@/nut-driver-enumerator.sh @@ -16,7 +16,7 @@ diff -up nut-2.8.0/scripts/systemd/nut-driver@.service.in.tmpfiles nut-2.8.0/scr [Service] EnvironmentFile=-@CONFPATH@/nut.conf SyslogIdentifier=%N -+ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-client.conf ++ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-common.conf ExecStart=/bin/sh -c 'NUTDEV="`@NUT_LIBEXECDIR@/nut-driver-enumerator.sh --get-device-for-service %i`" && [ -n "$NUTDEV" ] || { echo "FATAL: Could not find a NUT device section for service unit %i" >&2 ; exit 1 ; } ; @SBINDIR@/upsdrvctl start "$NUTDEV"' ExecStop=/bin/sh -c 'NUTDEV="`@NUT_LIBEXECDIR@/nut-driver-enumerator.sh --get-device-for-service %i`" && [ -n "$NUTDEV" ] || { echo "FATAL: Could not find a NUT device section for service unit %i" >&2 ; exit 1 ; } ; @SBINDIR@/upsdrvctl stop "$NUTDEV"' # Restart really always, do not stop trying: @@ -27,7 +27,7 @@ diff -up nut-2.8.0/scripts/systemd/nut-monitor.service.in.tmpfiles nut-2.8.0/scr [Service] EnvironmentFile=-@CONFPATH@/nut.conf SyslogIdentifier=%N -+ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-client.conf ++ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-common.conf ExecStart=@SBINDIR@/upsmon -F ExecReload=@SBINDIR@/upsmon -c reload PIDFile=@PIDPATH@/upsmon.pid diff --git a/nut.spec b/nut.spec index 1010dc5..f099346 100644 --- a/nut.spec +++ b/nut.spec @@ -14,7 +14,7 @@ Summary: Network UPS Tools Name: nut Version: 2.8.0 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2+ and GPLv3+ Url: https://www.networkupstools.org/ Source: https://www.networkupstools.org/source/2.8/%{name}-%{version}.tar.gz @@ -457,6 +457,9 @@ fi %{_libdir}/pkgconfig/libnutscan.pc %changelog +* Wed Nov 29 2023 Michal Hlavinka - 2.8.0-5 +- fix tmpfiles path in unit file (#2227107) + * Tue Feb 14 2023 Michal Hlavinka - 2.8.0-4 - add nut-xml to nut recommends (#1379382) From 65e797e06e42da87fce08027dfa2f15c7e6c4c55 Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Wed, 27 Nov 2024 12:44:49 +0100 Subject: [PATCH 11/11] updated to 2.8.2 --- libs.sh | 2 +- nut-2.6.5-rmpidf.patch | 39 ++++++------ nut-2.8.0-piddir-owner.patch | 80 +++++++++++------------ nut.spec | 120 +++++++++++++++++++++-------------- sources | 2 +- 5 files changed, 136 insertions(+), 107 deletions(-) diff --git a/libs.sh b/libs.sh index a6ca8a8..35a736b 100644 --- a/libs.sh +++ b/libs.sh @@ -28,5 +28,5 @@ do echo "#define $( echo "$l" | tr '[a-z]-' '[A-Z]_')_PATH \"$rp\"" done -VINFO=$(sed -e '/version-info/!d' -e 's/#.*$//' -e 's/^.*-version-info//' -e 's/[[:space:]]//g' clients/Makefile) +VINFO=$(sed -e '/version-info/!d' -e 's/#.*$//' -e 's/^.*-version-info//' -e 's/\\$//' -e 's/[[:space:]]//g' clients/Makefile) echo "#define LIBUPSCLIENT_PATH \"libupsclient.so.$(( ${VINFO%%:*}-${VINFO##*:} ))\"" diff --git a/nut-2.6.5-rmpidf.patch b/nut-2.6.5-rmpidf.patch index 54c6e1e..7755382 100644 --- a/nut-2.6.5-rmpidf.patch +++ b/nut-2.6.5-rmpidf.patch @@ -1,18 +1,18 @@ -diff -up nut-2.8.0/clients/upsmon.c.rmpidf nut-2.8.0/clients/upsmon.c ---- nut-2.8.0/clients/upsmon.c.rmpidf 2022-04-23 13:56:06.000000000 +0200 -+++ nut-2.8.0/clients/upsmon.c 2022-05-09 17:22:34.329547283 +0200 -@@ -2314,6 +2314,7 @@ int main(int argc, char *argv[]) - +diff -up nut-2.8.1/clients/upsmon.c.rmpidf nut-2.8.1/clients/upsmon.c +--- nut-2.8.1/clients/upsmon.c.rmpidf 2023-11-01 10:10:03.039782733 +0100 ++++ nut-2.8.1/clients/upsmon.c 2023-11-01 10:14:48.824806113 +0100 +@@ -3059,6 +3059,7 @@ int main(int argc, char *argv[]) upslogx(LOG_INFO, "Signal %d: exiting", exit_flag); + upsnotify(NOTIFY_STATE_STOPPING, "Signal %d: exiting", exit_flag); upsmon_cleanup(); + cleanpid(prog); exit(EXIT_SUCCESS); } -diff -up nut-2.8.0/common/common.c.rmpidf nut-2.8.0/common/common.c ---- nut-2.8.0/common/common.c.rmpidf 2022-05-09 17:22:34.329547283 +0200 -+++ nut-2.8.0/common/common.c 2022-05-09 17:26:48.671847245 +0200 -@@ -358,6 +358,20 @@ pid_t parsepid(const char *buf) +diff -up nut-2.8.1/common/common.c.rmpidf nut-2.8.1/common/common.c +--- nut-2.8.1/common/common.c.rmpidf 2023-10-30 00:02:33.000000000 +0100 ++++ nut-2.8.1/common/common.c 2023-11-01 10:10:03.040782744 +0100 +@@ -519,6 +519,20 @@ pid_t parsepid(const char *buf) return pid; } @@ -33,10 +33,10 @@ diff -up nut-2.8.0/common/common.c.rmpidf nut-2.8.0/common/common.c /* open pidfn, get the pid, then send it sig * returns negative codes for errors, or * zero for a successfully sent signal -diff -up nut-2.8.0/include/common.h.rmpidf nut-2.8.0/include/common.h ---- nut-2.8.0/include/common.h.rmpidf 2022-05-09 17:22:34.329547283 +0200 -+++ nut-2.8.0/include/common.h 2022-05-09 17:25:47.439740973 +0200 -@@ -103,6 +103,9 @@ void chroot_start(const char *path); +diff -up nut-2.8.1/include/common.h.rmpidf nut-2.8.1/include/common.h +--- nut-2.8.1/include/common.h.rmpidf 2023-10-24 10:45:21.000000000 +0200 ++++ nut-2.8.1/include/common.h 2023-11-01 10:10:03.040782744 +0100 +@@ -211,6 +211,9 @@ void chroot_start(const char *path); /* write a pid file - is a full pathname *or* just the program name */ void writepid(const char *name); @@ -46,14 +46,13 @@ diff -up nut-2.8.0/include/common.h.rmpidf nut-2.8.0/include/common.h /* parses string buffer into a pid_t if it passes * a few sanity checks; returns -1 on error */ pid_t parsepid(const char *buf); -diff -up nut-2.8.0/server/upsd.c.rmpidf nut-2.8.0/server/upsd.c ---- nut-2.8.0/server/upsd.c.rmpidf 2022-04-23 13:56:07.000000000 +0200 -+++ nut-2.8.0/server/upsd.c 2022-05-09 17:22:34.330547269 +0200 -@@ -1515,6 +1515,7 @@ int main(int argc, char **argv) - ssl_cleanup(); +diff -up nut-2.8.1/server/upsd.c.rmpidf nut-2.8.1/server/upsd.c +--- nut-2.8.1/server/upsd.c.rmpidf 2023-11-01 10:10:03.040782744 +0100 ++++ nut-2.8.1/server/upsd.c 2023-11-01 10:15:57.176529218 +0100 +@@ -2137,5 +2137,6 @@ int main(int argc, char **argv) + upsnotify(NOTIFY_STATE_STOPPING, "Signal %d: exiting", exit_flag); - upslogx(LOG_INFO, "Signal %d: exiting", exit_flag); + ssl_cleanup(); + if (*pidfn) cleanpid(pidfn); return EXIT_SUCCESS; } - diff --git a/nut-2.8.0-piddir-owner.patch b/nut-2.8.0-piddir-owner.patch index 61fa75d..53e639d 100644 --- a/nut-2.8.0-piddir-owner.patch +++ b/nut-2.8.0-piddir-owner.patch @@ -1,48 +1,50 @@ -diff -up nut-2.8.0/configure.ac.piddir-owner nut-2.8.0/configure.ac ---- nut-2.8.0/configure.ac.piddir-owner 2022-04-26 18:03:36.000000000 -0400 -+++ nut-2.8.0/configure.ac 2022-11-30 13:29:58.418038393 -0500 -@@ -2833,23 +2833,23 @@ AS_IF([test -n "$systemdtmpfilesdir"], - [mkdir -p "${TOP_BUILDDIR}"/scripts/systemd - cat > "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF - # State file (e.g. upsd to driver) and pidfile location for NUT: --d @STATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - --X @STATEPATH@/nut +diff -up nut-2.8.1/configure.ac.piddir-owner nut-2.8.1/configure.ac +--- nut-2.8.1/configure.ac.piddir-owner 2023-11-01 09:39:24.267596406 +0100 ++++ nut-2.8.1/configure.ac 2023-11-01 10:00:35.425987029 +0100 +@@ -4451,7 +4451,7 @@ AS_IF([test -n "$systemdtmpfilesdir"], + + # See also: https://github.com/networkupstools/nut/wiki/Technicalities:-Work-with-PID-and-state-file-paths#pidpath-altpidpath-statepath + # State file (e.g. upsd to driver pipes) and PID file location for NUT: +-d @STATEPATH@ 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +d @STATEPATH@ 0770 root @RUN_AS_GROUP@ - - -+X @STATEPATH@ - EOF - AS_IF([test "$STATEPATH" != "$PIDPATH"], - [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF --d @PIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - --X @PIDPATH@/nut + # Default PIPEFN and LOCKFN locations per upssched.conf: + d @STATEPATH@/upssched 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - + X @STATEPATH@ +@@ -4461,7 +4461,7 @@ EOF + [*/run|*/tmp|*/shm], [], dnl Do not intrude into system paths; TODO: add more if appropriate for some Linux distro + [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common-tmpfiles.conf.in << EOF + # Primarily used by upsmon and upslog, possibly running as root: +-d @PIDPATH@ 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +d @PIDPATH@ 0770 root @RUN_AS_GROUP@ - - -+X @PIDPATH@ - EOF]) - AS_IF([test -n "$ALTPIDPATH" && test "$STATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTPIDPATH"], - [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF --d @ALTPIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - --X @ALTPIDPATH@/nut + X @PIDPATH@ + EOF + ])]) +@@ -4469,14 +4469,14 @@ EOF + [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common-tmpfiles.conf.in << EOF + # Should be used as upsd and driver PID file location for NUT + # (if ALTPIDPATH differs from STATEPATH): +-d @ALTPIDPATH@ 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +d @ALTPIDPATH@ 0770 root @RUN_AS_GROUP@ - - -+X @ALTPIDPATH@ + X @ALTPIDPATH@ EOF]) + dnl Generally added to support some forks AS_IF([test -n "$ALTSTATEPATH" && test "$STATEPATH" != "$ALTSTATEPATH" && test "$ALTSTATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTSTATEPATH"], - [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF --d @ALTSTATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - --X @ALTSTATEPATH@/nut + [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common-tmpfiles.conf.in << EOF + # Some NUT variants also maintain an ALTSTATEPATH: +-d @ALTSTATEPATH@ 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +d @ALTSTATEPATH@ 0770 root @RUN_AS_GROUP@ - - -+X @ALTSTATEPATH@ + X @ALTSTATEPATH@ EOF]) ]) - AC_MSG_RESULT([done]) -diff -up nut-2.8.0/scripts/systemd/nut-common.tmpfiles.in.piddir-owner nut-2.8.0/scripts/systemd/nut-common.tmpfiles.in ---- nut-2.8.0/scripts/systemd/nut-common.tmpfiles.in.piddir-owner 2022-04-26 18:06:27.000000000 -0400 -+++ nut-2.8.0/scripts/systemd/nut-common.tmpfiles.in 2022-11-30 13:30:11.651106256 -0500 -@@ -1,5 +1,5 @@ - # State file (e.g. upsd to driver) and pidfile location for NUT: --d @STATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - --X @STATEPATH@/nut --d @PIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - --X @PIDPATH@/nut +diff -up nut-2.8.1/scripts/systemd/nut-common-tmpfiles.conf.in.piddir-owner nut-2.8.1/scripts/systemd/nut-common-tmpfiles.conf.in +--- nut-2.8.1/scripts/systemd/nut-common-tmpfiles.conf.in.piddir-owner 2023-10-31 23:05:03.000000000 +0100 ++++ nut-2.8.1/scripts/systemd/nut-common-tmpfiles.conf.in 2023-11-01 10:03:46.970845553 +0100 +@@ -5,7 +5,7 @@ + + # See also: https://github.com/networkupstools/nut/wiki/Technicalities:-Work-with-PID-and-state-file-paths#pidpath-altpidpath-statepath + # State file (e.g. upsd to driver pipes) and PID file location for NUT: +-d @STATEPATH@ 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +d @STATEPATH@ 0770 root @RUN_AS_GROUP@ - - -+X @STATEPATH@ -+d @PIDPATH@ 0770 root @RUN_AS_GROUP@ - - -+X @PIDPATH@ + # Default PIPEFN and LOCKFN locations per upssched.conf: + d @STATEPATH@/upssched 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - + X @STATEPATH@ diff --git a/nut.spec b/nut.spec index f099346..908465d 100644 --- a/nut.spec +++ b/nut.spec @@ -13,20 +13,16 @@ Summary: Network UPS Tools Name: nut -Version: 2.8.0 -Release: 5%{?dist} -License: GPLv2+ and GPLv3+ +Version: 2.8.2 +Release: 1%{?dist} +License: GPL-2.0-or-later AND GPL-3.0-or-later Url: https://www.networkupstools.org/ Source: https://www.networkupstools.org/source/2.8/%{name}-%{version}.tar.gz Source4: libs.sh -Patch1: nut-2.6.3-tmpfiles.patch Patch2: nut-2.8.0-piddir-owner.patch #quick fix. TODO: fix it properly -Patch8: nut-2.6.5-unreachable.patch Patch9: nut-2.6.5-rmpidf.patch -Patch13: nut-c99-c_attribute.patch -Patch14: nut-c99-ax_c_printf_null.patch Patch15: nut-c99-strdup.patch Requires(pre): shadow-utils @@ -51,12 +47,17 @@ BuildRequires: freetype-devel BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: gd-devel +%if 0%{?fedora} < 39 +BuildRequires: libgpiod-devel +%endif BuildRequires: libjpeg-devel BuildRequires: libpng-devel BuildRequires: libtool BuildRequires: libtool-ltdl-devel BuildRequires: libX11-devel BuildRequires: libXpm-devel +BuildRequires: libmodbus-devel +#BuildRequires: libi2c-devel BuildRequires: neon-devel BuildRequires: net-snmp-devel BuildRequires: netpbm-devel @@ -80,10 +81,10 @@ ExcludeArch: s390 s390x %global restart_flag %{piddir}/%{name}-restart-after-rpm-install %description -These programs are part of a developing project to monitor the assortment -of UPSes that are found out there in the field. Many models have serial +These programs are part of a developing project to monitor the assortment +of UPSes that are found out there in the field. Many models have serial ports of some kind that allow some form of state checking. This -capability has been harnessed where possible to allow for safe shutdowns, +capability has been harnessed where possible to allow for safe shutdowns, live status tracking on web pages, and more. %package client @@ -129,13 +130,9 @@ necessary to develop NUT client applications. %prep %setup -q -%patch1 -p1 -b .tmpfiles -%patch2 -p1 -b .piddir-owner -%patch8 -p1 -b .unreachable -%patch9 -p1 -b .rmpidf -%patch13 -p1 -%patch14 -p1 -%patch15 -p1 +%patch -P2 -p1 -b .piddir-owner +%patch -P9 -p1 -b .rmpidf +%patch -P15 -p1 sed -i 's|=NUT-Monitor|=nut-monitor|' scripts/python/app/nut-monitor-py3qt5.desktop sed -i "s|sys.argv\[0\]|'%{_datadir}/%{name}/nut-monitor/nut-monitor'|" scripts/python/app/NUT-Monitor-py3qt5.in @@ -160,10 +157,12 @@ export LDFLAGS="-Wl,-z,now" --with-nss \ %endif --without-wrap \ - --without-modbus \ + --with-modbus \ --without-linux-i2c \ --with-cgi \ - --with-python3 \ + --with-python=%{python3} \ + --with-python3=%{python3} \ + --without-python2 \ --datadir=%{_datadir}/%{name} \ --with-user=%{name} \ --with-group=dialout \ @@ -173,6 +172,9 @@ export LDFLAGS="-Wl,-z,now" --sysconfdir=%{_sysconfdir}/ups \ --with-cgipath=%{cgidir} \ --with-drvpath=%{modeldir} \ +%if 0%{?fedora} > 38 + --without-gpio \ +%endif --with-systemdsystemunitdir=%{_unitdir} \ --with-systemdshutdowndir=/lib/systemd/system-shutdown \ --with-pkgconfig-dir=%{_libdir}/pkgconfig \ @@ -181,6 +183,7 @@ export LDFLAGS="-Wl,-z,now" --libdir=%{_libdir} # --with-doc # does not work in 2.7.1 +# for rhbz#838139 check if still needed? sh %{SOURCE4} >>include/config.h #remove rpath @@ -198,7 +201,7 @@ mkdir -p %{buildroot}%{modeldir} \ %make_install -mv %{buildroot}%{_tmpfilesdir}/nut-common.tmpfiles %{buildroot}%{_tmpfilesdir}/nut-common.conf +#mv %{buildroot}%{_tmpfilesdir}/nut-common.tmpfiles %{buildroot}%{_tmpfilesdir}/nut-common.conf rm -rf %{buildroot}%{_prefix}/html rm -f %{buildroot}%{_libdir}/*.la @@ -206,7 +209,7 @@ rm -rf docs/man rm -rf %{buildroot}%{_datadir}/nut/solaris-init find docs/ -name 'Makefile*' -delete -pushd conf; +pushd conf; %make_install for file in %{buildroot}%{_sysconfdir}/ups/*.sample do @@ -226,8 +229,8 @@ do mv -f $fe.new $fe done -# install PyNUT -install -p -D -m 644 scripts/python/module/PyNUT.py %{buildroot}%{python3_sitelib}/PyNUT.py +# install PyNUT +install -p -D -m 644 scripts/python/module/PyNUT.py %{buildroot}%{python3_sitearch}/PyNUT.py # install nut-monitor %if %{with python2} mkdir -p %{buildroot}%{_datadir}/nut/nut-monitor/pixmaps @@ -239,6 +242,10 @@ desktop-file-install --dir=%{buildroot}%{_datadir}/applications scripts/python/a ln -s %{_datadir}/nut/nut-monitor/nut-monitor %{buildroot}%{_bindir}/nut-monitor %endif +# Setup permissions for pid file +touch %{buildroot}/%{piddir}/upsmon.pid +chmod 0644 %{buildroot}/%{piddir}/upsmon.pid + %pre /usr/sbin/useradd -c "Network UPS Tools" -u %{nut_uid} \ -s /bin/false -r -d %{_localstatedir}/lib/ups %{name} 2> /dev/null || : @@ -254,15 +261,13 @@ fi %post -/sbin/ldconfig -%systemd_post nut-driver.service nut-server.service +%systemd_post nut-driver-enumerator.path nut-driver-enumerator.service nut-driver.target nut-server.service nut.target %preun -%systemd_preun nut-driver.service nut-server.service +%systemd_preun nut-driver-enumerator.path nut-driver-enumerator.service nut-driver.target nut-server.service nut.target -%postun -/sbin/ldconfig -%systemd_postun_with_restart nut-driver.service nut-server.service +%postun +%systemd_postun_with_restart nut-driver.target nut-server.service %pre client /usr/sbin/useradd -c "Network UPS Tools" -u %{nut_uid} \ @@ -275,30 +280,27 @@ fi /usr/sbin/usermod -G dialout,tty %{name} %post client -/sbin/ldconfig -%systemd_post nut-monitor.service +%systemd_post nut-monitor.service nut.target %preun client -%systemd_preun nut-monitor.service +%systemd_preun nut-monitor.service nut.target %postun client -/sbin/ldconfig %systemd_postun_with_restart nut-monitor.service %posttrans # phase 2: start upsmon again -if [ -e %restart_flag ]; then - /bin/systemctl restart nut-monitor.service >/dev/null 2>&1 || : - rm -f %restart_flag +if [ -e %restart_flag ]; then + /bin/systemctl restart nut-monitor.service >/dev/null 2>&1 || : + rm -f %restart_flag else # maybe we did not stop it - if we reinstalled just nut-client - /bin/systemctl try-restart nut-monitor.service >/dev/null 2>&1 || : -fi + /bin/systemctl try-restart nut-monitor.service >/dev/null 2>&1 || : +fi %files %license COPYING LICENSE-GPL2 LICENSE-GPL3 -%doc ChangeLog AUTHORS MAINTAINERS README docs UPGRADING INSTALL NEWS -%config(noreplace) %attr(640,root,nut) %{_sysconfdir}/ups/nut.conf +%doc ChangeLog AUTHORS MAINTAINERS README docs INSTALL NEWS %config(noreplace) %attr(640,root,nut) %{_sysconfdir}/ups/ups.conf %config(noreplace) %attr(640,root,nut) %{_sysconfdir}/ups/upsd.conf %config(noreplace) %attr(640,root,nut) %{_sysconfdir}/ups/upsd.users @@ -308,23 +310,30 @@ fi %exclude %{modeldir}/netxml-ups %{_unitdir}/nut-driver-enumerator.path %{_unitdir}/nut-driver-enumerator.service +%{_unitdir}/nut-driver-enumerator-daemon-activator.path +%{_unitdir}/nut-driver-enumerator-daemon-activator.service +%{_unitdir}/nut-driver-enumerator-daemon.service %{_unitdir}/nut-driver@.service %{_unitdir}/nut-driver.target %{_unitdir}/nut-server.service %{_unitdir}/nut.target %{_sbindir}/upsd +%{_bindir}/nutconf %{_bindir}/nut-scanner -%{_bindir}/upslog %{_libdir}/libnutscan.so.* %{_libexecdir}/nut-driver-enumerator.sh +%{_libexecdir}/sockdebug %{_datadir}/augeas/lenses/dist/nut* %{_datadir}/%{name}/cmdvartab %{_datadir}/%{name}/driver.list -%{_mandir}/man5/nut.conf.5.gz %{_mandir}/man5/ups.conf.5.gz %{_mandir}/man5/upsd.conf.5.gz %{_mandir}/man5/upsd.users.5.gz +%{_mandir}/man8/nutconf.8.gz + +%{_mandir}/man8/adelsystem_cbi.8.gz +%{_mandir}/man8/apc_modbus.8.gz %{_mandir}/man8/al175.8.gz %{_mandir}/man8/apcsmart.8.gz @@ -345,7 +354,12 @@ fi %{_mandir}/man8/everups.8.gz %{_mandir}/man8/etapro.8.gz %{_mandir}/man8/gamatronic.8.gz +%{_mandir}/man8/generic_modbus.8.gz %{_mandir}/man8/genericups.8.gz +%if 0%{?fedora} < 39 +%{_mandir}/man8/generic_gpio.8.gz +%endif +%{_mandir}/man8/huawei-ups2000.8.gz %{_mandir}/man8/isbmex.8.gz %{_mandir}/man8/ivtscd.8.gz %{_mandir}/man8/liebert.8.gz @@ -366,6 +380,7 @@ fi %{_mandir}/man8/nutdrv_qx.8.gz %{_mandir}/man8/oneac.8.gz %{_mandir}/man8/optiups.8.gz +%{_mandir}/man8/phoenixcontact_modbus.8.gz %{_mandir}/man8/powercom.8.gz %if %{with powerman} %{_mandir}/man8/powerman-pdu.8.gz @@ -376,8 +391,11 @@ fi %{_mandir}/man8/riello_ser.8.gz %{_mandir}/man8/riello_usb.8.gz %{_mandir}/man8/safenet.8.gz +%{_mandir}/man8/sms_ser.8.gz %{_mandir}/man8/snmp-ups.8.gz %{_mandir}/man8/solis.8* +%{_mandir}/man8/sockdebug.8.gz +%{_mandir}/man8/socomec_jbus.8.gz %{_mandir}/man8/tripplite.8.gz %{_mandir}/man8/tripplite_usb.8.gz %{_mandir}/man8/tripplitesu.8.gz @@ -386,37 +404,44 @@ fi %{_mandir}/man8/upsd.8.gz %{_mandir}/man8/upsdrvctl.8.gz %{_mandir}/man8/upsdrvsvcctl.8.gz -%{_mandir}/man8/upslog.8.gz %{_mandir}/man8/usbhid-ups.8.gz %files client %license COPYING LICENSE-GPL2 LICENSE-GPL3 %dir %{_sysconfdir}/ups +%config(noreplace) %attr(640,root,nut) %{_sysconfdir}/ups/nut.conf %config(noreplace) %attr(640,root,nut) %{_sysconfdir}/ups/upsmon.conf %config(noreplace) %attr(640,root,nut) %{_sysconfdir}/ups/upssched.conf -%{_tmpfilesdir}/nut-common.conf +%{_tmpfilesdir}/nut-common-tmpfiles.conf %dir %attr(750,nut,nut) %{_localstatedir}/lib/ups # upsmon.pid is written as root, so root needs access for now -%ghost %attr(770,root,nut) %{piddir} +%dir %attr(770,root,dialout) %{piddir} +%attr(644,nut,nut) %verify(not size mtime md5) /run/%{name}/upsmon.pid %{_bindir}/upsc %{_bindir}/upscmd +%{_bindir}/upslog %{_bindir}/upsrw %{_sbindir}/upsmon %{_sbindir}/upssched %{_bindir}/upssched-cmd %{_unitdir}/nut-monitor.service +# nut-monitor.service also needs nut.target +%{_unitdir}/nut.target /lib/systemd/system-shutdown/nutshutdown %{_libdir}/libupsclient.so.* %{_libdir}/libnutclient.so.* %{_libdir}/libnutclientstub.so.* +%{_mandir}/man5/nut.conf.5.gz %{_mandir}/man5/upsmon.conf.5.gz %{_mandir}/man5/upssched.conf.5.gz %{_mandir}/man8/upsc.8.gz %{_mandir}/man8/upscmd.8.gz +%{_mandir}/man8/upslog.8.gz %{_mandir}/man8/upsrw.8.gz %{_mandir}/man8/upsmon.8.gz %{_mandir}/man8/upssched.8.gz -%pycached %{python3_sitelib}/PyNUT.py +%pycached %{python3_sitearch}/PyNUT.py +%pycached %{python3_sitearch}/test_nutclient.py %{_datadir}/nut %if %{with python2} %{_bindir}/nut-monitor @@ -457,6 +482,9 @@ fi %{_libdir}/pkgconfig/libnutscan.pc %changelog +* Wed Nov 27 2024 Michal Hlavinka - 2.8.2-1 +- updated to 2.8.2 + * Wed Nov 29 2023 Michal Hlavinka - 2.8.0-5 - fix tmpfiles path in unit file (#2227107) diff --git a/sources b/sources index 3574636..474d28c 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nut-2.8.0.tar.gz) = 3c413ae54088045a713eb80cf1bdda474f41bb3b67c7c0248aa7a0c4d441dce1ff42627a2735273d7e36892d1f2eeb895220cf28af63fec2fa0c7a267f82d577 +SHA512 (nut-2.8.2.tar.gz) = b6f8f22318e4a4fcb8073a63132b1cb083952c665191b82a7d6765a61b859575a4b0c2ba84ed17cfb8c88d34179876d64520dd2f75f02fe8707b406da2c0821c