diff --git a/sysutils/nut-devel/Makefile b/sysutils/nut-devel/Makefile index 398569e10c81..b3d796bfec97 100644 --- a/sysutils/nut-devel/Makefile +++ b/sysutils/nut-devel/Makefile @@ -1,172 +1,172 @@ PORTNAME= nut PORTVERSION= ${NUT_COMMIT_DATE} -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= sysutils PKGNAMESUFFIX= -devel # MASTER_SITES= http://www.networkupstools.org/source/${PORTVERSION:R}/ # DISTFILES= ${DISTNAME}${EXTRACT_SUFX} # EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} MAINTAINER= cy@FreeBSD.org COMMENT= Network UPS Tools LICENSE= GPLv2+ GPLv3+ ART10 GPLv1+ LICENSE_COMB= multi LICENSE_FILE= ${WRKSRC}/COPYING CONFLICTS= nut-[0-9]* USE_GITHUB= yes GH_ACCOUNT= networkupstools GH_TAGNAME= 2ce9dfa4a NUT_COMMIT_DATE= 2022.08.25 MAKE_JOBS_UNSAFE= yes USE_GCC= yes GNU_CONFIGURE= yes USES= autoreconf:build compiler:c11 gmake libtool pkgconfig python USE_LDCONFIG= yes NUT_USER?= uucp NUT_GROUP?= uucp STATEDIR?= /var/db/nut PLIST_SUB+= NUT_USER=${NUT_USER} PLIST_SUB+= NUT_GROUP=${NUT_GROUP} CGIDIR?= ${PREFIX}/www/cgi-bin/${PORTNAME} CGIDIR_REL?= ${CGIDIR:S,^${PREFIX}/,,} PLIST_SUB+= CGIDIR="${CGIDIR_REL}" PLIST_SUB+= CGIETCDIR="etc/nut/" OPTIONS_DEFAULT= SERIAL USB SNMP NEON PDU MODBUS CGI BASH AVAHI FREEIPMI DOCS MANPAGES OPENSSL OPTIONS_DEFINE= SERIAL USB SNMP NEON PDU MODBUS CGI BASH AVAHI IPMIPSU FREEIPMI DOCS MANPAGES OPTIONS_SINGLE= SSL OPTIONS_SINGLE_SSL= SSL_OFF OPENSSL NSS OPTIONS_SUB= yes SERIAL_DESC= SERIAL support USB_DESC= USB support NEON_DESC= NEON XML/HTTP support PDU_DESC= Powerman PDU support MODBUS_DESC= Modbus support CGI_DESC= Web CGI interface FREEIPMI_DESC= freeipmi support IPMIPSU_DESC= Use nut-ipmipsu support (experimental) SSL_OFF_DESC= No SSL support USE_RC_SUBR= nut nut_upsmon nut_upslog SUB_LIST+= STATEDIR=${STATEDIR} PLIST_SUB+= STATEDIR=${STATEDIR} PORTDOCS= * TMPDIR?= /tmp INSTALL_TARGET= install-strip CONFIGURE_ARGS= --sysconfdir=${PREFIX}/etc/nut \ --program-transform-name="" \ --localstatedir=${STATEDIR} \ --datadir=${PREFIX}/etc/nut \ --with-devd-dir=${PREFIX}/etc/devd \ --with-drvpath=${PREFIX}/libexec/nut \ --with-statepath=${STATEDIR} \ --with-altpidpath=${STATEDIR} \ --with-pidpath=${STATEDIR} \ --with-pkgconfig-dir=${PREFIX}/libdata/pkgconfig \ --with-user=${NUT_USER} \ --with-group=${NUT_GROUP} \ --with-python=${PYTHON_CMD} \ --without-python2 \ --with-python3=${PYTHON_CMD} \ --with-dev \ --with-ltdl --with-nut-scanner CFLAGS+= -I${LOCALBASE}/include -L${LOCALBASE}/lib LIB_DEPENDS+= libltdl.so:devel/libltdl # XXX Remove this when copying this port to sysutils/nut. The GA version # XXX of nut ships with preformatted files and therefore does not need # XXX asciidoc. BUILD_DEPENDS= asciidoc:textproc/asciidoc MANPAGES_CONFIGURE_ON= --with-doc=man=auto MANPAGES_CONFIGURE_OFF= --with-doc=no CGI_LIB_DEPENDS= libgd.so:graphics/gd CGI_CONFIGURE_WITH= cgi CGI_CONFIGURE_ON= --with-cgipath=${CGIDIR} \ --with-htmlpath=${WWWDIR} \ --with-gd-includes=-I${LOCALBASE}/include \ --with-gd-libs="-L${LOCALBASE}/lib -lgd" SERIAL_CONFIGURE_WITH= serial USB_CONFIGURE_WITH= usb=auto SNMP_LIB_DEPENDS= libnetsnmp.so:net-mgmt/net-snmp SNMP_CONFIGURE_WITH= snmp NEON_LIB_DEPENDS= libneon.so:www/neon NEON_CONFIGURE_WITH= neon PDU_LIB_DEPENDS= libpowerman.so:sysutils/powerman PDU_CONFIGURE_WITH= powerman MODBUS_LIB_DEPENDS= libmodbus.so:comms/libmodbus MODBUS_CONFIGURE_WITH= modbus BASH_BUILD_DEPENDS= ${LOCALBASE}/share/bash-completion/bash_completion.sh:shells/bash-completion BASH_RUN_DEPENDS= ${LOCALBASE}/share/bash-completion/bash_completion.sh:shells/bash-completion AVAHI_BUILD_DEPENDS= ${LOCALBASE}/include/avahi-ui/avahi-ui.h:net/avahi-header AVAHI_BUILD_DEPENDS= avahi-daemon:net/avahi-app AVAHI_RUN_DEPENDS= avahi-daemon:net/avahi-app AVAHI_CONFIGURE_WITH= avahi FREEIPMI_LIB_DEPENDS= libfreeipmi.so:sysutils/freeipmi FREEIPMI_CONFIGURE_WITH=freeipmi IPMIPSU_LIB_DEPENDS= libfreeipmi.so:sysutils/freeipmi IPMIPSU_CONFIGURE_WITH= ipmi OPENSSL_USES= ssl OPENSSL_CONFIGURE_WITH= openssl NSS_LIB_DEPENDS= libnss3.so:security/nss NSS_CONFIGURE_WITH= nss .include post-patch: @${REINPLACE_CMD} -i '' -e 's|python|${PYTHON_CMD}|' ${WRKSRC}/autogen.sh @${FIND} ${WRKSRC} -type f | ${XARGS} ${REINPLACE_CMD} -i '' -e 's|/usr/bin/env python|${PYTHON_CMD}|' @${FIND} ${WRKSRC} -type f | ${XARGS} ${REINPLACE_CMD} -i '' -e 's|/usr/local/ups|${PREFIX}|' pre-configure: cd ${WRKSRC} && ./autogen.sh pre-install: @${MKDIR} ${STAGEDIR}${PREFIX}/libexec/nut @${REINPLACE_CMD} -e 's/device-name\*/cdev/g' ${WRKSRC}/scripts/devd/nut-usb.conf post-install: @${MKDIR} ${STAGEDIR}${STATEDIR} @${MKDIR} ${STAGEDIR}${PREFIX}/etc/syslog.d .if ${PORT_OPTIONS:MBASH} @${MKDIR} ${STAGEDIR}${PREFIX}/etc/bash_completion.d/ ${INSTALL_DATA} ${WRKSRC}/scripts/misc/nut.bash_completion ${STAGEDIR}${PREFIX}/etc/bash_completion.d/ .endif .if ${PORT_OPTIONS:MDOCS} @${MKDIR} ${STAGEDIR}${DOCSDIR}/cables ${INSTALL_DATA} ${WRKSRC}/docs/cables/*.txt ${STAGEDIR}${DOCSDIR}/cables ${INSTALL_DATA} ${WRKSRC}/docs/*.txt ${STAGEDIR}${DOCSDIR} ${INSTALL_DATA} ${WRKSRC}/docs/FAQ.txt ${STAGEDIR}${DOCSDIR} .for file in AUTHORS COPYING INSTALL MAINTAINERS NEWS README UPGRADING ${INSTALL_DATA} ${WRKSRC}/${file} ${STAGEDIR}${DOCSDIR} .endfor .endif @${MKDIR} ${STAGEDIR}${EXAMPLESDIR} ${INSTALL_DATA} ${PATCHDIR}/nut.syslog ${STAGEDIR}${EXAMPLESDIR}/syslog.sample ${INSTALL_DATA} ${PATCHDIR}/nut.newsyslog ${STAGEDIR}${EXAMPLESDIR}/newsyslog.sample ${INSTALL_DATA} ${PATCHDIR}/nut_upslog.sample ${STAGEDIR}${EXAMPLESDIR}/nut_upslog.sample ${MKDIR} ${STAGEDIR}/var/log/nut .include diff --git a/sysutils/nut-devel/files/patch-clients_upslog.c b/sysutils/nut-devel/files/patch-clients_upslog.c deleted file mode 100644 index b00846526b21..000000000000 --- a/sysutils/nut-devel/files/patch-clients_upslog.c +++ /dev/null @@ -1,167 +0,0 @@ ---- clients/upslog.c.orig 2022-08-26 15:25:26.539215000 -0700 -+++ clients/upslog.c 2022-08-26 15:26:10.909994000 -0700 -@@ -32,6 +32,10 @@ - */ - - #include "common.h" -+#include -+#include -+#include -+#include - #include "nut_platform.h" - #include "upsclient.h" - -@@ -41,17 +45,32 @@ - #include "upslog.h" - - static int reopen_flag = 0, exit_flag = 0; -+ static int wait_status; - static uint16_t port; - static char *upsname, *hostname; - static UPSCONN_t ups; - - static FILE *logfile; -- static const char *logfn, *monhost; -+ static char *logfn, *monhost; - static sigset_t nut_upslog_sigmask; - static char logbuffer[LARGEBUF], *logformat; - - static flist_t *fhead = NULL; -+ struct monhost_child { -+ char *monhost; -+ char *logfn; -+ char *pidfilebase; -+ pid_t pid; -+ struct monhost_child *next; -+ }; -+ static struct monhost_child *monhost_child_anchor = NULL; -+ static struct monhost_child *monhost_child_current = NULL; -+ static struct monhost_child *monhost_child_prev = NULL; -+ static struct sigaction upslog_sigaction; -+ static int trapped_signals[] = { SIGHUP, SIGINT, SIGTERM, SIGCHLD }; -+ static pid_t daemon_pid; - -+ - #define DEFAULT_LOGFORMAT "%TIME @Y@m@d @H@M@S% %VAR battery.charge% " \ - "%VAR input.voltage% %VAR ups.load% [%VAR ups.status%] " \ - "%VAR ups.temperature% %VAR input.frequency%" -@@ -131,6 +150,8 @@ - printf(" -p - Base name for PID file (defaults to \"%s\")\n", prog); - printf(" -s - Monitor UPS - @[:]\n"); - printf(" - Example: -s myups@server\n"); -+ printf(" -m - Monitor UPS ,\n"); -+ printf(" - Example: -m myups@server,/var/log/myups.log,/var/run/myups.pid\n"); - printf(" -u - Switch to if started as root\n"); - - printf("\n"); -@@ -393,9 +414,25 @@ - * -u - */ - -+static void term_handler(int signo) -+{ -+ if (signo != SIGCHLD && monhost_child_anchor != NULL) { -+ for (monhost_child_current = monhost_child_anchor; -+ monhost_child_current != NULL; -+ monhost_child_current = monhost_child_current->next -+ ) { -+ kill(monhost_child_current->pid, signo); -+ } -+ -+ if (signo != SIGHUP) -+ fatalx(EXIT_FAILURE, "Killed by user"); -+ } -+} -+ - int main(int argc, char **argv) - { - int interval = 30, i, foreground = -1; -+ size_t monhost_len = 0, mh; - const char *prog = xbasename(argv[0]); - time_t now, nextpoll = 0; - const char *user = NULL; -@@ -407,7 +444,7 @@ - - printf("Network UPS Tools %s %s\n", prog, UPS_VERSION); - -- while ((i = getopt(argc, argv, "+hs:l:i:f:u:Vp:FB")) != -1) { -+ while ((i = getopt(argc, argv, "+hs:l:i:f:u:Vp:FBm:")) != -1) { - switch(i) { - case 'h': - help(prog); -@@ -415,6 +452,33 @@ - break; - #endif - -+ case 'm': { /* var scope */ -+ char *m_arg, *s; -+ -+ monhost_child_prev = monhost_child_current; -+ monhost_child_current = xmalloc(sizeof(struct monhost_child)); -+ if (monhost_child_anchor == NULL) -+ monhost_child_anchor = monhost_child_current; -+ else -+ monhost_child_prev->next = monhost_child_current; -+ monhost_child_current->next = NULL; -+ monhost_len++; -+ -+ /* Be sure to not mangle original optarg, nor rely on its longevity */ -+ s = xstrdup(optarg); -+ m_arg = s; -+ monhost_child_current->monhost = xstrdup(strsep(&m_arg, ",")); -+ if (!m_arg) -+ fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile,pidfile' requires exactly 3 components in the tuple"); -+ monhost_child_current->logfn = xstrdup(strsep(&m_arg, ",")); -+ if (!m_arg) -+ fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile,pidfile' requires exactly 3 components in the tuple"); -+ monhost_child_current->pidfilebase = xstrdup(strsep(&m_arg, ",")); -+ if (m_arg) /* Had a third comma - also unexpected! */ -+ fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile,pidfile' requires exactly 3 components in the tuple"); -+ free(s); -+ } /* var scope */ -+ break; - case 's': - monhost = optarg; - break; -@@ -477,6 +541,41 @@ - - for (i = 3; i < argc; i++) - snprintfcat(logformat, LARGEBUF, "%s ", argv[i]); -+ } -+ -+ if (monhost_child_anchor != NULL) { -+ if (foreground > 0) -+ daemon_pid = 0; -+ else -+ daemon_pid = fork(); -+ if (!daemon_pid) { -+ upsdebugx(1,"Forking to log %" PRIuSIZE " devices", monhost_len); -+ for (monhost_child_current = monhost_child_anchor; -+ monhost_child_current != NULL; -+ monhost_child_current = monhost_child_current->next) { -+ if ((monhost_child_current->pid = fork()) == 0) { -+ monhost = monhost_child_current->monhost; -+ logfn = monhost_child_current->logfn; -+ pidfilebase = monhost_child_current->pidfilebase; -+ foreground = 1; -+ break; -+ } -+ } -+ if (monhost_child_anchor->pid) { /* parent */ -+ for (mh = 0; mh < sizeof(trapped_signals)/sizeof(trapped_signals[0]); mh++) { -+ upslog_sigaction.sa_handler = &term_handler; -+ sigfillset(&upslog_sigaction.sa_mask); -+ upslog_sigaction.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT; -+ sigaction(trapped_signals[mh], &upslog_sigaction, NULL); -+ } -+ become_user(get_user_pwent(user)); -+ writepid(pidfilebase); -+ while(wait(&wait_status) > 0); -+ exit(EXIT_SUCCESS); -+ } -+ } else { -+ exit(EXIT_SUCCESS); -+ } - } - - if (!monhost) diff --git a/sysutils/nut-devel/files/patch-docs_man_upslog.txt b/sysutils/nut-devel/files/patch-docs_man_upslog.txt deleted file mode 100644 index a8b41f0f7569..000000000000 --- a/sysutils/nut-devel/files/patch-docs_man_upslog.txt +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/docs/man/upslog.txt b/docs/man/upslog.txt -index f4051048..f49695fe 100644 ---- docs/man/upslog.txt -+++ docs/man/upslog.txt -@@ -78,6 +78,11 @@ upslog will run in the background, regardless of logging target. - Monitor this UPS. The format for this option is - +upsname[@hostname[:port]]+. The default hostname is "localhost". - -+*-m* 'tuple':: -+Monitor multiple UPSs. The format for this option is a tuple of -+ups, logfile, and pidfile separated by commas. An example would be: -+`upsname@hostname:9999,/var/log/nut/cps.log,/var/run/cps.pid` -+ - *-u* 'username':: - - If started as root, upslog will *setuid*(2) to the user id diff --git a/sysutils/nut/Makefile b/sysutils/nut/Makefile index 0e1209bbc376..1bad77416107 100644 --- a/sysutils/nut/Makefile +++ b/sysutils/nut/Makefile @@ -1,150 +1,150 @@ PORTNAME= nut PORTVERSION= 2.8.0 -PORTREVISION= 9 +PORTREVISION= 10 CATEGORIES= sysutils MASTER_SITES= http://www.networkupstools.org/source/${PORTVERSION:R}/ MAINTAINER= cy@FreeBSD.org COMMENT= Network UPS Tools LICENSE= GPLv2+ GPLv3+ ART10 GPLv1+ LICENSE_COMB= multi LICENSE_FILE= ${WRKSRC}/COPYING CONFLICTS= nut-devel-* GNU_CONFIGURE= yes USES= autoreconf:build compiler:c11 gmake libtool pkgconfig python:build USE_LDCONFIG= yes NUT_USER?= uucp NUT_GROUP?= uucp STATEDIR?= /var/db/nut PLIST_SUB+= NUT_USER=${NUT_USER} PLIST_SUB+= NUT_GROUP=${NUT_GROUP} CGIDIR?= ${PREFIX}/www/cgi-bin/${PORTNAME} CGIDIR_REL?= ${CGIDIR:S,^${PREFIX}/,,} PLIST_SUB+= CGIDIR="${CGIDIR_REL}" PLIST_SUB+= CGIETCDIR="etc/nut/" OPTIONS_DEFAULT=SERIAL USB SNMP NEON PDU MODBUS CGI BASH AVAHI FREEIPMI DOCS MANPAGES OPENSSL OPTIONS_DEFINE= SERIAL USB SNMP NEON PDU MODBUS CGI BASH AVAHI IPMIPSU FREEIPMI DOCS MANPAGES OPTIONS_SINGLE= IPMI SSL OPTIONS_SINGLE_SSL= SSL_OFF OPENSSL NSS OPTIONS_SUB= yes SERIAL_DESC= SERIAL support USB_DESC= USB support NEON_DESC= NEON XML/HTTP support PDU_DESC= Powerman PDU support MODBUS_DESC= Modbus support CGI_DESC= Web CGI interface FREEIPMI_DESC= freeipmi support IPMIPSU_DESC= Use nut-ipmipsu support (experimental) SSL_OFF_DESC= No SSL support USE_RC_SUBR= nut nut_upsmon nut_upslog SUB_LIST+= STATEDIR=${STATEDIR} PLIST_SUB+= STATEDIR=${STATEDIR} PORTDOCS= * TMPDIR?= /tmp INSTALL_TARGET= install-strip CONFIGURE_ARGS= --sysconfdir=${PREFIX}/etc/nut \ --program-transform-name="" \ --localstatedir=${STATEDIR} \ --datadir=${PREFIX}/etc/nut \ --with-devd-dir=${PREFIX}/etc/devd \ --with-drvpath=${PREFIX}/libexec/nut \ --with-statepath=${STATEDIR} \ --with-altpidpath=${STATEDIR} \ --with-pidpath=${STATEDIR} \ --with-pkgconfig-dir=${PREFIX}/libdata/pkgconfig \ --with-user=${NUT_USER} \ --with-group=${NUT_GROUP} \ --with-dev CFLAGS+= -I${LOCALBASE}/include -L${LOCALBASE}/lib LIB_DEPENDS+= libltdl.so:devel/libltdl MANPAGES_CONFIGURE_ON= --with-doc=man=auto MANPAGES_CONFIGURE_OFF= --with-doc=no CGI_LIB_DEPENDS= libgd.so:graphics/gd CGI_CONFIGURE_WITH= cgi CGI_CONFIGURE_ON= --with-cgipath=${CGIDIR} \ --with-htmlpath=${WWWDIR} \ --with-gd-includes=-I${LOCALBASE}/include \ --with-gd-libs="-L${LOCALBASE}/lib -lgd" SERIAL_CONFIGURE_WITH= serial USB_CONFIGURE_WITH= usb=auto SNMP_LIB_DEPENDS= libnetsnmp.so:net-mgmt/net-snmp SNMP_CONFIGURE_WITH= snmp NEON_LIB_DEPENDS+= libneon.so:www/neon NEON_CONFIGURE_WITH= neon PDU_LIB_DEPENDS+= libpowerman.so:sysutils/powerman PDU_CONFIGURE_WITH= powerman MODBUS_LIB_DEPENDS+= libmodbus.so:comms/libmodbus MODBUS_CONFIGURE_WITH= modbus BASH_BUILD_DEPENDS= ${LOCALBASE}/share/bash-completion/bash_completion.sh:shells/bash-completion BASH_RUN_DEPENDS= ${LOCALBASE}/share/bash-completion/bash_completion.sh:shells/bash-completion AVAHI_BUILD_DEPENDS= ${LOCALBASE}/include/avahi-ui/avahi-ui.h:net/avahi-header AVAHI_BUILD_DEPENDS= avahi-daemon:net/avahi-app AVAHI_RUN_DEPENDS= avahi-daemon:net/avahi-app AVAHI_CONFIGURE_WITH= avahi FREEIPMI_LIB_DEPENDS= libfreeipmi.so:sysutils/freeipmi FREEIPMI_CONFIGURE_WITH=freeipmi IPMIPSU_LIB_DEPENDS= libfreeipmi.so:sysutils/freeipmi IPMIPSU_CONFIGURE_WITH= ipmi OPENSSL_USES= ssl OPENSSL_CONFIGURE_WITH= openssl NSS_LIB_DEPENDS= libnss3.so:security/nss NSS_CONFIGURE_WITH= nss .include post-patch: @${FIND} ${WRKSRC} -type f | ${XARGS} ${REINPLACE_CMD} -i '' -e 's|/usr/bin/env python|${PYTHON_CMD}|' @${FIND} ${WRKSRC} -type f | ${XARGS} ${REINPLACE_CMD} -i '' -e 's|/usr/local/ups|${PREFIX}|' pre-install: @${MKDIR} ${STAGEDIR}${PREFIX}/libexec/nut post-install: @${MKDIR} ${STAGEDIR}${STATEDIR} @${MKDIR} ${STAGEDIR}${PREFIX}/etc/syslog.d .if ${PORT_OPTIONS:MBASH} @${MKDIR} ${STAGEDIR}${PREFIX}/etc/bash_completion.d/ ${INSTALL_DATA} ${WRKSRC}/scripts/misc/nut.bash_completion ${STAGEDIR}${PREFIX}/etc/bash_completion.d/ .endif .if ${PORT_OPTIONS:MDOCS} @${MKDIR} ${STAGEDIR}${DOCSDIR}/cables ${INSTALL_DATA} ${WRKSRC}/docs/cables/*.txt ${STAGEDIR}${DOCSDIR}/cables ${INSTALL_DATA} ${WRKSRC}/docs/*.txt ${STAGEDIR}${DOCSDIR} ${INSTALL_DATA} ${WRKSRC}/docs/FAQ.txt ${STAGEDIR}${DOCSDIR} .for file in AUTHORS COPYING ChangeLog INSTALL MAINTAINERS NEWS README UPGRADING ${INSTALL_DATA} ${WRKSRC}/${file} ${STAGEDIR}${DOCSDIR} .endfor .endif @${MKDIR} ${STAGEDIR}${EXAMPLESDIR} ${INSTALL_DATA} ${PATCHDIR}/nut.syslog ${STAGEDIR}${EXAMPLESDIR}/syslog.sample ${INSTALL_DATA} ${PATCHDIR}/nut.newsyslog ${STAGEDIR}${EXAMPLESDIR}/newsyslog.sample ${INSTALL_DATA} ${PATCHDIR}/nut_upslog.sample ${STAGEDIR}${EXAMPLESDIR}/nut_upslog.sample ${MKDIR} ${STAGEDIR}/var/log/nut @${RM} ${STAGEDIR}${PREFIX}/etc/nut/solaris-init/nut @${RMDIR} ${STAGEDIR}${PREFIX}/etc/nut/solaris-init .include diff --git a/sysutils/nut/files/patch-clients_upslog.c b/sysutils/nut/files/patch-clients_upslog.c deleted file mode 100644 index 1602d8b65067..000000000000 --- a/sysutils/nut/files/patch-clients_upslog.c +++ /dev/null @@ -1,166 +0,0 @@ ---- clients/upslog.c.orig 2022-08-26 15:25:00.233023000 -0700 -+++ clients/upslog.c 2022-08-26 15:26:30.983822000 -0700 -@@ -32,6 +32,10 @@ - */ - - #include "common.h" -+#include -+#include -+#include -+#include - #include "nut_platform.h" - #include "upsclient.h" - -@@ -41,17 +45,32 @@ - #include "upslog.h" - - static int reopen_flag = 0, exit_flag = 0; -+ static int wait_status; - static uint16_t port; - static char *upsname, *hostname; - static UPSCONN_t ups; - - static FILE *logfile; -- static const char *logfn, *monhost; -+ static char *logfn, *monhost; - static sigset_t nut_upslog_sigmask; - static char logbuffer[LARGEBUF], *logformat; - - static flist_t *fhead = NULL; -+ struct monhost_child { -+ char *monhost; -+ char *logfn; -+ char *pidfilebase; -+ pid_t pid; -+ struct monhost_child *next; -+ }; -+ static struct monhost_child *monhost_child_anchor = NULL; -+ static struct monhost_child *monhost_child_current = NULL; -+ static struct monhost_child *monhost_child_prev = NULL; -+ static struct sigaction upslog_sigaction; -+ static int trapped_signals[] = { SIGHUP, SIGINT, SIGTERM, SIGCHLD }; -+ static pid_t daemon_pid; - -+ - #define DEFAULT_LOGFORMAT "%TIME @Y@m@d @H@M@S% %VAR battery.charge% " \ - "%VAR input.voltage% %VAR ups.load% [%VAR ups.status%] " \ - "%VAR ups.temperature% %VAR input.frequency%" -@@ -131,6 +150,8 @@ - printf(" -p - Base name for PID file (defaults to \"%s\")\n", prog); - printf(" -s - Monitor UPS - @[:]\n"); - printf(" - Example: -s myups@server\n"); -+ printf(" -m - Monitor UPS ,\n"); -+ printf(" - Example: -m myups@server,/var/log/myups.log,/var/run/myups.pid\n"); - printf(" -u - Switch to if started as root\n"); - - printf("\n"); -@@ -393,9 +414,25 @@ - * -u - */ - -+static void term_handler(int signo) -+{ -+ if (signo != SIGCHLD && monhost_child_anchor != NULL) { -+ for (monhost_child_current = monhost_child_anchor; -+ monhost_child_current != NULL; -+ monhost_child_current = monhost_child_current->next -+ ) { -+ kill(monhost_child_current->pid, signo); -+ } -+ -+ if (signo != SIGHUP) -+ fatalx(EXIT_FAILURE, "Killed by user"); -+ } -+} -+ - int main(int argc, char **argv) - { - int interval = 30, i, foreground = -1; -+ size_t monhost_len = 0, mh; - const char *prog = xbasename(argv[0]); - time_t now, nextpoll = 0; - const char *user = NULL; -@@ -407,7 +444,7 @@ - - printf("Network UPS Tools %s %s\n", prog, UPS_VERSION); - -- while ((i = getopt(argc, argv, "+hs:l:i:f:u:Vp:FB")) != -1) { -+ while ((i = getopt(argc, argv, "+hs:l:i:f:u:Vp:FBm:")) != -1) { - switch(i) { - case 'h': - help(prog); -@@ -415,6 +452,33 @@ - break; - #endif - -+ case 'm': { /* var scope */ -+ char *m_arg, *s; -+ -+ monhost_child_prev = monhost_child_current; -+ monhost_child_current = xmalloc(sizeof(struct monhost_child)); -+ if (monhost_child_anchor == NULL) -+ monhost_child_anchor = monhost_child_current; -+ else -+ monhost_child_prev->next = monhost_child_current; -+ monhost_child_current->next = NULL; -+ monhost_len++; -+ -+ /* Be sure to not mangle original optarg, nor rely on its longevity */ -+ s = xstrdup(optarg); -+ m_arg = s; -+ monhost_child_current->monhost = xstrdup(strsep(&m_arg, ",")); -+ if (!m_arg) -+ fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile,pidfile' requires exactly 3 components in the tuple"); -+ monhost_child_current->logfn = xstrdup(strsep(&m_arg, ",")); -+ if (!m_arg) -+ fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile,pidfile' requires exactly 3 components in the tuple"); -+ monhost_child_current->pidfilebase = xstrdup(strsep(&m_arg, ",")); -+ if (m_arg) /* Had a third comma - also unexpected! */ -+ fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile,pidfile' requires exactly 3 components in the tuple"); -+ free(s); -+ } /* var scope */ -+ break; - case 's': - monhost = optarg; - break; -@@ -477,6 +541,40 @@ - - for (i = 3; i < argc; i++) - snprintfcat(logformat, LARGEBUF, "%s ", argv[i]); -+ } -+ -+ if (monhost_child_anchor != NULL) { -+ if (foreground > 0) -+ daemon_pid = 0; -+ else -+ daemon_pid = fork(); -+ if (!daemon_pid) { -+ for (monhost_child_current = monhost_child_anchor; -+ monhost_child_current != NULL; -+ monhost_child_current = monhost_child_current->next) { -+ if ((monhost_child_current->pid = fork()) == 0) { -+ monhost = monhost_child_current->monhost; -+ logfn = monhost_child_current->logfn; -+ pidfilebase = monhost_child_current->pidfilebase; -+ foreground = 1; -+ break; -+ } -+ } -+ if (monhost_child_anchor->pid) { /* parent */ -+ for (mh = 0; mh < sizeof(trapped_signals)/sizeof(trapped_signals[0]); mh++) { -+ upslog_sigaction.sa_handler = &term_handler; -+ sigfillset(&upslog_sigaction.sa_mask); -+ upslog_sigaction.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT; -+ sigaction(trapped_signals[mh], &upslog_sigaction, NULL); -+ } -+ become_user(get_user_pwent(user)); -+ writepid(pidfilebase); -+ while(wait(&wait_status) > 0); -+ exit(EXIT_SUCCESS); -+ } -+ } else { -+ exit(EXIT_SUCCESS); -+ } - } - - if (!monhost) diff --git a/sysutils/nut/files/patch-docs_man_upslog.8 b/sysutils/nut/files/patch-docs_man_upslog.8 deleted file mode 100644 index 10335395cea9..000000000000 --- a/sysutils/nut/files/patch-docs_man_upslog.8 +++ /dev/null @@ -1,16 +0,0 @@ ---- docs/man/upslog.8.orig 2022-04-26 15:07:16.000000000 -0700 -+++ docs/man/upslog.8 2022-08-24 07:39:07.356811000 -0700 -@@ -134,6 +134,13 @@ - upsname[@hostname[:port]]\&. The default hostname is "localhost"\&. - .RE - .PP -+\fB\-m\fR \fItuple\fR -+.RS 4 -+Monitor multiple UPSs. The format for this option is a tuple of -+ups, logfile, and pidfile separated by commas. An example would be: -+`upsname@hostname:9999,/var/log/nut/cps.log,/var/run/cps.pid` -+.RE -+.PP - \fB\-u\fR \fIusername\fR - .RS 4 - If started as root, upslog will diff --git a/sysutils/nut/files/patch-include_nut__stdint.h b/sysutils/nut/files/patch-include_nut__stdint.h deleted file mode 100644 index fdd2bd783c61..000000000000 --- a/sysutils/nut/files/patch-include_nut__stdint.h +++ /dev/null @@ -1,31 +0,0 @@ ---- include/nut_stdint.h.orig 2022-08-24 07:49:23.934399000 -0700 -+++ include/nut_stdint.h 2022-08-24 07:56:48.050406000 -0700 -@@ -52,6 +52,28 @@ - #endif - - /* Printing format for size_t and ssize_t */ -+#ifndef PRIuSIZE -+# ifdef PRIsize -+# define PRIuSIZE PRIsize -+# else -+# if defined(__MINGW32__) || defined (WIN32) -+# define PRIuSIZE "llu" -+# else -+# define PRIuSIZE "zu" -+# endif -+# endif -+#endif -+ -+#ifndef PRIxSIZE -+# if defined(__MINGW32__) || defined (WIN32) -+# define PRIxSIZE "llx" -+# else -+# define PRIxSIZE "zx" -+# endif -+#endif -+ -+/* Note: Windows headers are known to define at least "d" values, -+ * so macros below revolve around that and not "i" directly */ - #ifndef PRIsize - # if defined(__MINGW32__) - # define PRIsize "u"