Skip to content

Commit 026118e

Browse files
authored
Merge a35a999 into 6c63f77
2 parents 6c63f77 + a35a999 commit 026118e

19 files changed

Lines changed: 230 additions & 120 deletions

Jenkinsfile-dynamatrix

Lines changed: 78 additions & 48 deletions
Large diffs are not rendered by default.

ci_build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,6 +2061,8 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-al
20612061
20622062
# Use "distcheck-ci" if caller did not ask for any DISTCHECK_TGT
20632063
# value, and we defaulted to strict "distcheck" above
2064+
# Check the actual logic below though, currently these sub-matrix
2065+
# builds do not call distcheck (they can however do a parallel-check)
20642066
( [ -n "${ORIG_DISTCHECK_TGT}" ] || [ x"${DISTCHECK_TGT}" != x"distcheck" ] ) || DISTCHECK_TGT="distcheck-ci"
20652067
20662068
if [ "${CANBUILD_LIBGD_CGI-}" != "no" ] && [ "${BUILD_LIBGD_CGI-}" != "auto" ] ; then

clients/authconf.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ static int parse_authconf_file(const char *filename, int fatal_errors, int globa
991991
return 1;
992992
}
993993

994-
int upscli_read_authconf_file(const char *filename, int fatal_errors)
994+
int upscli_read_authconf_file(const char *filename, int fatal_errors, int debug_level)
995995
{
996996
char fn[NUT_PATH_MAX + 1];
997997

@@ -1064,7 +1064,11 @@ int upscli_read_authconf_file(const char *filename, int fatal_errors)
10641064
if (fatal_errors) {
10651065
fatalx(EXIT_FAILURE, "Can't open a user/site-provided default nutauth.conf file");
10661066
} else {
1067-
upslogx(LOG_WARNING, "Can't open a user/site-provided default nutauth.conf file");
1067+
if (debug_level < 0) {
1068+
upslogx(LOG_WARNING, "Can't open a user/site-provided default nutauth.conf file");
1069+
} else {
1070+
upsdebugx(debug_level, "Can't open a user/site-provided default nutauth.conf file");
1071+
}
10681072
return -1;
10691073
}
10701074
}

clients/authconf.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ void upscli_free_authconf_list(void);
5757
* If filename==NULL, tries to locate per-user ${HOME}/.config/nut/nutauth.conf
5858
* and ${HOME}/.nutauth.conf, or site default ${nutconfdir}/nutauth.conf
5959
* (whichever is found first); then one can follow `INCLUDE` trail if needed.
60-
* Returns -1 on error, 1 on success
60+
* Ultimate error, if file was not found, is posted at specified debug_level>=0
61+
* or logged as LOG_WARNING if negative.
62+
* Returns -1 on error, 1 on success.
6163
*/
62-
int upscli_read_authconf_file(const char *filename, int fatal_errors);
64+
int upscli_read_authconf_file(const char *filename, int fatal_errors, int debug_level);
6365

6466
/** All p_* args must be non-NULL pointers to `char *` string variables
6567
* which may be freed and re-allocated to return normalized values

clients/upsc.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -515,18 +515,18 @@ int main(int argc, char **argv)
515515
int parsed = -1;
516516
if (!strcmp(nutauth, "default")) {
517517
upsdebugx(1, "Using nutauth='%s': require a user or system provided file", nutauth);
518-
parsed = upscli_read_authconf_file(NULL, 0);
518+
parsed = upscli_read_authconf_file(NULL, 0, -1);
519519
} else {
520520
upsdebugx(1, "Using nutauth='%s': require this file", nutauth);
521-
parsed = upscli_read_authconf_file(nutauth, 0);
521+
parsed = upscli_read_authconf_file(nutauth, 0, -1);
522522
}
523523
if (parsed < 0) {
524524
fatalx_error_json_simple(0, "Failed to parse auth config file");
525525
}
526526
}
527527
} else {
528528
upsdebugx(1, "Using best-effort auth config detection");
529-
upscli_read_authconf_file(NULL, 0);
529+
upscli_read_authconf_file(NULL, 0, 1);
530530
}
531531

532532
if (upscli_init_default_connect_timeout(net_connect_timeout, NULL, UPSCLI_DEFAULT_CONNECT_TIMEOUT) < 0) {
@@ -557,9 +557,12 @@ int main(int argc, char **argv)
557557
NUT_STRARG(upsname), NUT_STRARG(hostname), port);
558558

559559
ac_conn = upscli_get_authconf_item(NULL, hostname, snprintf(str_port, sizeof(str_port), "%" PRIu16, port) > 0 ? str_port : NULL, 1);
560-
if (ac_conn && upscli_init_authconf(ac_conn) > 0) {
561-
upscli_authconf_t *ac_default = upscli_find_authconf_item(NULL, NULL, NULL);
562-
upscli_authconf_update_conn_flags(ac_default, &flags_ssl);
560+
if (ac_conn) {
561+
if (upscli_init_authconf(ac_conn) > 0) {
562+
upscli_authconf_t *ac_default = upscli_find_authconf_item(NULL, NULL, NULL);
563+
upscli_authconf_update_conn_flags(ac_default, &flags_ssl);
564+
}
565+
upscli_authconf_update_conn_flags(ac_conn, &flags_ssl);
563566
}
564567

565568
ups = (UPSCONN_t *)xmalloc(sizeof(*ups));

clients/upsclient.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,9 +1017,11 @@ int upscli_init2(int certverify, const char *certpath,
10171017

10181018
#if defined(WITH_OPENSSL) || defined(WITH_NSS)
10191019
if (certname) {
1020+
free(sslcertname);
10201021
sslcertname = xstrdup(certname);
10211022
}
10221023
if (certpasswd) {
1024+
free(sslcertpasswd);
10231025
sslcertpasswd = xstrdup(certpasswd);
10241026
}
10251027
#else /* neither backend: */

