Skip to content

Commit 47c3b5d

Browse files
authored
Merge 0f03f63 into b0b3898
2 parents b0b3898 + 0f03f63 commit 47c3b5d

40 files changed

+1094
-146
lines changed

NEWS.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ https://github.com/networkupstools/nut/milestone/12
104104
characters. Now it is evaluated at `configure` time (to check that the
105105
characters may be used), and if not -- during `nut_stdint.h` parsing to
106106
fit known `int`/`long`/`long long` types. [#3300]
107+
* Added new API methods and defined bitmap values for `libupsclient`
108+
C binding to query and report SSL capabilities of the current library
109+
build (none, OpenSSL, Mozilla NSS): `upscli_ssl_caps_descr()` and
110+
`upscli_ssl_caps()`. Updated common NUT clients to report this info
111+
in their detailed help banners. Done similarly for `upsd`. The NIT
112+
(NUT Integration Test) suite piggy-backs on this to add run-time
113+
dependent tests of SSL capability. Added `upscli_set_debug_level()`
114+
and `upscli_set_debug_level()` methods to facilitate NUT debugging
115+
for clients built with shared NUT private libraries. [issues #3328,
116+
#1771, #2800, PR #3330]
107117

108118
- NUT for Windows specific updates:
109119
* Revised detection of (relative) paths to program and configuration files
@@ -302,6 +312,11 @@ https://github.com/networkupstools/nut/milestone/12
302312
or Windows `HANDLE`'s at a time, and moving on to another chunk.
303313
The system-provided value can be further limited by `NUT_SYSMAXCONN_LIMIT`
304314
environment variable (e.g. in tests). [#3302]
315+
* Extended processing of `CERTREQUEST` setting to handle numeric or specific
316+
string values, to match both ways of reading ambiguous documentation.
317+
Added `configure --with-ssl-client-validation` toggle to expose the
318+
macro previously meant to be passed via `make` command line. [PR #3330,
319+
but beware issue #3329]
305320

306321
- `upsdrvctl` tool updates:
307322
* Make use of `setproctag()` and `getproctag()` to report parent/child

UPGRADING.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Changes from 2.8.4 to 2.8.5
3535
library files to deliver with the packages (formally versioned and
3636
named by NUT release semantic version triplet). [issue #2800]
3737
38+
- Related to the above, `libupsclient` will remove the exported symbol for
39+
`nut_debug_level` variable in a later NUT release, and now introduces the
40+
`upscli_set_debug_level()` and `upscli_get_debug_level()` methods. [PR #3330]
41+
3842
- For ages, most recipes for building NUT had customized the `sysconfdir` to
3943
be `/etc/nut`, which is not exactly the *system* configuration directory.
4044
This is finally deprecated, with new `--with-confdir` configuration option
@@ -99,6 +103,10 @@ Changes from 2.8.4 to 2.8.5
99103
use `upsdrvquery_NOSIGPIPE=0` to disable neutering of the signal inside
100104
the API itself. [PR #3277]
101105
106+
- Added new API methods and defined bitmap values for `libupsclient` C binding
107+
to query and report SSL capabilities of the library build (none, OpenSSL,
108+
Mozilla NSS): `upscli_ssl_caps_descr()` and `upscli_ssl_caps()`. [PR #33xx]
109+
102110
- Fixed man page naming for `nutdrv_siemens-sitop(.8)` (dash vs. underscore)
103111
to match the driver program name. Packaging recipes may have to be updated.
104112
Follow-up from slightly botched renaming in original contribution. [PR #545]

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ install:
6363
# versions of packages.
6464
- cmd: |
6565
REM Prerequisites for NUT per https://github.com/networkupstools/nut/blob/master/docs/config-prereqs.txt :
66-
C:\msys64\usr\bin\bash -lc "date -u; pacman --noconfirm -S --needed base-devel mingw-w64-x86_64-toolchain autoconf-wrapper automake-wrapper libtool mingw-w64-x86_64-libltdl gcc ccache mingw-w64-x86_64-ccache git aspell aspell-en python mingw-w64-x86_64-python-pygments mingw-w64-x86_64-winpthreads-git mingw-w64-x86_64-libusb mingw-w64-x86_64-libusb-compat-git mingw-w64-x86_64-neon libneon-devel mingw-w64-x86_64-libgd mingw-w64-x86_64-cppunit"
66+
C:\msys64\usr\bin\bash -lc "date -u; pacman --noconfirm -S --needed base-devel mingw-w64-x86_64-toolchain autoconf-wrapper automake-wrapper libtool mingw-w64-x86_64-libltdl gcc ccache mingw-w64-x86_64-ccache git aspell aspell-en python mingw-w64-x86_64-python-pygments mingw-w64-x86_64-winpthreads-git mingw-w64-x86_64-libusb mingw-w64-x86_64-libusb-compat-git mingw-w64-x86_64-neon libneon-devel mingw-w64-x86_64-libgd mingw-w64-x86_64-cppunit mingw-w64-x86_64-nss mingw-w64-x86_64-openssl"
6767
REM SKIP mingw-w64-x86_64-libmodbus-git : we custom-build one with USB support
6868
REM SKIP for now NUT-Monitor prereqs (runtime Python would require somilar modules; need to fix localization builds like "fr.po"): gettext mingw-w64-x86_64-python-pyqt6
6969

clients/Makefile.am

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,13 @@ upsstats_cgi_LDADD = $(LDADD_CLIENT) $(top_builddir)/common/libcommonstrjson.la
166166
# not LDADD... why?
167167
libupsclient_la_SOURCES = upsclient.c upsclient.h
168168
# NOTE: The library does not require libcommonversion.la
169+
if ENABLE_SHARED_PRIVATE_LIBS
170+
libupsclient_la_LIBADD = \
171+
$(top_builddir)/common/libnutprivate-@NUT_SOURCE_GITREV_SEMVER_UNDERSCORES@-common-client.la
172+
else !ENABLE_SHARED_PRIVATE_LIBS
169173
libupsclient_la_LIBADD = \
170174
$(top_builddir)/common/libcommonclient.la
175+
endif !ENABLE_SHARED_PRIVATE_LIBS
171176
if HAVE_WINDOWS_SOCKETS
172177
libupsclient_la_LIBADD += -lws2_32
173178
endif HAVE_WINDOWS_SOCKETS
@@ -181,6 +186,15 @@ endif WITH_SSL
181186
# object .so names would differ)
182187

183188
# libupsclient version information
189+
# NOTE: with libnutprivate*common* builds dynamically linked into the same
190+
# program (a typical in-tree NUT client, not typical for out-of-tree third
191+
# party clients) we can end up with two copies of libcommon symbols present
192+
# in each library. It's recommended to explicitly call upscli_set_debug_level()
193+
# instead of ambiguously manipulating the nut_debug_level variable by name.
194+
# TOTHINK: Un-export nut_debug_level from this library to avoid ambiguity
195+
# for the run-time dynamic linker resolution? For now the shared-library
196+
# builds are "exotic", but it makes sense to deprecate this export in a
197+
# future release.
184198
libupsclient_la_LDFLAGS = -version-info 7:0:0
185199
libupsclient_la_LDFLAGS += -export-symbols-regex '^(upscli_|nut_debug_level)'
186200
#|s_upsdebug|fatalx|fatal_with_errno|xcalloc|xbasename|print_banner_once)'

clients/upsc.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Copyright (C) 1999 Russell Kroll <rkroll@exploits.org>
44
Copyright (C) 2012 Arnaud Quette <arnaud.quette@free.fr>
5-
Copyright (C) 2020-2025 Jim Klimov <jimklimov+nut@gmail.com>
5+
Copyright (C) 2020-2026 Jim Klimov <jimklimov+nut@gmail.com>
66
77
This program is free software; you can redistribute it and/or modify
88
it under the terms of the GNU General Public License as published by
@@ -48,14 +48,14 @@ static void fatalx_error_json_simple(int msg_is_simple, const char *msg) {
4848
if (output_json) {
4949
if (msg_is_simple) {
5050
/* Caller knows there is nothing to escape here, pass through */
51-
printf("{\"error\": \"%s\"}\n", msg);
51+
printf("{\"error\": \"%s\"}\n", NUT_STRARG(msg));
5252
} else {
5353
printf("{\"error\": \"");
5454
json_print_esc(msg);
5555
printf("\"}\n");
5656
}
5757
}
58-
fatalx(EXIT_FAILURE, "Error: %s", msg);
58+
fatalx(EXIT_FAILURE, "Error: %s", NUT_STRARG(msg));
5959
}
6060

6161
static void usage(const char *prog)
@@ -91,6 +91,7 @@ static void usage(const char *prog)
9191
printf(" -h - display this help text\n");
9292

9393
nut_report_config_flags();
94+
upscli_report_build_details();
9495

9596
printf("\n%s", suggest_doc_links(prog, NULL));
9697
}
@@ -168,6 +169,8 @@ static void list_vars(void)
168169
int msg_is_simple = 1;
169170

170171
/* check for an old upsd */
172+
upsdebugx(1, "%s: got code %d, upserror %d",
173+
__func__, ret, upscli_upserror(ups));
171174
if (upscli_upserror(ups) == UPSCLI_ERR_UNKCOMMAND) {
172175
msg = "upsd is too old to support this query";
173176
} else {
@@ -177,14 +180,14 @@ static void list_vars(void)
177180

178181
if (output_json) {
179182
if (msg_is_simple) {
180-
printf(" \"error\": \"%s\"\n}\n", msg);
183+
printf(" \"error\": \"%s\"\n}\n", NUT_STRARG(msg));
181184
} else {
182185
printf(" \"error\": \"");
183186
json_print_esc(msg);
184187
printf("\"\n}\n");
185188
}
186189
}
187-
fatalx(EXIT_FAILURE, "Error: %s", msg);
190+
fatalx(EXIT_FAILURE, "Error: %s", NUT_STRARG(msg));
188191
}
189192

190193
while (upscli_list_next(ups, numq, query, &numa, &answer) == 1) {
@@ -237,6 +240,8 @@ static void list_upses(int verbose)
237240
int msg_is_simple = 1;
238241

239242
/* check for an old upsd */
243+
upsdebugx(1, "%s: got code %d, upserror %d",
244+
__func__, ret, upscli_upserror(ups));
240245
if (upscli_upserror(ups) == UPSCLI_ERR_UNKCOMMAND) {
241246
msg = "upsd is too old to support this query";
242247
} else {
@@ -394,6 +399,7 @@ int main(int argc, char **argv)
394399
s = getenv("NUT_DEBUG_LEVEL");
395400
if (s && str_to_int(s, &i, 10) && i > 0) {
396401
nut_debug_level = i;
402+
upscli_set_debug_level(nut_debug_level);
397403
}
398404
upsdebugx(1, "Starting NUT client: %s", prog);
399405

0 commit comments

Comments
 (0)