Date: Wed, 27 Feb 2008 07:58:40 GMT From: Adrian Penisoara <ady@freebsd.ady.ro> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/121141: [ports] fix apcaccess functionality in apcupsd package Message-ID: <200802270758.m1R7weRj084784@www.freebsd.org> Resent-Message-ID: <200802270810.m1R8A1sE090939@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 121141 >Category: ports >Synopsis: [ports] fix apcaccess functionality in apcupsd package >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Feb 27 08:10:00 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Adrian Penisoara >Release: 7.0-RC3 >Organization: EntepriseBSD >Environment: FreeBSD husky.ady.ro 7.0-RC3 FreeBSD 7.0-RC3 #0: Sun Feb 24 20:26:26 EET 2008 root@husky.ady.ro:/usr/obj/usr/src/sys/HUSKY i386 >Description: In recent sysutils/apcupsd package versions the apcaccess tool has been "downsized" to its minimal "status" functionality, thus the developer(s) have stripped down a lot of code from it -- from the Changelog: 2007-08-03 11:17 adk0212 * src/apcaccess.c: Remove lots of obsolete code. 'status' is now the only supported option. However, together with this "downsizing" operation some critical functionality: the tools is not able anymore to fetch the apcuspd daemon binding point (host:port) from its configuration file; by default it can query only the localhost:3551 address. This will impact running the tool for non-default apcupsd configurations. While it previously was able to correctly read daemon binding point from the configuration file, it can no longer do so in the new versions. >How-To-Repeat: Configure your apcupsd daemon (in /usr/local/etc/apcupsd/apcupsd.conf) to run on a non-default IP and/or port. Running the "apcaccess [status]" command will fail now, including when ran from the default-action scripts like "commok" , "offbattery, "onbattery", etc. This will show up in email reports and web interface. >Fix: I have backported some minimal code from the 3.12.4 sources to restore the missing functionality (reading host:port configuration from the configuration file). See patch attached (raises PORTREVISION). Patch attached with submission follows: diff -ruN apcupsd.orig/Makefile apcupsd/Makefile --- apcupsd.orig/Makefile 2007-10-21 13:39:38.000000000 +0300 +++ apcupsd/Makefile 2008-02-27 09:39:19.659171480 +0200 @@ -7,6 +7,7 @@ PORTNAME= apcupsd PORTVERSION= 3.14.2 +PORTREVISION= 1 CATEGORIES= sysutils MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:S/$/:src_sf/g} \ http://sce-tindy.tecnik93.com/FreeBSD/ports/${PORTNAME}/sources/:src_bk \ diff -ruN apcupsd.orig/files/patch-aa apcupsd/files/patch-aa --- apcupsd.orig/files/patch-aa 1970-01-01 02:00:00.000000000 +0200 +++ apcupsd/files/patch-aa 2008-02-27 09:36:59.310547004 +0200 @@ -0,0 +1,51 @@ +--- src/apcaccess.c.orig 2007-08-03 18:17:38.000000000 +0300 ++++ src/apcaccess.c 2008-02-27 09:30:39.352400647 +0200 +@@ -62,11 +62,19 @@ + int main(int argc, char **argv) + { + int mode = 0; ++ UPSINFO *ups = NULL; ++ ++ char *cfgfile = APCCONF; ++ struct stat cfgstat; + + #ifdef HAVE_MINGW + WSA_Init(); /* init MS networking */ + #endif + ++ ups = attach_ups(ups); ++ if (!ups) ++ Error_abort0(_("Cannot attach SYSV IPC.\n")); ++ + if (argc < 2) { + /* Assume user wants "status" */ + mode = 2; +@@ -87,6 +95,20 @@ + *p++ = 0; + port = atoi(p); + } ++ } else { ++ /* check configuration so local NISIP and NISPORT variables can be used as ++ defaults */ ++ if (!stat(cfgfile, &cfgstat)) { ++ check_for_config(ups, cfgfile); ++ ++ if (ups) { ++ if (ups->nisip && ups->nisip[0]) ++ host = ups->nisip; ++ ++ if (ups->statusport) ++ port = ups->statusport; ++ } ++ } + } + + if (!*host || strcmp(host, "0.0.0.0") == 0) +@@ -101,5 +123,7 @@ + Error_abort0(_("Strange mode\n")); + } + ++ detach_ups(ups); ++ + return 0; + } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802270758.m1R7weRj084784>