clients/upscmd.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,15 +435,15 @@ int main(int argc, char **argv)
435435
} else {
436436
if (!strcmp(nutauth, "default")) {
437437
upsdebugx(1, "Using nutauth='%s': require a user or system provided file", nutauth);
438-
upscli_read_authconf_file(NULL, 1);
438+
upscli_read_authconf_file(NULL, 1, -1);
439439
} else {
440440
upsdebugx(1, "Using nutauth='%s': require this file", nutauth);
441-
upscli_read_authconf_file(nutauth, 1);
441+
upscli_read_authconf_file(nutauth, 1, -1);
442442
}
443443
}
444444
} else {
445445
upsdebugx(1, "Using best-effort auth config detection");
446-
upscli_read_authconf_file(NULL, 0);
446+
upscli_read_authconf_file(NULL, 0, 1);
447447
}
448448

449449
if (upscli_init_default_connect_timeout(net_connect_timeout, NULL, UPSCLI_DEFAULT_CONNECT_TIMEOUT) < 0) {
@@ -470,9 +470,12 @@ int main(int argc, char **argv)
470470
setproctag(argv[0]); /* ups[@host[:port]] */
471471

472472
ac_conn = upscli_get_authconf_item(NULL, hostname, snprintf(str_port, sizeof(str_port), "%" PRIu16, port) > 0 ? str_port : NULL, 1);
473-
if (ac_conn && upscli_init_authconf(ac_conn) > 0) {
474-
upscli_authconf_t *ac_default = upscli_find_authconf_item(NULL, NULL, NULL);
475-
upscli_authconf_update_conn_flags(ac_default, &flags_ssl);
473+
if (ac_conn) {
474+
if (upscli_init_authconf(ac_conn) > 0) {
475+
upscli_authconf_t *ac_default = upscli_find_authconf_item(NULL, NULL, NULL);
476+
upscli_authconf_update_conn_flags(ac_default, &flags_ssl);
477+
}
478+
upscli_authconf_update_conn_flags(ac_conn, &flags_ssl);
476479
}
477480

478481
ups = (UPSCONN_t *)xcalloc(1, sizeof(*ups));

clients/upsimage.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,15 +725,18 @@ int main(int argc, char **argv)
725725
extractcgiargs();
726726

727727
upsdebugx(1, "Using best-effort auth config detection");
728-
upscli_read_authconf_file(NULL, 0);
728+
upscli_read_authconf_file(NULL, 0, 1);
729729

730730
upscli_init_default_connect_timeout(NULL, NULL, UPSCLI_DEFAULT_CONNECT_TIMEOUT);
731731
atexit(clean_exit);
732732

733733
ac_conn = upscli_get_authconf_item(NULL, hostname, snprintf(str_port, sizeof(str_port), "%" PRIu16, port) > 0 ? str_port : NULL, 1);
734-
if (ac_conn && upscli_init_authconf(ac_conn) > 0) {
735-
upscli_authconf_t *ac_default = upscli_find_authconf_item(NULL, NULL, NULL);
736-
upscli_authconf_update_conn_flags(ac_default, &flags_ssl);
734+
if (ac_conn) {
735+
if (upscli_init_authconf(ac_conn) > 0) {
736+
upscli_authconf_t *ac_default = upscli_find_authconf_item(NULL, NULL, NULL);
737+
upscli_authconf_update_conn_flags(ac_default, &flags_ssl);
738+
}
739+
upscli_authconf_update_conn_flags(ac_conn, &flags_ssl);
737740
}
738741

739742
/* no 'host=' or 'display=' given */

clients/upslog.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ int main(int argc, char **argv)
531531
const char *user = NULL;
532532
char *nutauth = NULL, str_port[16];
533533
upscli_authconf_t *ac_default = NULL;
534-
int flags_ssl = UPSCLI_CONN_TRYSSL;
534+
int flags_ssl = UPSCLI_CONN_TRYSSL, flags_ssl_default = UPSCLI_CONN_TRYSSL;
535535
struct passwd *new_uid = NULL;
536536
const char *pidfilebase = prog;
537537
/* For legacy single-ups -s/-l args: */
@@ -723,15 +723,15 @@ int main(int argc, char **argv)
723723
} else {
724724
if (!strcmp(nutauth, "default")) {
725725
upsdebugx(1, "Using nutauth='%s': require a user or system provided file", nutauth);
726-
upscli_read_authconf_file(NULL, 1);
726+
upscli_read_authconf_file(NULL, 1, -1);
727727
} else {
728728
upsdebugx(1, "Using nutauth='%s': require this file", nutauth);
729-
upscli_read_authconf_file(nutauth, 1);
729+
upscli_read_authconf_file(nutauth, 1, -1);
730730
}
731731
}
732732
} else {
733733
upsdebugx(1, "Using best-effort auth config detection");
734-
upscli_read_authconf_file(NULL, 0);
734+
upscli_read_authconf_file(NULL, 0, 1);
735735
}
736736

737737
if (upscli_init_default_connect_timeout(net_connect_timeout, NULL, UPSCLI_DEFAULT_CONNECT_TIMEOUT) < 0) {
@@ -854,12 +854,14 @@ int main(int argc, char **argv)
854854
/* Always call this, to register possible CERTHOSTs etc. */
855855
if (upscli_init_authconf(ac_current) > 0) {
856856
if (ac_default) {
857-
upscli_authconf_update_conn_flags(ac_default, &flags_ssl);
857+
upscli_authconf_update_conn_flags(ac_default, &flags_ssl_default);
858858

859859
// Do not call on the next loop cycle, if any
860860
ac_default = NULL;
861861
}
862862
}
863+
flags_ssl = flags_ssl_default;
864+
upscli_authconf_update_conn_flags(ac_current, &flags_ssl);
863865

864866
/* Revise the list if some UPS name was an asterisk
865867
* (query the data server) */

clients/upsrw.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -735,15 +735,15 @@ int main(int argc, char **argv)
735735
} else {
736736
if (!strcmp(nutauth, "default")) {
737737
upsdebugx(1, "Using nutauth='%s': require a user or system provided file", nutauth);
738-
upscli_read_authconf_file(NULL, 1);
738+
upscli_read_authconf_file(NULL, 1, -1);
739739
} else {
740740
upsdebugx(1, "Using nutauth='%s': require this file", nutauth);
741-
upscli_read_authconf_file(nutauth, 1);
741+
upscli_read_authconf_file(nutauth, 1, -1);
742742
}
743743
}
744744
} else {
745745
upsdebugx(1, "Using best-effort auth config detection");
746-
upscli_read_authconf_file(NULL, 0);
746+
upscli_read_authconf_file(NULL, 0, 1);
747747
}
748748

