Update to 1.4.1.

In addition to the standard bugfixes, this is a major port rewrite.
The port now uses a '_ups' user and the CGIs created can now run under
either chrooted Apache or non-chrooted Apache.
This commit is contained in:
marcm 2004-02-09 06:48:48 +00:00
parent fd394d0188
commit 85dc249d41
26 changed files with 551 additions and 173 deletions

View File

@ -1,34 +1,35 @@
# $OpenBSD: Makefile,v 1.10 2003/03/30 16:19:25 marcm Exp $
# $OpenBSD: Makefile,v 1.11 2004/02/09 06:48:48 marcm Exp $
COMMENT= "UPS monitoring program supporting many brands"
COMMENT-cgi= "CGIs for monitoring Nut-based UPSs"
VERSION= 1.2.1
VERSION= 1.4.1
DISTNAME= nut-${VERSION}
PKGNAME-cgi= nut-cgi-${VERSION}
CATEGORIES= sysutils
HOMEPAGE= http://www.exploits.org/nut/
HOMEPAGE= http://www.networkupstools.org/
MAINTAINER= Marc Matteo <marcm@openbsd.org>
MASTER_SITES= http://random.networkupstools.org/source/1.4/
# GPL
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
MASTER_SITES= http://penguin.harrison.k12.co.us/mirrors/nut/release/1.2/ \
${HOMEPAGE}release/1.2/
FAKE_FLAGS= INSTALLROOT="${WRKINST}"
CGI_CFG= hosts.conf upsset.conf upsstats.html upsstats-single.html
WEB_ROOT= /var/www
CONFIGURE_STYLE= gnu
CONFIGURE_ARGS+= --with-statepath="/var/db/nut"
CONFIGURE_ARGS+= --with-user=uucp
CONFIGURE_ARGS+= --with-group=dialer
NUT_USER= _ups
NUT_ID= 528
NUT_STATEDIR= /var/db/nut
CONFDIR= ${SYSCONFDIR}/nut
SUBST_VARS= NUT_USER NUT_ID NUT_STATEDIR CONFDIR
CONFIGURE_STYLE= gnu old
CONFIGURE_ARGS+= --sysconfdir=${CONFDIR}
CONFIGURE_ARGS+= --with-statepath=${NUT_STATEDIR}
CONFIGURE_ARGS+= --with-user=${NUT_USER}
CONFIGURE_ARGS+= --with-ssl
PSEUDO_FLAVORS= no_cgi
@ -49,9 +50,8 @@ BUILD_DEPENDS= :gd->=1.8.3:graphics/gd
CONFIGURE_ARGS+= --with-cgi
CONFIGURE_ARGS+= --with-cgipath="${WEB_ROOT}/cgi-bin/nut"
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
LDFLAGS="-L${LOCALBASE}/lib" \
CFLAGS="${CFLAGS} -I${LOCALBASE}/include -L${LOCALBASE}/lib"
CONFIGURE_ARGS+= --with-gd-libs="-L${LOCALBASE}/lib -lgd -lpng -lz -ljpeg -lttf -lm"
CONFIGURE_ARGS+= --with-gd-includes="-I${LOCALBASE}/include"
ALL_TARGET= all cgi
INSTALL_TARGET= install install-cgi
@ -64,12 +64,12 @@ post-install:
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/nut
cp -R ${WRKSRC}/docs/* ${PREFIX}/share/doc/nut/
# Yes, we install the CGI config files even if we're not building CGI support,
# it will get properly handled by the packaging.
# it will get properly handled by packaging.
${INSTALL_DATA_DIR} ${WRKINST}${WEB_ROOT}/conf/nut
.for file in ${CGI_CFG}
mv ${WRKINST}/${SYSCONFDIR}/nut/${file}.sample ${WRKINST}${WEB_ROOT}/conf/nut/
.for file in hosts.conf upsset.conf upsstats.html upsstats-single.html
mv ${WRKINST}/${CONFDIR}/${file}.sample ${WRKINST}${WEB_ROOT}/conf/nut/
.endfor
@${INSTALL_DATA_DIR} ${PREFIX}/share/examples/nut; \
cp -Rp ${WRKINST}/${SYSCONFDIR}/nut/* ${PREFIX}/share/examples/nut/
${INSTALL_DATA} ${WRKINST}/${CONFDIR}/* ${PREFIX}/share/examples/nut/
.include <bsd.port.mk>

View File

@ -1,3 +1,3 @@
MD5 (nut-1.2.1.tar.gz) = bf1147dbc04a6d5bb982d03720d2331e
RMD160 (nut-1.2.1.tar.gz) = 56185d560cf569c6fa92956424d23ad1550d1d72
SHA1 (nut-1.2.1.tar.gz) = db55b0165ef594ad1cf73bf5d3d9336a0ac0fb93
MD5 (nut-1.4.1.tar.gz) = ae91ea3d643d7665bda0a95ce62957a0
RMD160 (nut-1.4.1.tar.gz) = 65be779ce1e4741f2ac6db3e1165e57573950999
SHA1 (nut-1.4.1.tar.gz) = b23920207d3bd6563172194546f26dbe7cfb7ec6

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-Makefile_in,v 1.2 2003/01/16 23:42:18 marcm Exp $
--- Makefile.in.orig Sat Dec 7 17:04:24 2002
+++ Makefile.in Sun Dec 29 11:33:37 2002
@@ -55,6 +55,7 @@ install-bin:
$OpenBSD: patch-Makefile_in,v 1.3 2004/02/09 06:48:48 marcm Exp $
--- Makefile.in.orig 2003-10-17 14:00:06.000000000 -0700
+++ Makefile.in 2004-01-03 10:08:46.000000000 -0800
@@ -49,6 +49,7 @@ install-bin:
install-man:
@cd man; $(MAKE) install; cd ..;
@ -9,7 +9,7 @@ $OpenBSD: patch-Makefile_in,v 1.2 2003/01/16 23:42:18 marcm Exp $
install-conf:
cd conf; $(MAKE) install; cd ..
@@ -84,7 +85,7 @@ build-cgi:
@@ -74,7 +75,7 @@ build-cgi:
@cd clients; $(MAKE) cgi; cd ..;
install-cgi: cgi install-cgi-dir install-dirs install-cgi-bin \

View File

@ -1,20 +1,20 @@
$OpenBSD: patch-clients_Makefile_in,v 1.2 2003/01/16 23:42:18 marcm Exp $
--- clients/Makefile.in.orig Mon Dec 2 04:09:20 2002
+++ clients/Makefile.in Sun Dec 29 16:38:29 2002
@@ -51,13 +51,13 @@ upslog: upslog.c upsclient.o $(LIBDEP)
$(CC) $(NET_CFLAGS) -o upslog upslog.c upsclient.o $(LIBOBJ) $(NET_LDFLAGS)
$OpenBSD: patch-clients_Makefile_in,v 1.3 2004/02/09 06:48:48 marcm Exp $
--- clients/Makefile.in.orig 2004-01-03 13:49:46.000000000 -0800
+++ clients/Makefile.in 2004-01-03 13:51:23.000000000 -0800
@@ -54,13 +54,13 @@ upslog: upslog.c $(UPSCLI_OBJ) $(LIBDEP)
$(CC) $(NET_CFLAGS) -o upslog upslog.c $(UPSCLI_OBJ) $(LIBOBJ) $(NET_LDFLAGS)
upsstats.cgi: upsstats.c upsclient.o cgilib.o ../common/parseconf.o $(LIBDEP)
- $(CC) $(NET_CFLAGS) -o upsstats.cgi upsstats.c upsclient.o cgilib.o ../common/parseconf.o $(LIBOBJ) $(NET_LDFLAGS)
+ $(CC) $(NET_CFLAGS) -o upsstats.cgi upsstats.c upsclient.o cgilib.o ../common/parseconf.o $(LIBOBJ) $(NET_LDFLAGS) -static
upsstats.cgi: upsstats.c $(UPSCLI_OBJ) cgilib.o $(LIBDEP)
- $(CC) $(NET_CFLAGS) -o upsstats.cgi upsstats.c $(UPSCLI_OBJ) cgilib.o $(LIBOBJ) $(NET_LDFLAGS)
+ $(CC) $(NET_CFLAGS) -o upsstats.cgi upsstats.c $(UPSCLI_OBJ) cgilib.o $(LIBOBJ) $(NET_LDFLAGS) -static
upsimage.cgi: upsimage.c upsclient.o cgilib.o $(LIBDEP)
- $(CC) $(NET_CFLAGS) $(GD_INCLUDES) -o upsimage.cgi upsimage.c upsclient.o cgilib.o $(GD_LIBS) $(LIBOBJ) $(NET_LDFLAGS)
+ $(CC) $(NET_CFLAGS) $(GD_INCLUDES) -o upsimage.cgi upsimage.c upsclient.o cgilib.o $(GD_LIBS) $(LIBOBJ) $(NET_LDFLAGS) -lgd -static
upsimage.cgi: upsimage.c $(UPSCLI_OBJ) cgilib.o $(LIBDEP)
- $(CC) $(NET_CFLAGS) $(GD_INCLUDES) -o upsimage.cgi upsimage.c $(UPSCLI_OBJ) cgilib.o $(GD_LIBS) $(LIBOBJ) $(NET_LDFLAGS)
+ $(CC) $(NET_CFLAGS) $(GD_INCLUDES) -o upsimage.cgi upsimage.c $(UPSCLI_OBJ) cgilib.o $(GD_LIBS) $(LIBOBJ) $(NET_LDFLAGS) -static
upsset.cgi: upsset.c upsclient.o cgilib.o ../common/parseconf.o $(LIBDEP)
- $(CC) $(NET_CFLAGS) -o upsset.cgi upsset.c upsclient.o cgilib.o ../common/parseconf.o $(LIBOBJ) $(NET_LDFLAGS)
+ $(CC) $(NET_CFLAGS) -o upsset.cgi upsset.c upsclient.o cgilib.o ../common/parseconf.o $(LIBOBJ) $(NET_LDFLAGS) -static
upsset.cgi: upsset.c $(UPSCLI_OBJ) cgilib.o $(LIBDEP)
- $(CC) $(NET_CFLAGS) -o upsset.cgi upsset.c $(UPSCLI_OBJ) cgilib.o $(LIBOBJ) $(NET_LDFLAGS)
+ $(CC) $(NET_CFLAGS) -o upsset.cgi upsset.c $(UPSCLI_OBJ) cgilib.o $(LIBOBJ) $(NET_LDFLAGS) -static
upsmon: upsmon.c upsclient.o ../common/parseconf.o $(LIBDEP)
$(CC) $(NET_CFLAGS) -o upsmon upsmon.c upsclient.o ../common/parseconf.o $(LIBOBJ) $(NET_LDFLAGS)
upsmon: upsmon.c $(UPSCLI_OBJ) $(LIBDEP)
$(CC) $(NET_CFLAGS) -o upsmon upsmon.c $(UPSCLI_OBJ) $(LIBOBJ) $(NET_LDFLAGS)

View File

@ -1,12 +1,12 @@
$OpenBSD: patch-clients_cgilib_c,v 1.2 2003/01/16 23:42:18 marcm Exp $
--- clients/cgilib.c.orig Tue Aug 20 07:39:06 2002
+++ clients/cgilib.c Sun Dec 29 11:31:52 2002
@@ -155,7 +155,7 @@ int checkhost(char *check, char **desc)
if (!check)
$OpenBSD: patch-clients_cgilib_c,v 1.3 2004/02/09 06:48:48 marcm Exp $
--- clients/cgilib.c.orig 2004-01-03 14:55:07.000000000 -0800
+++ clients/cgilib.c 2004-01-03 14:55:22.000000000 -0800
@@ -162,7 +162,7 @@ int checkhost(const char *host, char **d
if (!host)
return 0; /* deny null hostnames */
- snprintf(fn, sizeof(fn), "%s/hosts.conf", CONFPATH);
+ snprintf(fn, sizeof(fn), "%s/hosts.conf", CGICONFPATH);
hostlist = fopen(fn, "r");
- snprintf(fn, sizeof(fn), "%s/hosts.conf", confpath());
+ snprintf(fn, sizeof(fn), "%s/hosts.conf", cgiconfpath());
pconf_init(&ctx, cgilib_err);
if (hostlist == NULL)

