From 0210417761a5778e0b0981b804c321b76f4d7928 Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Nov 23 2015 13:16:59 +0000 Subject: fix apcaccess crash if apcupsd is not running (#1236367,#1197383) - enabled modbus-usb (#1195071) - add bigger icon (#1157532) --- diff --git a/apcupsd-3.14.13-netopenfix.patch b/apcupsd-3.14.13-netopenfix.patch new file mode 100644 index 0000000..face793 --- /dev/null +++ b/apcupsd-3.14.13-netopenfix.patch @@ -0,0 +1,63 @@ +diff -up apcupsd-3.14.13/src/apcaccess.c.netopenfix apcupsd-3.14.13/src/apcaccess.c +--- apcupsd-3.14.13/src/apcaccess.c.netopenfix 2015-11-23 13:03:18.960051659 +0100 ++++ apcupsd-3.14.13/src/apcaccess.c 2015-11-23 13:07:37.225759158 +0100 +@@ -49,7 +49,7 @@ static int do_pthreads_status(const char + char recvline[MAXSTRING + 1]; + char *line; + +- if ((sockfd = net_open(host, NULL, port)) == INVALID_SOCKET) { ++ if ((sockfd = net_open(host, NULL, port)) < 0) { + fprintf(stderr, "Error contacting apcupsd @ %s:%d: %s\n", + host, port, strerror(-sockfd)); + return 1; +diff -up apcupsd-3.14.13/src/cgi/upsfetch.c.netopenfix apcupsd-3.14.13/src/cgi/upsfetch.c +--- apcupsd-3.14.13/src/cgi/upsfetch.c.netopenfix 2015-11-23 13:09:20.108837721 +0100 ++++ apcupsd-3.14.13/src/cgi/upsfetch.c 2015-11-23 13:09:20.153838193 +0100 +@@ -114,7 +114,7 @@ static int fetch_data(const char *host) + *p++ = '\0'; + nis_port = atoi(p); + } +- if ((sockfd = net_open(lhost, NULL, nis_port)) == INVALID_SOCKET) { ++ if ((sockfd = net_open(lhost, NULL, nis_port)) < 0) { + (void) snprintf(errmsg, sizeof (errmsg), + "upsfetch: tcp_open failed for %s port %d", lhost, nis_port); + return 0; +@@ -153,7 +153,7 @@ int fetch_events(const char *host) + *p++ = '\0'; + nis_port = atoi(p); + } +- if ((sockfd = net_open(lhost, NULL, nis_port)) == INVALID_SOCKET) { ++ if ((sockfd = net_open(lhost, NULL, nis_port)) < 0) { + snprintf(errmsg, sizeof(errmsg), + "upsfetch: tcp_open failed for %s port %d", lhost, nis_port); + fputs(errmsg, stdout); +diff -up apcupsd-3.14.13/src/drivers/net/net.c.netopenfix apcupsd-3.14.13/src/drivers/net/net.c +--- apcupsd-3.14.13/src/drivers/net/net.c.netopenfix 2015-11-23 13:09:33.997983325 +0100 ++++ apcupsd-3.14.13/src/drivers/net/net.c 2015-11-23 13:09:34.041983787 +0100 +@@ -202,7 +202,7 @@ bool NetUpsDriver::poll_ups() + _statlen = 0; + + Dmsg(20, "Opening connection to %s:%d\n", _hostname, _port); +- if ((_sockfd = net_open(_hostname, NULL, _port)) == INVALID_SOCKET) { ++ if ((_sockfd = net_open(_hostname, NULL, _port)) < 0) { + Dmsg(90, "Exit poll_ups 0 comm lost\n"); + if (!_ups->is_commlost()) { + _ups->set_commlost(); +diff -up apcupsd-3.14.13/src/lib/statmgr.cpp.netopenfix apcupsd-3.14.13/src/lib/statmgr.cpp +--- apcupsd-3.14.13/src/lib/statmgr.cpp.netopenfix 2015-11-23 13:08:48.076501913 +0100 ++++ apcupsd-3.14.13/src/lib/statmgr.cpp 2015-11-23 13:08:48.105502218 +0100 +@@ -199,12 +199,12 @@ bool StatMgr::open() + close(); + + m_socket = net_open(m_host, NULL, m_port); +- return m_socket != INVALID_SOCKET; ++ return m_socket >= 0; + } + + void StatMgr::close() + { +- if (m_socket != INVALID_SOCKET) { ++ if (m_socket != INVALID_SOCKET && m_socket >= 0) { + net_close(m_socket); + m_socket = INVALID_SOCKET; + } diff --git a/apcupsd.spec b/apcupsd.spec index 10c6299..cc571a5 100644 --- a/apcupsd.spec +++ b/apcupsd.spec @@ -1,6 +1,6 @@ Name: apcupsd Version: 3.14.13 -Release: 3%{?dist} +Release: 4%{?dist} Summary: APC UPS Power Control Daemon for Linux Group: System Environment/Daemons @@ -9,6 +9,7 @@ URL: http://www.apcupsd.com Source0: http://downloads.sourceforge.net/apcupsd/%{name}-%{version}.tar.gz Source1: apcupsd.logrotate Source2: apcupsd-httpd.conf +Source3: apcupsd64x64.png Patch0: apcupsd-3.14.3-init.patch Patch1: apcupsd-3.14.4-shutdown.patch @@ -17,11 +18,12 @@ Patch3: apcupsd-3.14.8-systemd.patch # fix crash in gui, rhbz#578276 Patch4: apcupsd-3.14.9-fixgui.patch +Patch5: apcupsd-3.14.13-netopenfix.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: glibc-devel >= 2.3, gd-devel > 2.0 -BuildRequires: net-snmp-devel, tcp_wrappers-devel +BuildRequires: net-snmp-devel, tcp_wrappers-devel, libusb-devel BuildRequires: gtk2-devel, gnome-vfs2-devel, desktop-file-utils Requires: /bin/mail Requires(post): systemd-units @@ -65,6 +67,7 @@ A GUI interface to the APC UPS monitoring daemon. %patch1 -p1 -b .shutdown %patch3 -p1 -b .systemd %patch4 -p1 -b .fixgui +%patch5 -p1 -b .netopenfix #we will handle fedora/redhat part ourselfs printf 'install:\n\techo skipped\n' >platforms/redhat/Makefile @@ -85,8 +88,7 @@ export CPPFLAGS="$CPPFLAGS -DNETSNMP_NO_LEGACY_DEFINITIONS" --enable-net-snmp \ --enable-snmp \ --enable-usb \ - --enable-powerflute \ - --enable-nls \ + --enable-modbus-usb \ --enable-gapcmon \ --enable-pcnet \ --with-libwrap=%{_libdir} \ @@ -115,12 +117,14 @@ install -d %{buildroot}%{_sysconfdir}/logrotate.d install -m0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} install -d %{buildroot}%{_sysconfdir}/httpd/conf.d install -m0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/httpd/conf.d/%{name}.conf +install -D -m0644 %{SOURCE3} %{buildroot}%{_datadir}/pixmaps/apcupsd64x64.png desktop-file-install \ %if (0%{?fedora} && 0%{?fedora} < 19) || (0%{?rhel} && 0%{?rhel} < 7) --vendor="fedora" \ %endif --dir=${RPM_BUILD_ROOT}%{_datadir}/applications \ + --set-icon=apcupsd64x64 \ --delete-original \ ${RPM_BUILD_ROOT}%{_datadir}/applications/gapcmon.desktop @@ -164,6 +168,7 @@ rm -rf $RPM_BUILD_ROOT %{_bindir}/gapcmon %{_datadir}/applications/*gapcmon.desktop %{_datadir}/pixmaps/apcupsd.png +%{_datadir}/pixmaps/apcupsd64x64.png %{_datadir}/pixmaps/charging.png %{_datadir}/pixmaps/gapc_prefs.png %{_datadir}/pixmaps/onbatt.png @@ -182,6 +187,11 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon Nov 23 2015 Michal Hlavinka - 3.14.13-4 +- fix apcaccess crash if apcupsd is not running (#1236367,#1197383) +- enabled modbus-usb (#1195071) +- add bigger icon (#1157532) + * Wed Jun 17 2015 Fedora Release Engineering - 3.14.13-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild diff --git a/apcupsd64x64.png b/apcupsd64x64.png new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/apcupsd64x64.png