Compare commits

...
Sign in to create a new pull request.

16 commits

Author SHA1 Message Date
Michal Hlavinka
65e797e06e updated to 2.8.2 2024-11-27 12:44:49 +01:00
Michal Hlavinka
5e78cbec8b fix tmpfiles path in unit file (#2227107) 2023-11-29 10:36:24 +01:00
Michal Hlavinka
af7c7cf0e9 Merge branch 'epel8' into epel9 2023-02-14 21:31:31 +01:00
Michal Hlavinka
f37cf7411e add nut-xml to nut recommends (#1379382) 2023-02-14 21:13:52 +01:00
Michal Hlavinka
a686358628 Merge branch 'epel8' into epel9 2022-12-12 23:15:32 +01:00
Michal Hlavinka
b761a2932a apply missing patch 2022-12-12 23:06:36 +01:00
Michal Hlavinka
7ebc81e5c7 Merge branch 'epel8' into epel9 2022-12-06 23:11:14 +01:00
Michal Hlavinka
3aa7b876a5 fix STATEPATH location and creation (#2024651)
merged C99 related changes to configure from fedora
2022-12-06 22:53:51 +01:00
Michal Hlavinka
833cbe1e9c Merge branch 'epel8' into epel9 2022-11-09 10:12:58 +01:00
Michal Hlavinka
5f339ebaff update to 2.8.0 2022-09-13 20:28:16 +02:00
Orion Poplawski
9d502dbf9e Drop old conditional 2022-01-24 19:06:38 -07:00
Troy Dawson
308ab912ca remove package.cfg per new epel-playground policy 2020-09-24 16:58:08 +00:00
Michal Hlavinka
42618a5303 nut user needs tty group for wall (#1774591) 2020-06-02 20:18:15 +02:00
Michal Hlavinka
ce790c9866 change pid dir from /var/run/nut to /run/nut 2020-02-12 15:32:48 +01:00
Orion Poplawski
a1134bf756 Merge branch 'master' into epel8 2019-10-16 09:40:44 -06:00
Mohan Boddu
ae3b0a6646 Adding package.cfg file
Signed-off-by: Mohan Boddu <mboddu@bhujji.com>
2019-08-01 12:35:00 -04:00
18 changed files with 332 additions and 785 deletions

1
.gitignore vendored
View file

@ -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

333
504.patch
View file

@ -1,333 +0,0 @@
From da1f5aa699f54e0f6977ab64a3bc2f90a51c3104 Mon Sep 17 00:00:00 2001
From: Arjen de Korte <build+lede@de-korte.org>
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 <build+lede@de-korte.org>
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 <build+lede@de-korte.org>
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 <build+github@de-korte.org>
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 <build+github@de-korte.org>
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 <build+github@de-korte.org>
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 <build+github@de-korte.org>
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

View file

@ -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##*:} ))\""

View file

@ -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
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-common.conf
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]
+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
EnvironmentFile=-@CONFPATH@/nut.conf
SyslogIdentifier=%N
+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:
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]
+ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-client.conf
ExecStart=@SBINDIR@/upsmon
EnvironmentFile=-@CONFPATH@/nut.conf
SyslogIdentifier=%N
+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
Type=forking

View file

@ -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 <ltdl.h>
/* 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;

View file

@ -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 <dir> chroots to <dir>\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 {

View file

@ -1,59 +1,58 @@
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.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.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.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;
}
+/* 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.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 - <name> 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);
/* 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.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);
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)
ssl_cleanup();
upslogx(LOG_INFO, "Signal %d: exiting", exit_flag);
+ if (*pidfn) cleanpid(pidfn);
return EXIT_SUCCESS;
}

View file

@ -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 <h
self.gui_status_notification( _("Device '%s' not found on server") % self.__current_ups, "warning.png" )
return
@ -13,10 +13,10 @@ diff -up nut-2.6.5/scripts/python/app/NUT-Monitor.unreachable nut-2.6.5/scripts/
self.__connected = True
self.__widgets["ups_connect"].hide()
self.__widgets["ups_disconnect"].show()
diff -up nut-2.6.5/scripts/python/module/PyNUT.py.unreachable nut-2.6.5/scripts/python/module/PyNUT.py
--- nut-2.6.5/scripts/python/module/PyNUT.py.unreachable 2012-07-31 19:38:56.000000000 +0200
+++ nut-2.6.5/scripts/python/module/PyNUT.py 2013-01-07 17:41:26.548440712 +0100
@@ -158,6 +158,20 @@ available vars.
diff -up nut-2.8.0/scripts/python/module/PyNUT.py.in.unreachable nut-2.8.0/scripts/python/module/PyNUT.py.in
--- nut-2.8.0/scripts/python/module/PyNUT.py.in.unreachable 2022-05-09 17:20:32.100323526 +0200
+++ nut-2.8.0/scripts/python/module/PyNUT.py.in 2022-05-09 17:21:35.505402117 +0200
@@ -170,6 +170,21 @@ available vars.
return( ups_vars )
@ -33,6 +33,7 @@ diff -up nut-2.6.5/scripts/python/module/PyNUT.py.unreachable nut-2.6.5/scripts/
+
+ self.__srv_handler.read_until( "END LIST CMD %s\n" % ups )
+ return True
+
+
def GetUPSCommands( self, ups="" ) :
""" Get all available commands for the specified UPS

View file

@ -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 <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <fcntl.h>
#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 <sys/stat.h>
#include <sys/wait.h>
#include <sys/socket.h>
+#include <unistd.h>
+#include <fcntl.h>
#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 <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
+#include <unistd.h>
+#include <fcntl.h>
#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);

View file

@ -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)

View file

@ -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);
}

View file

@ -0,0 +1,50 @@
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@ - -
# 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
])])
@@ -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@
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.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@
EOF])
])
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@ - -
# Default PIPEFN and LOCKFN locations per upssched.conf:
d @STATEPATH@/upssched 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - -
X @STATEPATH@

View file

@ -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 <string.h> instead of <strings.h>. Add missing braces
and parentheses. Use double-quote for string literals.
Submitted upstream: <https://github.com/networkupstools/nut/pull/1720>
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 <stdio.h>
-#include <strings.h>
-], [dnl
+#include <string.h>
+], [[
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]
)]

17
nut-c99-c_attribute.patch Normal file
View file

@ -0,0 +1,17 @@
Call the defined foo function instead of the undeclared func function.
Submitted upstream: <https://github.com/networkupstools/nut/pull/1720>
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]
)

17
nut-c99-strdup.patch Normal file
View file

@ -0,0 +1,17 @@
Fix strdup configure test: Remove a call to the undeclared free
function.
Submitted upstream: <https://github.com/networkupstools/nut/pull/1720>
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;" */
]])],