View File

@ -1,21 +1,21 @@
$OpenBSD: patch-clients_upsset_c,v 1.2 2003/01/16 23:42:18 marcm Exp $
--- clients/upsset.c.orig Fri Sep 6 08:10:49 2002
+++ clients/upsset.c Sun Dec 29 11:44:39 2002
@@ -294,7 +294,7 @@ static void do_pickups(const char *currf
$OpenBSD: patch-clients_upsset_c,v 1.3 2004/02/09 06:48:48 marcm Exp $
--- clients/upsset.c.orig 2004-01-03 14:55:55.000000000 -0800
+++ clients/upsset.c 2004-01-03 14:56:19.000000000 -0800
@@ -299,7 +299,7 @@ static void do_pickups(const char *currf
char hostfn[SMALLBUF];
int ret;
PCONF_CTX ctx;
- snprintf(hostfn, sizeof(hostfn), "%s/hosts.conf", CONFPATH);
+ snprintf(hostfn, sizeof(hostfn), "%s/hosts.conf", CGICONFPATH);
- snprintf(hostfn, sizeof(hostfn), "%s/hosts.conf", confpath());
+ snprintf(hostfn, sizeof(hostfn), "%s/hosts.conf", cgiconfpath());
printf("<FORM METHOD=\"POST\" ACTION=\"upsset.cgi\">\n");
@@ -929,7 +929,7 @@ static void check_conf(void)
@@ -1495,7 +1495,7 @@ static void check_conf(void)
char fn[SMALLBUF];
int ret;
PCONF_CTX ctx;
- snprintf(fn, sizeof(fn), "%s/upsset.conf", CONFPATH);
+ snprintf(fn, sizeof(fn), "%s/upsset.conf", CGICONFPATH);
- snprintf(fn, sizeof(fn), "%s/upsset.conf", confpath());
+ snprintf(fn, sizeof(fn), "%s/upsset.conf", cgiconfpath());
ret = parseconf(fn, upsset_conf_arg, upsset_conf_err);
pconf_init(&ctx, upsset_conf_err);

View File

@ -1,21 +1,21 @@
$OpenBSD: patch-clients_upsstats_c,v 1.1 2003/01/16 23:42:18 marcm Exp $
--- clients/upsstats.c.orig Tue Oct 29 07:12:42 2002
+++ clients/upsstats.c Sun Dec 29 18:10:20 2002
@@ -594,7 +594,7 @@ static void display_template(const char
$OpenBSD: patch-clients_upsstats_c,v 1.2 2004/02/09 06:48:48 marcm Exp $
--- clients/upsstats.c.orig 2004-01-03 14:54:09.000000000 -0800
+++ clients/upsstats.c 2004-01-03 14:54:42.000000000 -0800
@@ -621,7 +621,7 @@ static void display_template(const char
{
char fn[SMALLBUF], buf[LARGEBUF];
- snprintf(fn, sizeof(fn), "%s/%s", CONFPATH, tfn);
+ snprintf(fn, sizeof(fn), "%s/%s", CGICONFPATH, tfn);
- snprintf(fn, sizeof(fn), "%s/%s", confpath(), tfn);
+ snprintf(fn, sizeof(fn), "%s/%s", cgiconfpath(), tfn);
tf = fopen(fn, "r");
@@ -670,7 +670,7 @@ static void load_hosts_conf(void)
{
@@ -678,7 +678,7 @@ static void load_hosts_conf(void)
char fn[SMALLBUF];
PCONF_CTX ctx;
- snprintf(fn, sizeof(fn), "%s/hosts.conf", CONFPATH);
+ snprintf(fn, sizeof(fn), "%s/hosts.conf", CGICONFPATH);
parseconf(fn, hosts_conf_args, hosts_conf_error);
}
+ snprintf(fn, sizeof(fn), "%s/hosts.conf", cgiconfpath());
pconf_init(&ctx, upsstats_hosts_err);

View File

@ -0,0 +1,21 @@
$OpenBSD: patch-common_common_c,v 1.1 2004/02/09 06:48:48 marcm Exp $
--- common/common.c.orig 2004-01-03 14:48:45.000000000 -0800
+++ common/common.c 2004-01-03 14:53:25.000000000 -0800
@@ -268,6 +268,17 @@ const char * confpath(void)
return path;
}
+/* return a config path for the CGIs so they can be kept seperate */
+const char * cgiconfpath(void)
+{
+ const char * path;
+
+ if ((path = getenv("NUT_CGICONFPATH")) == NULL)
+ path = CGICONFPATH;
+
+ return path;
+}
+
/* Return the default path for the directory containing state files */
const char * dflt_statepath(void)
{

View File

@ -1,30 +1,12 @@
$OpenBSD: patch-configure,v 1.4 2003/03/30 16:19:25 marcm Exp $
--- configure.orig Mon Dec 2 04:08:51 2002
+++ configure Thu Mar 27 23:56:17 2003
@@ -556,7 +556,7 @@ do
ac_prev=sysconfdir ;;
-sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
| --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir=$ac_optarg ;;
+ sysconfdir="$ac_optarg/nut" ;;
-target | --target | --targe | --targ | --tar | --ta | --t)
ac_prev=target_alias ;;
@@ -1338,7 +1338,7 @@ BUILDOBJ=common.o
GD_INCLUDES=""
-GD_LIBS="-L/usr/X11R6/lib -lgd -lpng -lz -ljpeg -lfreetype -lm -lXpm -lX11"
+GD_LIBS="-lgd -lpng -lz -ljpeg -lttf -lm"
ac_ext=c
@@ -4007,7 +4007,7 @@ rm -f conftest.$ac_objext conftest$ac_ex
int F77_DUMMY_MAIN() { return 1; }
#endif
$OpenBSD: patch-configure,v 1.5 2004/02/09 06:48:48 marcm Exp $
--- configure.orig 2004-01-04 23:26:22.000000000 -0800
+++ configure 2004-01-04 23:27:00.000000000 -0800
@@ -4856,7 +4856,7 @@ cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <openssl/ssl.h>
int
-main ()
+test_main ()
{
SSL_library_init
SSL_library_init()
;

View File

@ -0,0 +1,44 @@
$OpenBSD: patch-drivers_esupssmart_c,v 1.1 2004/02/09 06:48:48 marcm Exp $
--- drivers/esupssmart.c.orig 2003-06-11 01:58:06.000000000 -0700
+++ drivers/esupssmart.c 2004-01-03 10:54:40.000000000 -0800
@@ -70,7 +70,7 @@ void parse_str_num(const char *org, char
*dest='\0';
if (prec < 0 || prec > 99) prec = 5;
if (numdec < 0 || prec > 10) prec = 1;
- sprintf(myfmtstr,"%%0%d.%df",prec,numdec);
+ snprintf(myfmtstr,sizeof(myfmtstr),"%%0%d.%df",prec,numdec);
num = atof(org);
if (num < min || num > max)
num = defval;
@@ -304,12 +304,12 @@ void queryF( char *buf )
if (UPSFIRMSET == 0) {
if (UPSFIRM[0] == ' ') {
ModGuess = ModGuess * atof(value);
- sprintf(UPSFIRM,"%04.0f", ModGuess);
+ snprintf(UPSFIRM, sizeof (UPSFIRM), "%04.0f", ModGuess);
dstate_setinfo( "ups.firmware", "%s", UPSFIRM); /* INFO_FIRMREV */
}
else
{
- sprintf(UPSFIRM,"%s", "UNKNOWN");
+ snprintf(UPSFIRM, sizeof (UPSFIRM), "%s", "UNKNOWN");
dstate_setinfo( "ups.firmware" , "%s", UPSFIRM); /* INFO_FIRMREV */
}
UPSFIRMSET = 1;
@@ -420,14 +420,14 @@ int instcmd(const char *cmdname, const c
}
if (!strcasecmp(cmdname, "shutdown.return")) {
- sprintf(aux, "S%sR%s\x0D", strdelayshut, strwakedelay);
+ snprintf(aux, sizeof (aux), "S%sR%s\x0D", strdelayshut, strwakedelay);
upssend(aux);
upslogx(LOG_INFO,"Sending shutdown command '%s' to UPS", aux);
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "shutdown.stayoff")) {
- sprintf(aux, "S%sR0000\x0D", strdelayshut);
+ snprintf(aux, sizeof (aux), "S%sR0000\x0D", strdelayshut);
upssend(aux);
upslogx(LOG_INFO,"Sending shutdown command '%s' to UPS", aux);
return STAT_INSTCMD_HANDLED;

View File

@ -0,0 +1,42 @@
$OpenBSD: patch-drivers_mge-shut_c,v 1.1 2004/02/09 06:48:48 marcm Exp $
--- drivers/mge-shut.c.orig 2003-11-27 15:35:37.000000000 -0800
+++ drivers/mge-shut.c 2004-01-03 10:56:03.000000000 -0800
@@ -173,12 +173,12 @@ void upsdrv_shutdown (void)
if (sdtype == SD_RETURN) {
/* set DelayBeforeStartup */
- sprintf(val, "%d", ondelay);
+ snprintf(val, sizeof (val), "%d", ondelay);
hid_set_value("ups.delay.start", val);
}
/* set DelayBeforeShutdown */
- sprintf(val, "%d", offdelay);
+ snprintf(val, sizeof (val), "%d", offdelay);
hid_set_value("ups.delay.shutdown", val);
}
@@ -201,19 +201,19 @@ void upsdrv_makevartable (void)
upsdebugx (2, "entering upsdrv_makevartable()");
- sprintf(msg, "Set low battery level, in %% (default=%d).",
+ snprintf(msg, sizeof (msg), "Set low battery level, in %% (default=%d).",
DEFAULT_LOWBATT);
addvar (VAR_VALUE, "lowbatt", msg);
- sprintf(msg, "Set shutdown delay, in seconds (default=%d).",
+ snprintf(msg, sizeof (msg), "Set shutdown delay, in seconds (default=%d).",
DEFAULT_OFFDELAY);
addvar (VAR_VALUE, "offdelay", msg);
- sprintf(msg, "Set startup delay, in ten seconds units (default=%d).",
+ snprintf(msg, sizeof (msg), "Set startup delay, in ten seconds units (default=%d).",
DEFAULT_ONDELAY);
addvar (VAR_VALUE, "ondelay", msg);
- sprintf(msg, "Set notification type, 1 = no, 2 = light, 3 = yes (default=%d).",
+ snprintf(msg, sizeof (msg), "Set notification type, 1 = no, 2 = light, 3 = yes (default=%d).",
DEFAULT_NOTIFICATION);
addvar (VAR_VALUE, "notification", msg);
}

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-drivers_mge-utalk_c,v 1.1 2004/02/09 06:48:48 marcm Exp $
--- drivers/mge-utalk.c.orig 2003-06-11 01:57:41.000000000 -0700
+++ drivers/mge-utalk.c 2004-01-03 10:54:04.000000000 -0800
@@ -467,8 +467,8 @@ int setvar(const char *varname, const ch
if(info_variable_ok(varname)) {
/* format command */
- sprintf(cmd, "%s", info_variable_cmd(varname));
- sprintf(strchr(cmd, '?'), "%s", val);
+ snprintf(cmd, sizeof (cmd), "%s", info_variable_cmd(varname));
+ snprintf(strchr(cmd, '?'), sizeof (cmd), "%s", val);
/* Execute command */
mge_command(temp, sizeof(temp), cmd);

View File

@ -0,0 +1,30 @@
$OpenBSD: patch-drivers_microdowell_c,v 1.1 2004/02/09 06:48:48 marcm Exp $
--- drivers/microdowell.c.orig 2004-01-03 10:37:16.000000000 -0800
+++ drivers/microdowell.c 2004-01-03 10:38:17.000000000 -0800
@@ -79,7 +79,7 @@ static int ups_model_ok (char *buf, unsi
dstate_setinfo("ups.model", "BBox Pro USB");
upslogx(LOG_NOTICE, "BBox Pro USB rev. %d on %s.\n", upsRelease, device_path);
}
- sprintf (upsSerial, "SH%c.%c", buf[4], buf[6]);
+ snprintf (upsSerial, sizeof (upsSerial), "SH%c.%c", buf[4], buf[6]);
dstate_setinfo("ups.serial", "%s", upsSerial);
return (100 + upsRelease);
}
@@ -95,7 +95,7 @@ static int ups_model_ok (char *buf, unsi
"BBox Interactive USB");
upslogx(LOG_NOTICE, "BBox Interactive USB rev. %d on %s.\n", upsRelease, device_path);
}
- sprintf (upsSerial, "MD%c.%c", buf[4], buf[6]);
+ snprintf (upsSerial, sizeof (upsSerial), "MD%c.%c", buf[4], buf[6]);
dstate_setinfo("ups.serial", "%s", upsSerial);
return (upsRelease);
}
@@ -104,7 +104,7 @@ static int ups_model_ok (char *buf, unsi
upsRelease = (buf[4] - '0') * 10 + buf[6] - '0';
dstate_setinfo("ups.model", "HiBox USB");
upslogx(LOG_NOTICE, "HiBox USB rev. %d on %s.\n", upsRelease, device_path);
- sprintf (upsSerial, "B5%c.%c", buf[4], buf[6]);
+ snprintf (upsSerial, sizeof (upsSerial), "B5%c.%c", buf[4], buf[6]);
dstate_setinfo("ups.serial", "%s", upsSerial);
return (upsRelease);
}

View File

@ -0,0 +1,17 @@
$OpenBSD: patch-drivers_sec_c,v 1.1 2004/02/09 06:48:48 marcm Exp $
--- drivers/sec.c.orig 2004-01-03 10:22:53.000000000 -0800
+++ drivers/sec.c 2004-01-03 10:24:29.000000000 -0800
@@ -213,11 +213,11 @@ int sec_cmd(const char mode, const char
/* create the message string */
if (*buflen > 0) {
- sprintf(msg, "%c%c%03d%s%s", SEC_MSG_STARTCHAR,
+ snprintf(msg, sizeof (msg), "%c%c%03d%s%s", SEC_MSG_STARTCHAR,
mode, (*buflen)+3, command, msgbuf);
}
else {
- sprintf(msg, "%c%c003%s", SEC_MSG_STARTCHAR,
+ snprintf(msg, sizeof (msg), "%c%c003%s", SEC_MSG_STARTCHAR,
mode, command);
}
upsdebugx(1, "PC-->UPS: \"%s\"",msg);

View File

@ -0,0 +1,39 @@
$OpenBSD: patch-drivers_tripplite_c,v 1.1 2004/02/09 06:48:48 marcm Exp $
--- drivers/tripplite.c.orig 2004-01-03 10:23:48.000000000 -0800
+++ drivers/tripplite.c 2004-01-03 10:25:55.000000000 -0800
@@ -322,7 +322,7 @@ void upsdrv_updateinfo(void)
switch (buf[0]) {
case '0': status_set("LB"); break; /* Low Battery */
case '1': break; /* Normal */
- default: sprintf(temp, "BAT-%c?", buf[0]);
+ default: snprintf(temp, sizeof (temp), "BAT-%c?", buf[0]);
status_set(temp);
break; /* Unknown */
}
@@ -331,7 +331,7 @@ void upsdrv_updateinfo(void)
switch (buf[1]) {
case '0': status_set("OVER"); break; /* Overload */
case '1': break; /* Normal */
- default: sprintf(temp, "LOAD-%c?", buf[1]);
+ default: snprintf(temp, sizeof (temp), "LOAD-%c?", buf[1]);
status_set(temp);
break; /* Unknown */
}
@@ -342,7 +342,7 @@ void upsdrv_updateinfo(void)
case '1': status_set("TRIM"); break; /* Reducing */
case '2': status_set("BOOST"); break; /* Boost */
case '3': status_set("BOOST"); break; /* Extra Boost */
- default: sprintf(temp, "TAP-%c?", buf[4]);
+ default: snprintf(temp, sizeof (temp), "TAP-%c?", buf[4]);
status_set(temp);
break; /* Unknown */
}
@@ -353,7 +353,7 @@ void upsdrv_updateinfo(void)
case '1': status_set("OB"); break; /* On Battery */
case '2': status_set("OL"); break; /* On Line */
case '3': status_set("OB"); break; /* On Battery */
- default: sprintf(temp, "MODE-%c?", buf[5]);
+ default: snprintf(temp, sizeof (temp), "MODE-%c?", buf[5]);
status_set(temp);
break; /* Unknown */
}

View File

@ -0,0 +1,68 @@
$OpenBSD: patch-drivers_tripplitesu_c,v 1.1 2004/02/09 06:48:48 marcm Exp $
--- drivers/tripplitesu.c.orig 2004-01-03 10:41:57.000000000 -0800
+++ drivers/tripplitesu.c 2004-01-03 10:44:21.000000000 -0800
@@ -329,7 +329,7 @@ static void set_transfer_voltage_low(int
if (!ptr)
return;
high = atoi(ptr);
- sprintf(response, "%d;%d", val, high);
+ snprintf(response, sizeof(response), "%d;%d", val, high);
do_command(SET, TRANSFER_VOLTAGE, response, NULL);
}
@@ -361,7 +361,7 @@ static void set_transfer_voltage_high(in
ptr = field(response, 1);
if (!ptr || val == atoi(ptr))
return;
- sprintf(response, "%d;%d", low, val);
+ snprintf(response, sizeof(response), "%d;%d", low, val);
do_command(SET, TRANSFER_VOLTAGE, response, NULL);
}
@@ -388,7 +388,7 @@ static void set_sensitivity(const char *
for (i = 0; i < sizeof(sensitivity) / sizeof(sensitivity[0]); i++) {
if (!strcasecmp(val, sensitivity[i].name)) {
- sprintf(parm, "%d", i);
+ snprintf(parm, sizeof (parm), "%d", i);
do_command(SET, VOLTAGE_SENSITIVITY, parm, NULL);
break;
}
@@ -409,7 +409,7 @@ static void auto_reboot(int enable) {
return;
ptr = field(response, 0);
if (!ptr || atoi(ptr) != mode) {
- sprintf(parm, "%d", mode);
+ snprintf(parm, sizeof (parm), "%d", mode);
do_command(SET, AUTO_REBOOT, parm, NULL);
}
}
@@ -421,14 +421,14 @@ static int instcmd(const char *cmdname,
if (!strcasecmp(cmdname, "load.off")) {
for (i = 0; i < ups.outlet_banks; i++) {
- sprintf(parm, "%d;1", i + 1);
+ snprintf(parm, sizeof (parm), "%d;1", i + 1);
do_command(SET, RELAY_OFF, parm, NULL);
}
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "load.on")) {
for (i = 0; i < ups.outlet_banks; i++) {
- sprintf(parm, "%d;1", i + 1);
+ snprintf(parm, sizeof (parm), "%d;1", i + 1);
do_command(SET, RELAY_ON, parm, NULL);
}
return STAT_INSTCMD_HANDLED;
@@ -782,9 +782,9 @@ void upsdrv_shutdown(void)
auto_reboot(1);
/* in case the power is on, tell it to automatically reboot. if
it is off, this has no effect. */
- sprintf(parm, "%d", 1); /* delay before reboot, in minutes */
+ snprintf(parm, sizeof (parm), "%d", 1); /* delay before reboot, in minutes */
do_command(SET, SHUTDOWN_RESTART, parm, NULL);
- sprintf(parm, "%d", 5); /* delay before shutdown, in seconds */
+ snprintf(parm, sizeof (parm), "%d", 5); /* delay before shutdown, in seconds */
do_command(SET, SHUTDOWN_ACTION, parm, NULL);
}

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-drivers_upscommon_c,v 1.1 2004/02/09 06:48:48 marcm Exp $
--- drivers/upscommon.c.orig 2003-06-11 04:22:59.000000000 -0700
+++ drivers/upscommon.c 2004-01-03 10:21:45.000000000 -0800
@@ -432,7 +432,7 @@ void upsflushin(int expected, int debugi
*ptr = 0; /* tie of string */
left--;
} else {
- sprintf(ptr, "\\%03o", in);
+ snprintf(ptr, sizeof (logstr), "\\%03o", in);
ptr += 4;
left--;
}

View File

@ -0,0 +1,13 @@
$OpenBSD: patch-include_common_h,v 1.1 2004/02/09 06:48:48 marcm Exp $
--- include/common.h.orig 2004-01-03 14:59:38.000000000 -0800
+++ include/common.h 2004-01-03 14:59:40.000000000 -0800
@@ -80,6 +80,9 @@ void syslogbit_set(void);
/* Return the default path for the directory containing configuration files */
const char * confpath(void);
+/* return a config path for the CGIs so they can be kept seperate */
+const char * cgiconfpath(void);
+
/* Return the default path for the directory containing state files */
const char * dflt_statepath(void);

View File

@ -1,9 +1,9 @@
$OpenBSD: patch-include_config_h_in,v 1.2 2003/01/17 06:23:43 marcm Exp $
--- include/config.h.in.orig Sun Nov 17 07:55:46 2002
+++ include/config.h.in Sun Dec 29 11:46:26 2002
@@ -9,6 +9,9 @@
/* Default path for configuration files */
#undef CONFPATH
$OpenBSD: patch-include_config_h_in,v 1.3 2004/02/09 06:48:48 marcm Exp $
--- include/config.h.in.orig 2003-08-22 19:56:06.000000000 -0700
+++ include/config.h.in 2004-01-03 10:08:47.000000000 -0800
@@ -12,6 +12,9 @@
/* Default path for data files */
#undef DATADIR
+/* path where CGI configuration files are looked for by a chrooted Apache */
+#define CGICONFPATH "/conf/nut"

View File

@ -1,34 +1,62 @@
#!/bin/sh
#
# $OpenBSD: DEINSTALL,v 1.3 2003/03/30 16:19:25 marcm Exp $
# $OpenBSD: DEINSTALL,v 1.4 2004/02/09 06:48:48 marcm Exp $
#
set -e
PATH=/bin:/usr/bin:/sbin:/usr/sbin
FILES='
nut/ups.conf
nut/upssched.conf
nut/upsmon.conf
nut/upsd.conf
nut/upsd.users
ups.conf
upssched.conf
upsmon.conf
upsd.conf
upsd.users
'
echo
echo "+--------------- $1"
echo "| To fully remove $1 from your system you should also"
echo "| remove the configuration files from the ${SYSCONFDIR}/nut directory."
echo "| Remove the directories in which the files reside as well if empty."
echo "|"
echo "| If you are planning on installing $1 again in the future"
echo "| you can leave it as it is."
echo "|"
echo "| FYI, the following configuration files belong to this package:"
echo "|"
for f in ${FILES}; do
echo "| ${SYSCONFDIR}/$f"
done
echo "+--------------- $1"
echo
do_notice()
{
echo
echo "+--------------- $1"
echo "| To fully remove $1 from your system you should also"
echo "| remove the configuration files from the ${CONFDIR}/nut directory."
echo "| Remove the directories in which the files reside as well if empty."
echo "|"
echo "| You should also remove the '_ups' user from the system by running:"
echo "|"
echo "| userdel _ups"
echo "|"
echo "| If you are planning on installing $1 again in the future"
echo "| you can leave them as they are."
echo "|"
echo "| FYI, the following configuration files belong to this package:"
echo "|"
for f in ${FILES}; do
echo "| ${CONFDIR}/$f"
done
echo "+--------------- $1"
echo
}
# Verify proper execution
#
if [ $# -ne 2 ]; then
echo "usage: $0 distname DEINSTALL" >&2
exit 1
fi
# Verify/process the command
#
case $2 in
DEINSTALL)
if [ "$PKG_DELETE_EXTRA" != Yes ]; then
do_notice "$1"
fi
;;
*)
echo "usage: $0 distname DEINSTALL" >&2
exit 1
;;
esac
exit 0

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# $OpenBSD: DEINSTALL-cgi,v 1.3 2003/03/30 16:19:25 marcm Exp $
# $OpenBSD: DEINSTALL-cgi,v 1.4 2004/02/09 06:48:48 marcm Exp $
#
set -e
@ -16,21 +16,45 @@ upsstats.html
WEBCONFDIR=${PREFIX}/conf/nut
echo
echo "+--------------- $1"
echo "| To fully remove $1 from your system you should also"
echo "| remove the configuration files from the ${WEBCONFDIR} directory."
echo "| Remove the directories in which the files reside as well if empty."
echo "|"
echo "| If you are planning on installing $1 again in the future"
echo "| you can leave it as it is."
echo "|"
echo "| FYI, the following configuration files belong to this package:"
echo "|"
for f in ${FILES}; do
echo "| ${WEBCONFDIR}/$f"
done
echo "+--------------- $1"
echo
do_notice()
{
echo
echo "+--------------- $1"
echo "| To fully remove $1 from your system you should also"
echo "| remove the configuration files from the ${WEBCONFDIR} directory."
echo "| Remove the directories in which the files reside as well if empty."
echo "|"
echo "| If you are planning on installing $1 again in the future"
echo "| you can leave it as it is."
echo "|"
echo "| FYI, the following configuration files belong to this package:"
echo "|"
for f in ${FILES}; do
echo "| ${WEBCONFDIR}/$f"
done
echo "+--------------- $1"
echo
}
# Verify proper execution
#
if [ $# -ne 2 ]; then
echo "usage: $0 distname DEINSTALL" >&2
exit 1
fi
# Verify/process the command
#
case $2 in
DEINSTALL)
if [ "$PKG_DELETE_EXTRA" != Yes ]; then
do_notice "$1"
fi
;;
*)
echo "usage: $0 distname DEINSTALL" >&2
exit 1
;;
esac
exit 0

View File

@ -1,2 +1,7 @@
A set of CGI scripts that can query a Nut based UPS and display information
and statistics on a web page.
By default the Nut CGIs are desinged to work within OpenBSD's chrooted
Apapche webserver. If you disable the chroot feature you can use Apache's
SetEnv directive to override the configuration file location by setting
the NUT_CGICONFPATH environment variable.

View File

@ -1,32 +1,45 @@
#!/bin/sh
#
# $OpenBSD: INSTALL,v 1.5 2003/03/30 16:19:25 marcm Exp $
# $OpenBSD: INSTALL,v 1.6 2004/02/09 06:48:48 marcm Exp $
P_NAME=nut
DIRS='
nut
.
'
FILES='
nut/ups.conf
nut/upssched.conf
ups.conf
upssched.conf
'
PRIVATE_FILES='
nut/upsmon.conf
nut/upsd.conf
nut/upsd.users
upsmon.conf
upsd.conf
upsd.users
'
set -e
PREFIX=${PKG_PREFIX:-/usr/local}
PATH=/bin:/usr/bin:/sbin:/usr/sbin
do_post() {
do_create_user() {
if id -u ${NUT_USER} >/dev/null 2>/dev/null
then
echo "===> Using existing account '${NUT_USER}'"
else
echo "===> Creating user '${NUT_USER}'"
useradd -g dialer \
-c "UPS User" \
-d /var/empty \
-s /sbin/nologin \
-u ${NUT_ID} ${NUT_USER}
fi
}
DEST_PFX=${SYSCONFDIR}
SOURCE_PFX=${PREFIX}/share/examples
do_post() {
DEST_PFX=${CONFDIR}
SOURCE_PFX=${PREFIX}/share/examples/${P_NAME}
echo
echo "+--------------- ${P_NAME}"
@ -37,6 +50,10 @@ do_post() {
install -d ${DEST_PFX}/$d
fi
done
if [ ! -d "${NUT_STATEDIR}" ]; then
install -d -m 0700 -o ${NUT_USER} ${NUT_STATEDIR}
fi
# install or take note of existing config files
for f in ${FILES}; do
@ -106,6 +123,7 @@ fi
#
case $2 in
PRE-INSTALL)
do_create_user
;;
POST-INSTALL)
do_post

View File

@ -1,5 +1,5 @@
+--------------- nut
| Using the Nut package in OpenBSD environment:
| Using the Nut package in an OpenBSD environment:
|
| Once you have the config files under /etc/nut set up properly, the
| following block can be added to your /etc/rc.local file to start nut.

View File

@ -1,30 +1,34 @@
@comment $OpenBSD: PLIST,v 1.3 2003/01/17 06:23:43 marcm Exp $
@comment $OpenBSD: PLIST,v 1.4 2004/02/09 06:48:48 marcm Exp $
@pkgcfl upsd-*
bin/apcsmart
bin/bcmxcp
bin/belkin
bin/bestferrups801-807
bin/bestfortress
bin/bestuferrups
bin/bestups
bin/blazer
bin/cyberpower
bin/esupssmart
bin/etapro
bin/everups
bin/fentonups
bin/ferrups
bin/genericups
bin/hp
bin/isbmex
bin/liebert
bin/masterguard
bin/mge-ellipse
bin/mge-shut
bin/mge-utalk
bin/microdowell
bin/newapc
bin/oneac
bin/powercom
bin/safenet
bin/sec
bin/sms
bin/tripplite
bin/tripplitesu
bin/upsc
bin/upscmd
bin/upsdrvctl
@ -42,31 +46,32 @@ man/man5/upsstats.html.5
man/man8/apcsmart.8
man/man8/bcmxcp.8
man/man8/belkin.8
man/man8/bestferrups801-807.8
man/man8/bestfortress.8
man/man8/bestuferrups.8
man/man8/bestups.8
man/man8/cyberpower.8
man/man8/dummycons.8
man/man8/energizerups.8
man/man8/etapro.8
man/man8/everups.8
man/man8/fentonups.8
man/man8/ferrups.8
man/man8/genericups.8
man/man8/hp.8
man/man8/isbmex.8
man/man8/liebert.8
man/man8/masterguard.8
man/man8/mge-ellipse.8
man/man8/mge-shut.8
man/man8/mge-utalk.8
man/man8/microdowell.8
man/man8/newapc.8
man/man8/nutupsdrv.8
man/man8/oneac.8
man/man8/powercom.8
man/man8/powernet.8
man/man8/safenet.8
man/man8/sec.8
man/man8/sms.8
man/man8/snmp-ups.8
man/man8/tripplite.8
man/man8/tripplitesu.8
man/man8/upsc.8
man/man8/upscmd.8
man/man8/upsd.8
@ -82,6 +87,7 @@ man/man8/victronups.8
sbin/upsd
sbin/upsmon
sbin/upssched
share/cmdvartab
share/doc/nut/FAQ
share/doc/nut/README
share/doc/nut/big-servers.txt
@ -96,19 +102,20 @@ share/doc/nut/chroot.txt
share/doc/nut/commands.txt
share/doc/nut/config-files.txt
share/doc/nut/configure.txt
share/doc/nut/contact-closure.txt
share/doc/nut/data-room.txt
share/doc/nut/design.txt
share/doc/nut/developers.txt
share/doc/nut/driver.list
share/doc/nut/drivers/README
share/doc/nut/drivers/generic-ups.txt
share/doc/nut/drivers/mge-ellipse.txt
share/doc/nut/drivers/mge-utalk.txt
share/doc/nut/drivers/snmp-ups.txt
share/doc/nut/new-drivers.txt
share/doc/nut/new-names.txt
share/doc/nut/osd-notify.txt
share/doc/nut/pager.txt
share/doc/nut/powersaving.txt
share/doc/nut/protocol.txt
share/doc/nut/shutdown.txt
share/doc/nut/snmp.txt
share/doc/nut/sock-protocol.txt
share/doc/nut/ssl.txt
share/doc/nut/todo.txt
share/doc/nut/upssched.txt
@ -118,6 +125,14 @@ share/examples/nut/upsd.users.sample
share/examples/nut/upsmon.conf.sample
share/examples/nut/upssched.conf.sample
@dirrm share/examples/nut
@dirrm share/doc/nut/drivers
@dirrm share/doc/nut/cables
@dirrm share/doc/nut
@cwd ${SYSCONFDIR}
@extra nut/ups.conf
@extra nut/upsd.conf
@extra nut/upsd.users
@extra nut/upsmon.conf
@extra nut/upssched.conf
@extra nut/
@cwd /var/db
@extraunexec rm -rf %D/nut

View File

@ -1,4 +1,4 @@
@comment $OpenBSD: PLIST-cgi,v 1.2 2003/01/17 06:23:43 marcm Exp $
@comment $OpenBSD: PLIST-cgi,v 1.3 2004/02/09 06:48:48 marcm Exp $
cgi-bin/nut/upsimage.cgi
cgi-bin/nut/upsset.cgi
cgi-bin/nut/upsstats.cgi
@ -7,3 +7,9 @@ conf/nut/upsset.conf.sample
conf/nut/upsstats-single.html.sample
conf/nut/upsstats.html.sample
@dirrm cgi-bin/nut
@cwd conf
@extra nut/hosts.conf
@extra nut/upsset.conf
@extra nut/upsstats-single.html
@extra nut/upsstats.html
@extra nut/