From 3af05f84003f3e4d0d4fe0f158d58249c581ff3a Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Mon, 23 Nov 2015 13:53:40 +0100 Subject: [PATCH 1/2] fix apcaccess crash if apcupsd is not running (#1236367,#1197383) - enabled modbus-usb (#1195071) - add bigger icon (#1157532) --- apcupsd-3.14.13-netopenfix.patch | 63 ++++++++++++++++++++++++++++++++ apcupsd.spec | 18 +++++++-- apcupsd64x64.png | 0 3 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 apcupsd-3.14.13-netopenfix.patch create mode 100644 apcupsd64x64.png 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 1fca5dd..a79e79a 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} \ @@ -116,12 +118,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 @@ -165,6 +169,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 @@ -183,6 +188,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 From 93137bf962386eb452c9f22da80158166fc4b899 Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Mon, 6 Jun 2016 12:18:13 +0200 Subject: [PATCH 2/2] updated to 3.14.14 --- .gitignore | 1 + apcupsd-3.14.13-netopenfix.patch | 63 -------------------------------- apcupsd.spec | 17 ++++++--- sources | 2 +- 4 files changed, 13 insertions(+), 70 deletions(-) delete mode 100644 apcupsd-3.14.13-netopenfix.patch diff --git a/.gitignore b/.gitignore index 039fa15..830429c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ apcupsd-3.14.8.tar.gz /apcupsd-3.14.11.tar.gz /apcupsd-3.14.12.tar.gz /apcupsd-3.14.13.tar.gz +/apcupsd-3.14.14.tar.gz diff --git a/apcupsd-3.14.13-netopenfix.patch b/apcupsd-3.14.13-netopenfix.patch deleted file mode 100644 index face793..0000000 --- a/apcupsd-3.14.13-netopenfix.patch +++ /dev/null @@ -1,63 +0,0 @@ -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 a79e79a..91e8ebb 100644 --- a/apcupsd.spec +++ b/apcupsd.spec @@ -1,6 +1,6 @@ Name: apcupsd -Version: 3.14.13 -Release: 4%{?dist} +Version: 3.14.14 +Release: 1%{?dist} Summary: APC UPS Power Control Daemon for Linux Group: System Environment/Daemons @@ -18,7 +18,6 @@ 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) @@ -67,7 +66,6 @@ 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 @@ -75,7 +73,9 @@ printf 'install:\n\techo skipped\n' >platforms/redhat/Makefile %build %global _hardened_build 1 cp -p /usr/lib/rpm/config.{guess,sub} autoconf/ -export CPPFLAGS="$CPPFLAGS -DNETSNMP_NO_LEGACY_DEFINITIONS" +export CPPFLAGS="$RPM_OPT_FLAGS -DNETSNMP_NO_LEGACY_DEFINITIONS -Wno-format-security -Wno-error=format-security" +export CXXFLAGS="$CPPFLAGS" +export CFLAGS="$CPPFLAGS" %configure \ --sysconfdir="%{_sysconfdir}/apcupsd" \ --with-cgi-bin="%{_localstatedir}/www/apcupsd" \ @@ -102,7 +102,6 @@ make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT -mkdir -p $RPM_BUILD_ROOT%{_initrddir} mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/www/apcupsd make DESTDIR=$RPM_BUILD_ROOT install @@ -188,6 +187,12 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Thu Jun 02 2016 Michal Hlavinka - 3.14.14-1 +- updated to 3.14.14 + +* Wed Feb 03 2016 Fedora Release Engineering - 3.14.13-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + * Mon Nov 23 2015 Michal Hlavinka - 3.14.13-4 - fix apcaccess crash if apcupsd is not running (#1236367,#1197383) - enabled modbus-usb (#1195071) diff --git a/sources b/sources index 290d693..4cc7ee2 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -c291d9d3923b4d9c0e600b755ad4f489 apcupsd-3.14.13.tar.gz +cc8f5ced77f38906a274787acb9bc980 apcupsd-3.14.14.tar.gz