diff --git a/nut-2.4.3-portcrash.patch b/nut-2.4.3-portcrash.patch new file mode 100644 index 0000000..d6b66fa --- /dev/null +++ b/nut-2.4.3-portcrash.patch @@ -0,0 +1,13 @@ +~/cvsf/nut/devel ~/cvsf/nut/devel +diff -up nut-2.4.3/drivers/upsdrvctl.c.portcrash nut-2.4.3/drivers/upsdrvctl.c +--- nut-2.4.3/drivers/upsdrvctl.c.portcrash 2010-07-26 11:38:19.830941009 +0200 ++++ nut-2.4.3/drivers/upsdrvctl.c 2010-07-26 11:39:32.302764246 +0200 +@@ -131,7 +131,7 @@ static void stop_driver(const ups_t *ups + ups->driver, ups->upsname); + ret = stat(pidfn, &fs); + +- if (ret != 0) { ++ if ((ret != 0) && (ups->port != NULL)) { + snprintf(pidfn, sizeof(pidfn), "%s/%s-%s.pid", altpidpath(), + ups->driver, xbasename(ups->port)); + ret = stat(pidfn, &fs); diff --git a/nut.spec b/nut.spec index 13194cb..c1e0f36 100644 --- a/nut.spec +++ b/nut.spec @@ -9,7 +9,7 @@ Summary: Network UPS Tools Name: nut Version: 2.2.0 -Release: 6%{?dist} +Release: 7%{?dist} Group: Applications/System License: GPLv2+ Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -25,6 +25,9 @@ Patch3: nut-2.2.0-glibcopen.patch Patch4: nut-2.2.0-wrongssl.patch Patch5: nut-2.2.0-trippliteusb_476850.patch +# for nut <= 2.4.3, rhbz#616375 +Patch6: nut-2.4.3-portcrash.patch + Requires: nut-client => 2.0.0 hal dbus-glib shadow-utils Requires(post): fileutils chkconfig /sbin/service Requires(postun): fileutils chkconfig /sbin/service @@ -83,7 +86,7 @@ Requires: %{name}-client = %{version}-%{release} webserver openssl-devel %description devel This package contains the development header files and libraries necessary to develop NUT client applications. - + %prep %setup -q %patch0 -p1 -b .conf @@ -92,6 +95,7 @@ necessary to develop NUT client applications. %patch3 -p1 -b .open %patch4 -p1 -b .wrongssl %patch5 -p1 -b .trippliteusb_476850 +%patch6 -p1 -b .portcrash %build %configure \ @@ -253,6 +257,7 @@ rm -rf %{buildroot} %{_mandir}/man8/usbhid-ups.8.gz %files client +%doc COPYING %defattr(-,root,root) %attr(755,root,root) %{initdir}/ups %dir %{_sysconfdir}/ups @@ -299,6 +304,10 @@ rm -rf %{buildroot} %{_libdir}/pkgconfig/libupsclient.pc %changelog +* Mon Jul 26 2010 Michal Hlavinka 2.2.0-7 +- fix crash when port= is ommited (#616375) +- fix issue where nut fails to restart because it did not finished termination + * Mon Jan 05 2009 Michal Hlavinka 2.2.0-6 - fix #476850 - tripplite_usb driver segfaults when UPS on battery diff --git a/ups.init b/ups.init index 3b60857..939c4dc 100644 --- a/ups.init +++ b/ups.init @@ -1,11 +1,14 @@ #! /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. - +# interface for monitoring and administering UPS hardware. # processname: upsd # config: /etc/ups/ +# config: /etc/sysconfig/ups +# # Source function library. if [ -f /etc/init.d/functions ]; then @@ -39,14 +42,14 @@ start() { echo echo -n $"Starting UPS monitor (master): " - daemon /usr/sbin/upsmon > /dev/null 2>&1 && success || failure + 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 /usr/sbin/upsmon > /dev/null 2>&1 && success || failure + daemon --pidfile /var/run/nut/upsmon.pid /usr/sbin/upsmon > /dev/null 2>&1 && success || failure echo fi @@ -55,7 +58,7 @@ start() { stop() { echo -n $"Stopping UPS monitor: " - killproc upsmon + killproc -p /var/run/nut/upsmon.pid upsmon echo if [ "$SERVER" = "yes" ]; then @@ -77,6 +80,12 @@ stop() { restart() { stop + waitmore=5 + while [ -n "$(ls /var/run/nut/)" -a $waitmore -ge 1 ] + do + sleep 1 + waitmore=$((waitmore-1)) + done start }