diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2021-04-02 01:53:28 +0200 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2021-04-02 01:54:01 +0200 |
commit | eb72f866280ce72c25d22963f3ec24d72d60dfa1 (patch) | |
tree | 499ea7272f528bb705c22f7a2e707b8c27a1ed47 /sys-power/apcupsd/files | |
parent | media-radio/cqrlog: fix MissingInherits (optfeature) (diff) | |
download | gentoo-eb72f866280ce72c25d22963f3ec24d72d60dfa1.tar.gz gentoo-eb72f866280ce72c25d22963f3ec24d72d60dfa1.tar.bz2 gentoo-eb72f866280ce72c25d22963f3ec24d72d60dfa1.zip |
sys-power/apcupsd: rev bump
- Migrate to EAPI 7
- OpenRC runscript rewritten
- Added some patches from Debian/Fedora
Package-Manager: Portage-3.0.18, Repoman-3.0.3
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'sys-power/apcupsd/files')
6 files changed, 161 insertions, 0 deletions
diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-close-on-exec.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-close-on-exec.patch new file mode 100644 index 000000000000..aeaa78b35420 --- /dev/null +++ b/sys-power/apcupsd/files/apcupsd-3.14.9-close-on-exec.patch @@ -0,0 +1,50 @@ +Close the socket on exec - avoid leaked file descriptors, patch from Fedora + +--- a/src/apcnis.c ++++ b/src/apcnis.c +@@ -157,6 +157,9 @@ void do_server(UPSINFO *ups) + sleep(5 * 60); + } + ++ /* Close the socket on exec - avoid leaked file descriptors */ ++ fcntl(sockfd, F_SETFD, FD_CLOEXEC); ++ + /* Reuse old sockets */ + #ifndef HAVE_MINGW + if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (void*)&turnon, sizeof(turnon)) < 0) { +--- a/src/apcupsd.c ++++ b/src/apcupsd.c +@@ -212,6 +212,9 @@ int main(int argc, char *argv[]) + if (ups->event_fd < 0) { + log_event(ups, LOG_WARNING, "Could not open events file %s: %s\n", + ups->eventfile, strerror(errno)); ++ } else { ++ /* Close the file on exec - avoid leaked file descriptors */ ++ fcntl(ups->event_fd, F_SETFD, FD_CLOEXEC); + } + } + +--- a/src/drivers/usb/linux/linux-usb.c ++++ b/src/drivers/usb/linux/linux-usb.c +@@ -246,8 +246,11 @@ bool LinuxUsbUpsDriver::open_usb_device() + /* Retry 10 times */ + for (i = 0; i < 10; i++) { + _fd = open_device(_ups->device); +- if (_fd != -1) ++ if (_fd != -1) { ++ /* Close the device on exec - avoid leaked file descriptors */ ++ fcntl(_fd, F_SETFD, FD_CLOEXEC); + return true; ++ } + sleep(1); + } + +@@ -270,6 +273,7 @@ auto_detect: + asnprintf(devname, sizeof(devname), "%s%d", hiddev[j], k); + _fd = open_device(devname); + if (_fd != -1) { ++ fcntl(_fd, F_SETFD, FD_CLOEXEC); + /* Successful open, save device name and return */ + strlcpy(_ups->device, devname, sizeof(_ups->device)); + return true; + diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-commfailure.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-commfailure.patch new file mode 100644 index 000000000000..49641c06bef3 --- /dev/null +++ b/sys-power/apcupsd/files/apcupsd-3.14.9-commfailure.patch @@ -0,0 +1,15 @@ +Author: Tero Janka <tero.janka@mbnet.fi> +Description: apcaccess call blocking commfailure mails (Closes: #409734). + +Index: apcupsd/platforms/etc/commfailure.in +=================================================================== +--- apcupsd.orig/platforms/etc/commfailure.in ++++ apcupsd/platforms/etc/commfailure.in +@@ -13,7 +13,5 @@ MSG="$HOSTNAME Communications with UPS $ + echo "Subject: $MSG" + echo " " + echo "$MSG" +- echo " " +- @sbindir@/apcaccess status + ) | $APCUPSD_MAIL -s "$MSG" $SYSADMIN + exit 0 diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-fix-nologin.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-fix-nologin.patch new file mode 100644 index 000000000000..75f9e4449bf5 --- /dev/null +++ b/sys-power/apcupsd/files/apcupsd-3.14.9-fix-nologin.patch @@ -0,0 +1,15 @@ +Description: only prohibit logins on shutdown if login is allowed at all +Index: apcupsd-3.14.12/src/action.c +=================================================================== +--- apcupsd-3.14.12.orig/src/action.c ++++ apcupsd-3.14.12/src/action.c +@@ -208,7 +208,8 @@ static void do_shutdown(UPSINFO *ups, in + delete_lockfile(ups); + ups->set_fastpoll(); + make_file(ups, ups->pwrfailpath); +- prohibit_logins(ups); ++ if (ups->nologin.type != NEVER) ++ prohibit_logins(ups); + + if (!ups->is_slave()) { + /* diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-gapcmon.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-gapcmon.patch new file mode 100644 index 000000000000..0dd1cc69aa35 --- /dev/null +++ b/sys-power/apcupsd/files/apcupsd-3.14.9-gapcmon.patch @@ -0,0 +1,33 @@ +Description: take care of some deprecated functions and format issue +Author: Thorsten Alteholz <debian@alteholz.de> +Index: apcupsd-3.14.14/src/gapcmon/gapcmon.c +=================================================================== +--- apcupsd-3.14.14.orig/src/gapcmon/gapcmon.c 2016-07-16 03:04:22.000000000 +0200 ++++ apcupsd-3.14.14/src/gapcmon/gapcmon.c 2017-10-06 09:26:40.412004149 +0200 +@@ -1580,7 +1580,7 @@ + scaled = gdk_pixbuf_scale_simple(pixbuf, size, size, GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(GTK_IMAGE(pm->tray_image), scaled); + gtk_widget_show(pm->tray_image); +- gdk_pixbuf_unref(scaled); ++ g_object_unref(scaled); + } + + if (pm->window != NULL) +@@ -2889,7 +2889,7 @@ + + pch = g_strdup_printf("%s(%s) emsg=%s", pch_func, pch_topic, pch_emsg); + +- g_message(pch); ++ g_message("%s",pch); + + g_free(pch); + +@@ -4474,7 +4474,7 @@ + gtk_image_set_from_pixbuf(GTK_IMAGE(image), scaled); + gtk_box_pack_start(GTK_BOX(hbox), image, TRUE, TRUE, 0); + gtk_widget_show(image); +- gdk_pixbuf_unref(scaled); ++ g_object_unref(scaled); + + label = gtk_label_new(about_text); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-wall-on-mounted-usr.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-wall-on-mounted-usr.patch new file mode 100644 index 000000000000..b89a5309e5ba --- /dev/null +++ b/sys-power/apcupsd/files/apcupsd-3.14.9-wall-on-mounted-usr.patch @@ -0,0 +1,20 @@ +At halt/killpower time, /usr may already be umounted, and wall +lives in /usr. Avoid failing by using cat if needed. + +Index: apcupsd/platforms/apccontrol.in +=================================================================== +--- apcupsd.orig/platforms/apccontrol.in ++++ apcupsd/platforms/apccontrol.in +@@ -62,10 +62,10 @@ fi + + case "$1" in + killpower) +- echo "Apccontrol doing: ${APCUPSD} --killpower on UPS ${2}" | ${WALL} ++ echo "Apccontrol doing: ${APCUPSD} --killpower on UPS ${2}" | (${WALL} 2>/dev/null || cat) + sleep 10 + ${APCUPSD} --killpower +- echo "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}" | ${WALL} ++ echo "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}" | (${WALL} 2>/dev/null || cat) + ;; + commfailure) + echo "Warning communications lost with UPS ${2}" | ${WALL} diff --git a/sys-power/apcupsd/files/apcupsd.init b/sys-power/apcupsd/files/apcupsd.init new file mode 100644 index 000000000000..e544fd4f3900 --- /dev/null +++ b/sys-power/apcupsd/files/apcupsd.init @@ -0,0 +1,28 @@ +#!/sbin/openrc-run +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +: ${APCUPSD_CONFIGFILE:=/etc/apcupsd/${SVCNAME#*.}.conf} +: ${APCUPSD_POWERFAILFILE:=/etc/apcupsd/powerfail} +: ${APCUPSD_PIDFILE:=/run/${SVCNAME}.pid} +: ${APCUPSD_SSDARGS:=--wait 1000} +: ${APCUPSD_TERMTIMEOUT:=TERM/60/KILL/5} + +command="/sbin/apcupsd" +command_args="${APCUPSD_OPTS} --config-file \"${APCUPSD_CONFIGFILE}\" --pid-file \"${APCUPSD_PIDFILE}\"" +pidfile="${APCUPSD_PIDFILE}" +retry="${APCUPSD_TERMTIMEOUT}" +start_stop_daemon_args="${APCUPSD_SSDARGS}" +required_files="${APCUPSD_CONFIGFILE}" + +depend() { + use dns +} + +start_pre() { + if [ -e "${APCUPSD_POWERFAILFILE}" ] ; then + ebegin "Removing stale ${APCUPSD_POWERFAILFILE}" + rm "${APCUPSD_POWERFAILFILE}" + eend $? + fi +} |