Skip to content

Commit

Permalink
server/netget.c: get_var_server(): refer to PACKAGE_URL (and hard-cod…
Browse files Browse the repository at this point in the history
…ed "https://www.networkupstools.org/" if PACKAGE_URL points completely elsewhere) [networkupstools#1949]

Tested with "GET VAR dummy server.info" command

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 30, 2024
1 parent 9beb897 commit 7e714ee
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions server/netget.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,37 @@ static void get_type(nut_ctype_t *client, const char *upsname, const char *var)

static void get_var_server(nut_ctype_t *client, const char *upsname, const char *var)
{
int pkgurlHasNutOrg = PACKAGE_URL ? (strstr(PACKAGE_URL, "networkupstools.org") != NULL) : 0;

if (!strcasecmp(var, "server.info")) {
#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
#pragma GCC diagnostic push
#endif
#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
#pragma GCC diagnostic ignored "-Wunreachable-code"
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code"
#endif
/* NOTE: Some compilers deduce that macro-based decisions about
* NUT_VERSION_IS_RELEASE make one of codepaths unreachable in
* a particular build. So we pragmatically handwave this away.
*/
sendback(client, "VAR %s server.info "
"\"Network UPS Tools upsd %s - "
"https://www.networkupstools.org/\"\n",
upsname, UPS_VERSION);
"%s%s%s\"\n",
upsname, UPS_VERSION,
PACKAGE_URL ? PACKAGE_URL : "",
(PACKAGE_URL && !pkgurlHasNutOrg) ? " or " : "",
pkgurlHasNutOrg ? "" : "https://www.networkupstools.org/"
);
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
#pragma GCC diagnostic pop
#endif
return;
}

Expand Down

0 comments on commit 7e714ee

Please sign in to comment.