Compare commits

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

1 commit

Author SHA1 Message Date
Troy Dawson
99859d197a epel8-playground decommissioned : https://pagure.io/epel/issue/136 2022-01-31 11:55:25 -08:00
15 changed files with 1 additions and 1653 deletions

11
.gitignore vendored
View file

@ -1,11 +0,0 @@
nut-2.4.3.tar.gz
/nut-2.6.0.tar.gz
/nut-2.6.1.tar.gz
/nut-2.6.2.tar.gz
/nut-2.6.3.tar.gz
/nut-2.6.4.tar.gz
/nut-2.6.5.tar.gz
/nut-2.7.1.tar.gz
/nut-2.7.2.tar.gz
/nut-2.7.3.tar.gz
/nut-2.7.4.tar.gz

1
dead.package Normal file
View file

@ -0,0 +1 @@
epel8-playground decommissioned : https://pagure.io/epel/issue/136

32
libs.sh
View file

@ -1,32 +0,0 @@
#!/bin/sh
for l in libavahi-client libfreeipmi libusb libnetsnmp libneon
do
rp=""
for p in /usr/lib64 /lib64 /usr/lib /lib
do
if [ -f ${p}/${l}.so ]
then
fn=$( readlink ${p}/${l}.so )
mfn=${fn%.so.*}.so
sfn=${fn##*.so.}
tfn=$mfn
while [ $tfn = ${l}.so ] || [ ! -f ${p}/${tfn} -a -n "$sfn" ]
do
tfn=${tfn}.${sfn%%.*}
sfn=${sfn#*.}
done
if [ -f ${p}/${tfn} ]
then
rp=${tfn}
else
rp=${fn}
fi
break
fi
done
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)
echo "#define LIBUPSCLIENT_PATH \"libupsclient.so.$(( ${VINFO%%:*}-${VINFO##*:} ))\""

View file

@ -1,22 +0,0 @@
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]
+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
[Service]
+ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-client.conf
ExecStart=@SBINDIR@/upsmon
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,12 +0,0 @@
diff -up nut-2.7.3/configure.ac.quickfix nut-2.7.3/configure.ac
--- nut-2.7.3/configure.ac.quickfix 2015-04-23 12:05:21.219228670 +0200
+++ nut-2.7.3/configure.ac 2015-04-23 12:05:21.230228646 +0200
@@ -1065,7 +1065,7 @@ dnl Override installation directory, wit
dnl prefix. This is needed for 'distcheck*' targets, otherwise
dnl files will try to get intalled to the actual system directories
if test -n "${systemdsystemunitdir}"; then
- systemdsystemshutdowndir="${libdir}/systemd/system-shutdown"
+ systemdsystemshutdowndir="/lib/systemd/system-shutdown"
AC_MSG_RESULT(using ${systemdsystemunitdir})
else
AC_MSG_RESULT(no)

View file

