Skip to content

Commit e286d0d

Browse files
authored
Merge branch 'master' into spellcheck-quick
2 parents a3b047d + 304f0c3 commit e286d0d

File tree

16 files changed

+590
-84
lines changed

16 files changed

+590
-84
lines changed

NEWS.adoc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ https://github.com/networkupstools/nut/milestone/9
4141

4242
- (expected) Bug fixes for fallout possible due to "fightwarn" effort in 2.8.0+
4343

44+
- Fix fallout of development in NUT v2.8.0 and/or v2.8.1 and/or v2.8.2 and/or
45+
v2.8.3:
46+
* Fixed a regression in recipes of NUT v2.8.3 release (as compared to
47+
v2.8.2), where `configure --with-docs=all` no longer failed a run
48+
of the `configure` script when some of the required rendering tools
49+
were not in fact available. [#2842]
50+
4451
- common code:
4552
* Revised common `writepid()` to use `altpidpath()` as location for the
4653
PID file creation, if the default `rootpidpath()` is not accessible
@@ -52,6 +59,27 @@ https://github.com/networkupstools/nut/milestone/9
5259
* Common code hardening: added sanity-checking for dynamically constructed
5360
or selected formatting strings with variable-argument list methods
5461
(typically used with log printing, `dstate` setting, etc.) [#2450]
62+
* Refactored repetitive implementations of `inet_ntopSS()` (nee
63+
`inet_ntopW()` in `upsd.c`) and `inet_ntopAI()` methods into `common.c`,
64+
so now they can be re-used or expanded more easily. [#2916]
65+
66+
- `upsd` updates:
67+
* Fixed two bugs about printing the "further (ignored) addresses resolved
68+
for this name": the way to extract IP address string was not portable
69+
and misfired on some platforms, and the way to print had a theoretical
70+
potential for buffer overflow. [#2915]
71+
72+
- `usbhid-ups` updates:
73+
* The `cps-hid` subdriver's existing mechanism for fixing broken report
74+
descriptors was extended to cover a newly reported case of nominal UPS
75+
power being incorrectly reported due to an unrealistically low maximum
76+
threshold, as seen with a EC850LCD device. [issue #2917, PR #2919]
77+
78+
- New NUT drivers:
79+
* Introduced a `ve-direct` driver for Victron Energy UPS/solar panels
80+
monitoring. Most specific reported values are in an `experimental.*`
81+
namespace, as a community we need to come up with standard naming for
82+
those via `docs/nut-names.txt`. [#440]
5583

5684

5785
Release notes for NUT 2.8.3 - what's new since 2.8.2

clients/upsclient.c

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2121
*/
2222

23+
#define NUT_WANT_INET_NTOP_XX 1
24+
2325
#include "config.h" /* safe because it doesn't contain prototypes */
2426
#include "nut_platform.h"
2527

@@ -1162,34 +1164,9 @@ int upscli_tryconnect(UPSCONN_t *ups, const char *host, uint16_t port, int flags
11621164
ups->upserror == UPSCLI_ERR_CONNFAILURE &&
11631165
ups->syserrno == ETIMEDOUT
11641166
) {
1165-
/* https://stackoverflow.com/a/29147085/4715872
1166-
* obviously INET6_ADDRSTRLEN is expected to be larger
1167-
* than INET_ADDRSTRLEN, but this may be required in case
1168-
* if for some unexpected reason IPv6 is not supported, and
1169-
* INET6_ADDRSTRLEN is defined as 0
1170-
* but this is not very likely and I am aware of no cases of
1171-
* this in practice (editor)
1172-
*/
1173-
char addrstr[(INET6_ADDRSTRLEN > INET_ADDRSTRLEN ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN) + 1];
1174-
addrstr[0] = '\0';
1175-
switch (ai->ai_family) {
1176-
case AF_INET: {
1177-
struct sockaddr_in addr_in;
1178-
memcpy(&addr_in, ai->ai_addr, sizeof(addr_in));
1179-
inet_ntop(AF_INET, &(addr_in.sin_addr), addrstr, INET_ADDRSTRLEN);
1180-
break;
1181-
}
1182-
case AF_INET6: {
1183-
struct sockaddr_in6 addr_in6;
1184-
memcpy(&addr_in6, ai->ai_addr, sizeof(addr_in6));
1185-
inet_ntop(AF_INET6, &(addr_in6.sin6_addr), addrstr, INET6_ADDRSTRLEN);
1186-
break;
1187-
}
1188-
default:
1189-
break;
1190-
}
1167+
const char *addrstr = inet_ntopAI(ai);
11911168
upslogx(LOG_WARNING, "%s: Connection to host timed out: '%s'",
1192-
__func__, *addrstr ? addrstr : NUT_STRARG(host));
1169+
__func__, (addrstr && *addrstr) ? addrstr : NUT_STRARG(host));
11931170
break;
11941171
}
11951172
continue;

common/common.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919
*/
2020

21+
#define NUT_WANT_INET_NTOP_XX 1
22+
2123
#include "common.h"
2224
#include "timehead.h"
2325

@@ -4713,3 +4715,67 @@ int match_regex_hex(const regex_t *preg, const int n)
47134715
return match_regex(preg, buf);
47144716
}
47154717
#endif /* HAVE_LIBREGEX */
4718+
4719+
/* NOT THREAD SAFE!
4720+
* Helpers to convert one IP address to string from different structure types
4721+
* Return pointer to internal buffer, or NULL and errno upon errors */
4722+
const char *inet_ntopSS(struct sockaddr_storage *s)
4723+
{
4724+
static char str[40];
4725+
4726+
if (!s) {
4727+
errno = EINVAL;
4728+
return NULL;
4729+
}
4730+
4731+
switch (s->ss_family)
4732+
{
4733+
case AF_INET:
4734+
return inet_ntop (AF_INET, &(((struct sockaddr_in *)s)->sin_addr), str, 16);
4735+
case AF_INET6:
4736+
return inet_ntop (AF_INET6, &(((struct sockaddr_in6 *)s)->sin6_addr), str, 40);
4737+
default:
4738+
errno = EAFNOSUPPORT;
4739+
return NULL;
4740+
}
4741+
}
4742+
4743+
const char *inet_ntopAI(struct addrinfo *ai)
4744+
{
4745+
/* Note: below we manipulate copies of ai - cannot cast into
4746+
* specific structure type pointers right away because:
4747+
* error: cast from 'struct sockaddr *' to 'struct sockaddr_storage *'
4748+
* increases required alignment from 2 to 8
4749+
*/
4750+
/* https://stackoverflow.com/a/29147085/4715872
4751+
* obviously INET6_ADDRSTRLEN is expected to be larger
4752+
* than INET_ADDRSTRLEN, but this may be required in case
4753+
* if for some unexpected reason IPv6 is not supported, and
4754+
* INET6_ADDRSTRLEN is defined as 0
4755+
* but this is not very likely and I am aware of no cases of
4756+
* this in practice (editor)
4757+
*/
4758+
static char addrstr[(INET6_ADDRSTRLEN > INET_ADDRSTRLEN ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN) + 1];
4759+
4760+
if (!ai || !ai->ai_addr) {
4761+
errno = EINVAL;
4762+
return NULL;
4763+
}
4764+
4765+
addrstr[0] = '\0';
4766+
switch (ai->ai_family) {
4767+
case AF_INET: {
4768+
struct sockaddr_in addr_in;
4769+
memcpy(&addr_in, ai->ai_addr, sizeof(addr_in));
4770+
return inet_ntop(AF_INET, &(addr_in.sin_addr), addrstr, INET_ADDRSTRLEN);
4771+
}
4772+
case AF_INET6: {
4773+
struct sockaddr_in6 addr_in6;
4774+
memcpy(&addr_in6, ai->ai_addr, sizeof(addr_in6));
4775+
return inet_ntop(AF_INET6, &(addr_in6.sin6_addr), addrstr, INET6_ADDRSTRLEN);
4776+
}
4777+
default:
4778+
errno = EAFNOSUPPORT;
4779+
return NULL;
4780+
}
4781+
}

configure.ac

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3463,9 +3463,6 @@ dnl is set to 'no', we may still want to build some doc targets manually
34633463
dnl (so enable the Makefile recipes for those targets if tools are available)
34643464
NUT_CHECK_ASCIIDOC
34653465

3466-
NUT_REPORT_FEATURE([requested to build and install documentation], [${nut_with_doc}], [],
3467-
[WITH_ASCIIDOC], [Define to enable Asciidoc support])
3468-
34693466
DOC_INSTALL_DISTED_MANS=no
34703467
KNOWN_UNABLE_MANS=no
34713468

@@ -3496,6 +3493,9 @@ dnl If user passed --with-doc='' they they want nothing, right?
34963493
;;
34973494
esac
34983495

3496+
NUT_REPORT_FEATURE([requested to build and install documentation], ['${nut_with_doc}' => '${nut_doc_build_list}'], [],
3497+
[WITH_ASCIIDOC], [Define to enable Asciidoc support], [-])
3498+
34993499
if test -z "${abs_srcdir}" ; then
35003500
case "${srcdir}" in
35013501
/*) abs_srcdir="${srcdir}";;
@@ -3574,7 +3574,7 @@ dnl not fail if we have no tools to generate it (so add to SKIP list).
35743574
AC_MSG_RESULT(no)
35753575
DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}"
35763576
if test "${nut_doc_build_target_flag}" = "yes" ; then
3577-
AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested])
3577+
AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested; will reflect on this below])
35783578
else
35793579
DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}"
35803580
fi
@@ -3597,7 +3597,7 @@ dnl not fail if we have no tools to generate it (so add to SKIP list).
35973597
AC_MSG_RESULT(no)
35983598
DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}"
35993599
if test "${nut_doc_build_target_flag}" = "yes" ; then
3600-
AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested])
3600+
AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested; will reflect on this below])
36013601
else
36023602
DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}"
36033603
fi
@@ -3623,7 +3623,7 @@ dnl not fail if we have no tools to generate it (so add to SKIP list).
36233623
AC_MSG_RESULT(no)
36243624
DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}"
36253625
if test "${nut_doc_build_target_flag}" = "yes" ; then
3626-
AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested])
3626+
AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested; will reflect on this below])
36273627
else
36283628
DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}"
36293629
fi
@@ -3660,7 +3660,7 @@ dnl not fail if we have no tools to generate it (so add to SKIP list).
36603660
DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}"
36613661
KNOWN_UNABLE_MANS=yes
36623662
if test "${nut_doc_build_target_flag}" = "yes" ; then
3663-
AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested])
3663+
AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested; will reflect on this below])
36643664
else
36653665
DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}"
36663666
if test "${nut_doc_build_target_flag}" = "auto" || test "${nut_doc_build_target_flag}" = "dist-auto" ; then
@@ -3684,28 +3684,30 @@ done
36843684
rm -rf "${DOCTESTDIR}"
36853685

36863686
AS_IF([test x"${nut_enable_configure_debug}" = xyes], [
3687-
AC_MSG_NOTICE([(CONFIGURE-DEVEL-DEBUG) DOC_BUILD_LIST: '${DOC_BUILD_LIST}'])
3688-
AC_MSG_NOTICE([(CONFIGURE-DEVEL-DEBUG) DOC_CANNOTBUILD_LIST: '${DOC_CANNOTBUILD_LIST}'])
3689-
AC_MSG_NOTICE([(CONFIGURE-DEVEL-DEBUG) DOC_SKIPBUILD_LIST: '${DOC_SKIPBUILD_LIST}'])
3687+
AC_MSG_NOTICE([(CONFIGURE-DEVEL-DEBUG) DOC_BUILD_LIST: '${DOC_BUILD_LIST}'])
3688+
AC_MSG_NOTICE([(CONFIGURE-DEVEL-DEBUG) DOC_CANNOTBUILD_LIST: '${DOC_CANNOTBUILD_LIST}'])
3689+
AC_MSG_NOTICE([(CONFIGURE-DEVEL-DEBUG) DOC_SKIPBUILD_LIST: '${DOC_SKIPBUILD_LIST}'])
36903690
])
36913691

36923692
case "${nut_with_doc}" in
36933693
auto)
36943694
if test -n "${DOC_BUILD_LIST}"; then
3695+
dnl # We can build at least one format...
36953696
nut_with_doc="yes"
36963697
else
3698+
dnl # We can not build any formats...
36973699
nut_with_doc="no"
36983700
fi
36993701
;;
37003702
no)
37013703
;;
3702-
*)
3704+
*) dnl # yes, all, skip...
37033705
if test -n "${DOC_CANNOTBUILD_LIST}"; then
37043706
DOC_CANNOTBUILD_LIST_LINES="`echo "${DOC_CANNOTBUILD_LIST}" | tr ' ' '\n' | grep -vE '^$'`"
3705-
for DOCTYPE in ${DOC_BUILD_LIST} ; do
3706-
if echo "${DOC_CANNOTBUILD_LIST_LINES}" | grep -E "^${DOCTYPE}(=yes)?\$" ; then
3707+
for DOCTYPE in ${nut_doc_build_list} ; do
3708+
if echo "${DOC_CANNOTBUILD_LIST_LINES}" | grep -E "^${DOCTYPE}(=yes)?\$" >/dev/null 2>/dev/null ; then
37073709
AC_MSG_ERROR([Unable to build${DOC_CANNOTBUILD_LIST} documentation (check for 'no' results above)])
3708-
else if echo "${DOC_CANNOTBUILD_LIST_LINES}" | grep -E "^${DOCTYPE}=(skip|auto|dist-auto)\$" ; then
3710+
else if echo "${DOC_CANNOTBUILD_LIST_LINES}" | grep -E "^${DOCTYPE}=(skip|auto|dist-auto)\$" >/dev/null 2>/dev/null ; then
37093711
AC_MSG_NOTICE([Unable to build${DOC_CANNOTBUILD_LIST} documentation (check for 'no' results above), skipping])
37103712
fi
37113713
fi
@@ -3727,7 +3729,7 @@ esac
37273729
AM_CONDITIONAL(WITH_PDF_NONASCII_TITLES, [test x"$can_build_doc_pdf_nonascii_titles" = xyes])
37283730

37293731
NUT_REPORT_FEATURE([would build specific documentation format(s)], [${nut_with_doc}], [${DOC_BUILD_LIST}],
3730-
[WITH_DOCS], [Define to enable overall documentation generation])
3732+
[WITH_DOCS], [Define to enable overall documentation generation], [-])
37313733

37323734
# To cater for less portable make's, precalculate the target list
37333735
# for "make check" in "docs/" here...

docs/daisychain.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ daisychain index. For example, if you have the following entry:
155155
{ "device.model", ST_FLAG_STRING, SU_INFOSIZE,
156156
".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0", ... },
157157
+
158-
And if the last "0" of the the 4th field represents the index of the device
158+
And if the last "0" of the 4th field represents the index of the device
159159
in the daisychain, then you would have to adapt it the following way:
160160
+
161161
{ "device.model", ST_FLAG_STRING, SU_INFOSIZE,

docs/man/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ SRC_SERIAL_PAGES = \
838838
tripplite.txt \
839839
tripplitesu.txt \
840840
upscode2.txt \
841+
ve-direct.txt \
841842
victronups.txt \
842843
apcupsd-ups.txt
843844

@@ -885,6 +886,7 @@ INST_MAN_SERIAL_PAGES = \
885886
tripplite.$(MAN_SECTION_CMD_SYS) \
886887
tripplitesu.$(MAN_SECTION_CMD_SYS) \
887888
upscode2.$(MAN_SECTION_CMD_SYS) \
889+
ve-direct.$(MAN_SECTION_CMD_SYS) \
888890
victronups.$(MAN_SECTION_CMD_SYS) \
889891
apcupsd-ups.$(MAN_SECTION_CMD_SYS)
890892

@@ -901,7 +903,6 @@ MAN_SERIAL_PAGES += \
901903
endif HAVE_LINUX_SERIAL_H
902904
endif WITH_MANS
903905

904-
905906
if WITH_SERIAL
906907
mansys_DATA += $(MAN_SERIAL_PAGES)
907908
endif WITH_SERIAL
@@ -951,6 +952,7 @@ INST_HTML_SERIAL_MANS = \
951952
tripplite.html \
952953
tripplitesu.html \
953954
upscode2.html \
955+
ve-direct.html \
954956
victronups.html \
955957
apcupsd-ups.html
956958

docs/man/ve-direct.txt

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
VE-DIRECT(8)
2+
============
3+
4+
NAME
5+
----
6+
7+
ve-direct - Driver for Victron UPS unit running on VE.Direct serial protocol
8+
9+
SYNOPSIS
10+
--------
11+
12+
*ve-direct* -h
13+
14+
*ve-direct* -a 'UPS_NAME' ['OPTIONS']
15+
16+
NOTE: This man page only documents the hardware-specific features of the
17+
*ve-direct* driver. For information about the core driver, see
18+
linkman:nutupsdrv[8].
19+
20+
SUPPORTED HARDWARE
21+
------------------
22+
23+
The ve-direct driver should recognize all Victron models that use a serial
24+
VE.Direct protocol at 19200 bps.
25+
26+
CABLING
27+
-------
28+
29+
Use Victron provided USB or serial cable to connect your Victron UPS.
30+
31+
EXTRA ARGUMENTS
32+
---------------
33+
34+
This driver supports the following optional setting in the
35+
linkman:ups.conf[5]:
36+
37+
*modelname*='name'::
38+
Set model name
39+
40+
BUGS
41+
----
42+
43+
The HEX protocol is not supported at the moment.
44+
45+
AUTHOR
46+
------
47+
48+
Petr Kubanek <[email protected]>
49+
50+
SEE ALSO
51+
--------
52+
53+
The core driver:
54+
~~~~~~~~~~~~~~~~
55+
56+
linkman:nutupsdrv[8]
57+
58+
Internet resources:
59+
~~~~~~~~~~~~~~~~~~~
60+
61+
The NUT (Network UPS Tools) home page: https://www.networkupstools.org/

docs/man/victronups.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ SYNOPSIS
1313

1414
*victronups* -a 'UPS_NAME' ['OPTIONS']
1515

16-
NOTE: This man page only documents the hardware-specific features of the the
17-
victronups driver. For information about the core driver, see
16+
NOTE: This man page only documents the hardware-specific features of the
17+
*victronups* driver. For information about the core driver, see
1818
linkman:nutupsdrv[8].
1919

2020
SUPPORTED HARDWARE

0 commit comments

Comments
 (0)