Skip to content

Commit

Permalink
Merge remote-tracking branch 'opensource/master' as of 2022-02-15 int…
Browse files Browse the repository at this point in the history
…o FTY
  • Loading branch information
jimklimov committed Feb 15, 2022
2 parents 4e5c8c0 + e121856 commit c4970c9
Show file tree
Hide file tree
Showing 146 changed files with 1,630 additions and 475 deletions.
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Also note below, a point about PR posting for NUT DDL
- [ ] Updated `docs/acknowledgements.txt` (for vendor-backed device support)

- [ ] Added or updated manual page information in `docs/man/*.txt` files
and corresponding recipe lists in `docs/man/Makefile.am` for new pages

- [ ] Passed `make spellcheck`, updated spell-checking dictionary in the
`docs/nut.dict` file if needed (did not remove any words -- the `make`
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ Release notes for NUT 2.7.5 - what's new since 2.7.4:
* add Arduino HID device support with new arduino-hid subdriver [PR #1044]
* add new salicru-hid subdriver, tested with Salicru SPS Home 850 VA
[PR #1199, issue #732]
* add new ever-hid subdriver to support EVER UPS devices (Sinline RT Series,
Sinline RT XL Series, ECO PRO AVR CDS Series) [PR #431]

- usbhid-ups / mge-shut: compute a realpower output load approximation for
Eaton UPS when the needed data is not present
Expand All @@ -174,6 +176,8 @@ Release notes for NUT 2.7.5 - what's new since 2.7.4:
for CyberPower, as well as shutdown and other instant commands
* several rounds of updates for Eaton devices, including new ATS and ePDU
hardware families
* fixed bit mask values for flags to surely use different numbers behind
logical items (inevitably changing some of those macro symbols) [PR #1180]

- snmp-ups and nut-scanner should now support more SNMPv3 Auth and Priv
protocols, as available at NUT build time [PRs #1165, #1172]
Expand Down
13 changes: 13 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ check this file to see if you need to make changes to your system.
Changes from 2.7.4 to 2.7.5
---------------------------

- Note to distribution packagers: this version hopefully learns from many
past mistakes, so many custom patches may be no longer needed. If some
remain, please consider making pull requests for upstream NUT codebase
to share the fixes consistently across the ecosystem. Also note that
some new types of drivers (so package groups with unique dependencies)
could have appeared since your packaging was written (e.g. with modbus).

- Due to changes needed to resolve build warnings, mostly about mismatching
data types for some variables, some structure definitions and API signatures
of several routines had to be changed for argument types, return types,
Expand Down Expand Up @@ -62,6 +69,12 @@ Changes from 2.7.4 to 2.7.5
preference of the detected script over `pkg-config` information, if both
are available, and `--with-netsnmp-config=/path/name` would as well.

- snmp-ups: bit mask values for flags in earlier codebase were defined in a
way that caused logically different items to have same numeric values.
This was fixed to surely use different definitions (so changing numbers
behind some of those macro symbols), and testing with UPS, ePDU and ATS
hardware which was available did not expose any practical differences.

- usbhid-ups: numeric data conversion from wire protocol to CPU representation
in GetValue() was completely reworked, aiming to be correct on all CPU types.
That said, regressions are possible and feedback is welcome.
Expand Down
8 changes: 8 additions & 0 deletions ci_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,10 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp
RES_ALLERRORS=$?
FAILED="${FAILED} NUT_SSL_VARIANT=${NUT_SSL_VARIANT}[configure]"
# TOTHINK: Do we want to try clean-up if we likely have no Makefile?
if [ "$CI_FAILFAST" = true ]; then
echo "===== Aborting because CI_FAILFAST=$CI_FAILFAST" >&2
break
fi
BUILDSTODO="`expr $BUILDSTODO - 1`" || [ "$BUILDSTODO" = "0" ] || break
continue
}
Expand Down Expand Up @@ -1260,6 +1264,10 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp
RES_ALLERRORS=$?
FAILED="${FAILED} NUT_USB_VARIANT=${NUT_USB_VARIANT}[configure]"
# TOTHINK: Do we want to try clean-up if we likely have no Makefile?
if [ "$CI_FAILFAST" = true ]; then
echo "===== Aborting because CI_FAILFAST=$CI_FAILFAST" >&2
break
fi
BUILDSTODO="`expr $BUILDSTODO - 1`" || [ "$BUILDSTODO" = "0" ] || break
continue
}
Expand Down
4 changes: 2 additions & 2 deletions clients/upsclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -1424,8 +1424,8 @@ int upscli_list_next(UPSCONN_t *ups, size_t numq, const char **query,

/* see if this is the end */
if (ups->pc_ctx.numargs >= 2) {
if ((!strncmp(ups->pc_ctx.arglist[0], "END", 3)) &&
(!strncmp(ups->pc_ctx.arglist[1], "LIST", 4)))
if ((!strcmp(ups->pc_ctx.arglist[0], "END")) &&
(!strcmp(ups->pc_ctx.arglist[1], "LIST")))
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion clients/upslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ int main(int argc, char **argv)
fprintf(stderr, "Warning: initial connect failed: %s\n",
upscli_strerror(&ups));

if (strncmp(logfn, "-", 1) == 0)
if (strcmp(logfn, "-") == 0)
logfile = stdout;
else
logfile = fopen(logfn, "a");
Expand Down
12 changes: 6 additions & 6 deletions clients/upsmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1619,19 +1619,19 @@ static void parse_status(utype_t *ups, char *status)

upsdebugx(3, "parsing: [%s]", statword);

if (!strncasecmp(statword, "OL", 2))
if (!strcasecmp(statword, "OL"))
ups_on_line(ups);
if (!strncasecmp(statword, "OB", 2))
if (!strcasecmp(statword, "OB"))
ups_on_batt(ups);
if (!strncasecmp(statword, "LB", 2))
if (!strcasecmp(statword, "LB"))
ups_low_batt(ups);
if (!strncasecmp(statword, "RB", 2))
if (!strcasecmp(statword, "RB"))
upsreplbatt(ups);
if (!strncasecmp(statword, "CAL", 3))
if (!strcasecmp(statword, "CAL"))
ups_cal(ups);

/* do it last to override any possible OL */
if (!strncasecmp(statword, "FSD", 3))
if (!strcasecmp(statword, "FSD"))
ups_fsd(ups);

update_crittimer(ups);
Expand Down
2 changes: 1 addition & 1 deletion clients/upsrw.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ static void do_type(const char *varname)
}

/* ignore this one */
if (!strncasecmp(answer[i], "RW", 2)) {
if (!strcasecmp(answer[i], "RW")) {
continue;
}

Expand Down
91 changes: 46 additions & 45 deletions clients/upssched.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,19 @@ static int sock_read(conn_t *conn)
if ((ret == -1) && (errno == EAGAIN))
return 0;

/* O_NDELAY with zero bytes means nothing to read but
* since read() follows a succesful select() with
* ready file descriptor, ret shouldn't be 0. */
if (ret == 0)
continue;

/* some other problem */
return -1; /* error */
}

ret = pconf_char(&conn->ctx, ch);

if (ret == 0) /* nothing to parse yet */
if (ret == 0) /* nothing to parse yet */
continue;

if (ret == -1) {
Expand Down Expand Up @@ -691,32 +697,15 @@ static int check_parent(const char *cmd, const char *arg2)
exit(EXIT_FAILURE);
}

static void read_timeout(int sig)
{
NUT_UNUSED_VARIABLE(sig);

/* ignore this */
return;
}

static void setup_sigalrm(void)
{
struct sigaction sa;
sigset_t nut_upssched_sigmask;

sigemptyset(&nut_upssched_sigmask);
sa.sa_mask = nut_upssched_sigmask;
sa.sa_flags = 0;
sa.sa_handler = read_timeout;
sigaction(SIGALRM, &sa, NULL);
}

static void sendcmd(const char *cmd, const char *arg1, const char *arg2)
{
int i, pipefd;
ssize_t ret;
size_t enclen;
char buf[SMALLBUF], enc[SMALLBUF + 8];
size_t enclen, buflen;
char buf[SMALLBUF], enc[SMALLBUF + 8];
int ret_s;
struct timeval tv;
fd_set fdread;

/* insanity */
if (!arg1)
Expand All @@ -732,8 +721,10 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2)

snprintf(enc, sizeof(enc), "%s\n", buf);

enclen = strlen(buf);
if (enclen >= SSIZE_MAX) {
/* Sanity checks, for static analyzers to sleep well */
enclen = strlen(enc);
buflen = strlen(buf);
if (enclen >= SSIZE_MAX || buflen >= SSIZE_MAX) {
/* Can't compare enclen to ret below */
fatalx(EXIT_FAILURE, "Unable to connect to daemon: buffered message too large");
}
Expand All @@ -745,7 +736,6 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2)
pipefd = check_parent(cmd, arg2);

if (pipefd == PARENT_STARTED) {

/* loop back and try to connect now */
usleep(250000);
continue;
Expand All @@ -760,27 +750,38 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2)
ret = write(pipefd, enc, enclen);

/* if we can't send the whole thing, loop back and try again */
if ((ret < 1) || (ret != (ssize_t) enclen)) {
if ((ret < 1) || (ret != (ssize_t)enclen)) {
upslogx(LOG_ERR, "write failed, trying again");
close(pipefd);
continue;
}

/* ugh - probably should use select here... */
setup_sigalrm();

alarm(2);
ret = read(pipefd, buf, sizeof(buf));
alarm(0);

#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wstrict-prototypes"
#endif
signal(SIGALRM, SIG_IGN);
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES)
# pragma GCC diagnostic pop
#endif
/* select on child's pipe fd */
do {
/* set timeout every time before call select() */
tv.tv_sec = 1;
tv.tv_usec = 0;

FD_ZERO(&fdread);
FD_SET(pipefd, &fdread);

ret_s = select(pipefd + 1, &fdread, NULL, NULL, &tv);
switch(ret_s) {
/* select error */
case -1:
upslogx(LOG_DEBUG, "parent select error: %s", strerror(errno));
break;

/* nothing to read */
case 0:
break;

/* available data to read */
default:
ret = read(pipefd, buf, sizeof(buf));
break;
}
} while (ret_s <= 0);

close(pipefd);

Expand All @@ -796,7 +797,7 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2)
upslogx(LOG_ERR, "read confirmation got [%s]", buf);

/* try again ... */
}
} /* loop until MAX_TRIES if no success above */

fatalx(EXIT_FAILURE, "Unable to connect to daemon and unable to start daemon");
}
Expand All @@ -823,7 +824,7 @@ static void parse_at(const char *ntype, const char *un, const char *cmd,

/* check upsname: does this apply to us? */
if (strcmp(upsname, un) != 0)
if (strncmp(un, "*", 1) != 0)
if (strcmp(un, "*") != 0)
return; /* not for us, and not the wildcard */

/* see if the current notify type matches the one from the .conf */
Expand Down Expand Up @@ -885,7 +886,7 @@ static int conf_arg(size_t numargs, char **arg)
return 0;

/* AT <notifytype> <upsname> <command> <cmdarg1> [<cmdarg2>] */
if (!strncmp(arg[0], "AT", 2)) {
if (!strcmp(arg[0], "AT")) {

/* don't use arg[5] unless we have it... */
if (numargs > 5)
Expand Down
2 changes: 1 addition & 1 deletion clients/upsset.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ static void do_type(const char *varname)
}

/* ignore this one */
if (!strncasecmp(answer[i], "RW", 2))
if (!strcasecmp(answer[i], "RW"))
continue;

printf("Unrecognized\n");
Expand Down
2 changes: 1 addition & 1 deletion common/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ void state_setflags(st_tree_t *root, const char *var, size_t numflags, char **fl

for (i = 0; i < numflags; i++) {

if (!strncasecmp(flag[i], "RW", 2)) {
if (!strcasecmp(flag[i], "RW")) {
sttmp->flags |= ST_FLAG_RW;
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion common/upsconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void conf_args(size_t numargs, char **arg)
return;

/* handle 'foo = bar', 'foo=bar', 'foo =bar' or 'foo= bar' forms */
if (!strncmp(arg[1], "=", 1)) {
if (!strcmp(arg[1], "=")) {
do_upsconf_args(ups_section, arg[0], arg[2]);
return;
}
Expand Down
Loading

0 comments on commit c4970c9

Please sign in to comment.