View file

@ -1 +0,0 @@
D /run/nut 0770 root nut -

233
nut.spec
View file

@ -6,43 +6,36 @@
%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
Summary: Network UPS Tools
Name: nut
Version: 2.7.4
Release: 44%{?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
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
# 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
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
Patch15: nut-c99-strdup.patch
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
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: augeas-libs
BuildRequires: avahi-devel
BuildRequires: cppunit-devel
BuildRequires: dbus-glib-devel
@ -54,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
@ -72,6 +70,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
@ -79,13 +78,13 @@ BuildRequires: libusb-devel
ExcludeArch: s390 s390x
%global restart_flag /var/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
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
@ -131,26 +130,15 @@ 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
%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
%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.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}
@ -169,7 +157,12 @@ export LDFLAGS="-Wl,-z,now"
--with-nss \
%endif
--without-wrap \
--with-modbus \
--without-linux-i2c \
--with-cgi \
--with-python=%{python3} \
--with-python3=%{python3} \
--without-python2 \
--datadir=%{_datadir}/%{name} \
--with-user=%{name} \
--with-group=dialout \
@ -179,13 +172,18 @@ 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 \
--disable-static \
--with-udev-dir=%{_usr}/lib/udev \
--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
@ -203,16 +201,15 @@ 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
rm -f %{buildroot}%{_libdir}/*.la
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
@ -232,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
@ -245,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 || :
@ -260,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} \
@ -281,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
@ -312,18 +308,33 @@ 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-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
%{_mandir}/man8/apcsmart-old.8.gz
@ -343,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
@ -351,16 +367,20 @@ 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
%{_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
@ -371,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
@ -380,38 +403,45 @@ fi
%{_mandir}/man8/upscode2.8*
%{_mandir}/man8/upsd.8.gz
%{_mandir}/man8/upsdrvctl.8.gz
%{_mandir}/man8/upslog.8.gz
%{_mandir}/man8/upsdrvsvcctl.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
%if 0%{?fedora} || 0%{?rhel} > 6
%{_tmpfilesdir}/nut-client.conf
%endif
%{_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
@ -444,69 +474,36 @@ 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
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.7.4-44
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Wed Nov 27 2024 Michal Hlavinka <mhlavink@redhat.com> - 2.8.2-1
- updated to 2.8.2
* Thu Sep 23 2021 Miro Hrončok <mhroncok@redhat.com> - 2.7.4-43
- Don't own /usr/lib/python3.X/site-packages
* Wed Nov 29 2023 Michal Hlavinka <mhlavink@redhat.com> - 2.8.0-5
- fix tmpfiles path in unit file (#2227107)
* Tue Sep 14 2021 Sahana Prasad <sahana@redhat.com> - 2.7.4-42
- Rebuilt with OpenSSL 3.0.0
* Tue Feb 14 2023 Michal Hlavinka <mhlavink@redhat.com> - 2.8.0-4
- add nut-xml to nut recommends (#1379382)
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.7.4-41
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Mon Dec 12 2022 Michal Hlavinka <mhlavink@redhat.com> - 2.8.0-3
- apply missing patch
* Tue Jun 08 2021 Michal Hlavinka <mhlavink@redhat.com> - 2.7.4-40
- drop snmp-ups support for DES, as required net-snmp no longer supports it
* Tue Dec 06 2022 Michal Hlavinka <mhlavink@redhat.com> - 2.8.0-2
- fix STATEPATH location and creation (#2024651)
- merged C99 related changes to configure from fedora
* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 2.7.4-39
- Rebuilt for Python 3.10
* Tue Sep 13 2022 Michal Hlavinka <mhlavink@redhat.com> - 2.8.0-1
- update to 2.8.0
* Tue Mar 02 2021 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.7.4-38
- Rebuilt for updated systemd-rpm-macros
See https://pagure.io/fesco/issue/2583.
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.7.4-37
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Sep 15 2020 Jeff Law <law@redhat.com> - 2.7.4-36
- Force C++14 as this code is not C++17 ready
* Wed Sep 02 2020 Josef Ridky <jridky@redhat.com> - 2.7.4-35
- Resolves: #1865077 - FTBFS in Fedora 33
- Rebuilt for new release of net-snmp
* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.7.4-34
- Second attempt - Rebuilt for
https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.7.4-33
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jun 02 2020 Michal Hlavinka <mhlavink@redhat.com> - 2.7.4-32
* Tue Jun 02 2020 Michal Hlavinka <mhlavink@redhat.com> - 2.7.4-27
- nut user needs tty group for wall (#1774591)
* Tue Jun 02 2020 Michal Hlavinka <mhlavink@redhat.com> - 2.7.4-31
- update tmpfiles nut run directory
* Tue May 26 2020 Orion Poplawski <orion@nwra.com> - 2.7.4-30
- Drop old udev requires/scriptlet
* Tue May 26 2020 Orion Poplawski <orion@nwra.com> - 2.7.4-29
- Add upstream patch for OpenSSL 1.1.0 support, enable for Fedora >= 33
* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 2.7.4-28
- Rebuilt for Python 3.9
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.7.4-27
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Fri Oct 04 2019 Michal Hlavinka <mhlavink@redhat.com> - 2.7.4-26
- drop pygtk2 requirements

View file

@ -1 +1 @@
3ba53656933d7471f95140b32a5b8d5c nut-2.7.4.tar.gz
SHA512 (nut-2.8.2.tar.gz) = b6f8f22318e4a4fcb8073a63132b1cb083952c665191b82a7d6765a61b859575a4b0c2ba84ed17cfb8c88d34179876d64520dd2f75f02fe8707b406da2c0821c