@ -1,59 +0,0 @@
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[])
upslogx(LOG_INFO, "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);
}
+/* remove pid file */
+void cleanpid(const char *name)
+{
+ 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);
+
+ 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);
/* 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);
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,39 +0,0 @@
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 :
self.gui_status_notification( _("Device '%s' not found on server") % self.__current_ups, "warning.png" )
return
+ if not self.__ups_handler.CheckUPSAvailable( self.__current_ups ):
+ self.gui_status_message( _("UPS '{0}' is not reachable").format( self.__current_ups ) )
+ self.gui_status_notification( _("UPS '{0}' is not reachable").format( self.__current_ups ), "warning.png" )
+ return
+
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.
return( ups_vars )
+ def CheckUPSAvailable( self, ups="") :
+ """ Check whether UPS is reachable
+
+Just tries to contact UPS with safe command.
+The result is True (rechable) or False (unreachable)
+ """
+ self.__srv_handler.write( "LIST CMD %s\n" % ups )
+ result = self.__srv_handler.read_until( "\n" )
+ if result != "BEGIN LIST CMD %s\n" % ups :
+ return False
+
+ 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 +0,0 @@
D /var/run/nut 0770 root nut -

1085
nut.spec

File diff suppressed because it is too large Load diff

View file

@ -1 +0,0 @@
3ba53656933d7471f95140b32a5b8d5c nut-2.7.4.tar.gz

147
ups.init
View file

@ -1,147 +0,0 @@
#! /bin/bash
#
# ups: Starts the Network UPS Tools
#
# chkconfig: - 26 74
# description: Network UPS Tools is a collection of programs which provide a common \
# interface for monitoring and administering UPS hardware.
# processname: upsd
# config: /etc/ups/
# config: /etc/sysconfig/ups
#
### BEGIN INIT INFO
# Provides: ups
# Required-Start: $syslog $network $named
# Required-Stop: $local_fs
# Default-Stop: 0 1 6
# Short-Description: Starts the Network UPS tools
# Description: Network UPS Tools is a collection of programs which provide a common \
# interface for monitoring and administering UPS hardware.
### END INIT INFO
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
else
exit 0
fi
# Get config.
if [ -f /etc/sysconfig/ups ]; then
. /etc/sysconfig/ups
else
SERVER="no"
fi
start() {
if [ "$SERVER" = "yes" ]; then
echo -n $"Starting UPS driver controller: "
daemon /sbin/upsdrvctl start > /dev/null 2>&1 && success || failure
RETVAL=$?
echo
prog="upsd"
echo -n $"Starting $prog: "
daemon /usr/sbin/upsd $UPSD_OPTIONS > /dev/null 2>&1 && success || failure
if [ "$RETVAL" = 0 ]; then
RETVAL=$?
fi
echo
echo -n $"Starting UPS monitor (master): "
daemon --pidfile /var/run/nut/upsmon.pid /usr/sbin/upsmon > /dev/null 2>&1 && success || failure
if [ "$RETVAL" = 0 ]; then
RETVAL=$?
fi
echo
else
echo -n $"Starting UPS monitor (slave): "
daemon --pidfile /var/run/nut/upsmon.pid /usr/sbin/upsmon > /dev/null 2>&1 && success || failure
echo
fi
[ "$RETVAL" = 0 ] && touch /var/lock/subsys/ups
}
stop() {
echo -n $"Stopping UPS monitor: "
killproc -p /var/run/nut/upsmon.pid upsmon
echo
if [ "$SERVER" = "yes" ]; then
prog="upsd"
echo -n $"Stopping $prog: "
killproc upsd > /dev/null 2>&1 && success || failure
RETVAL=$?
echo
echo -n $"Shutting down UPS driver controller: "
/sbin/upsdrvctl stop > /dev/null 2>&1 && success || failure
if [ "$RETVAL" = 0 ]; then
RETVAL=$?
fi
echo
fi
[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/ups
}
restart() {
stop
waitmore=5
while [ -n "$(ls /var/run/nut/)" -a $waitmore -ge 1 ]
do
sleep 1
waitmore=$((waitmore-1))
done
start
}
reload() {
# FIXME: upsd and upsmon always return 0
# => can't tell if reload was successful
if [ "$SERVER" = "yes" ]; then
action "Reloading upsd:" /usr/sbin/upsd -c reload
RETVAL=$?
fi
action "Reloading upsmon:" /usr/sbin/upsmon -c reload
if [ "$RETVAL" = 0 ]; then
RETVAL=$?
fi
}
# See how we are called.
case "$1" in
start)
start ;;
stop)
stop ;;
restart)
restart ;;
try-restart)
[ -f /var/lock/subsys/ups ] && restart || :
;;
reload)
reload ;;
force-reload)
restart ;;
status)
if [ "$SERVER" = "yes" ]; then
status upsd
fi
status upsmon
;;
*)
echo $"Usage: $0 {start|stop|restart|try-restart|reload|force-reload|status}"
RETVAL=3
esac
exit $RETVAL

View file

@ -1,8 +0,0 @@
# If the UPS is locally attached set it to "yes"
SERVER=yes
# Any options to pass to upsd
UPSD_OPTIONS=
# This *must* be the same as in /etc/ups/upsmon.conf
POWERDOWNFLAG=/etc/killpower
#
# [End]