749749
if (upscli_init_default_connect_timeout(net_connect_timeout, NULL, UPSCLI_DEFAULT_CONNECT_TIMEOUT) < 0) {
@@ -770,9 +770,12 @@ int main(int argc, char **argv)
770770
setproctag(argv[0]); /* ups[@host[:port]] */
771771

772772
ac_conn = upscli_get_authconf_item(NULL, hostname, snprintf(str_port, sizeof(str_port), "%" PRIu16, port) > 0 ? str_port : NULL, 1);
773-
if (ac_conn && upscli_init_authconf(ac_conn) > 0) {
774-
upscli_authconf_t *ac_default = upscli_find_authconf_item(NULL, NULL, NULL);
775-
upscli_authconf_update_conn_flags(ac_default, &flags_ssl);
773+
if (ac_conn) {
774+
if (upscli_init_authconf(ac_conn) > 0) {
775+
upscli_authconf_t *ac_default = upscli_find_authconf_item(NULL, NULL, NULL);
776+
upscli_authconf_update_conn_flags(ac_default, &flags_ssl);
777+
}
778+
upscli_authconf_update_conn_flags(ac_conn, &flags_ssl);
776779
}
777780

778781
ups = (UPSCONN_t *)xcalloc(1, sizeof(*ups));

0 commit comments

Comments
 (0)