Skip to content

Perl UPS::Nut: decode NUT tokens and quote authentication arguments - #3634

Open
user01010111 wants to merge 2 commits into
networkupstools:masterfrom
user01010111:codex/perl-nut-tokenizer
Open

Perl UPS::Nut: decode NUT tokens and quote authentication arguments#3634
user01010111 wants to merge 2 commits into
networkupstools:masterfrom
user01010111:codex/perl-nut-tokenizer

Conversation

@user01010111

Copy link
Copy Markdown

Reading an UPS description such as "Main" C:\UPS\\end #1 through
UPS::Nut currently leaves wire escapes in returned values. Parse NUT
words once in the shared query/list readers and in nutauth.conf, including
escaped include paths, comments and line continuation. Encode literal
username/password arguments in Authenticate() so credentials decoded
from configuration can be sent correctly. Keep escaping # on output for
older servers. GetCmdDesc() now accepts the actual CMDDESC reply.

Preserve scalar/hash/array result shapes, the space-separated GetType()
scalar, aliases and constructor/tied-read consumers. Keep existing include
resolution, precedence and the separate section-include inheritance FIXME.
Set(), InstCmd(), tied writes, tracking and TLS are outside this change.
Single quotes in configuration are literal, following the C parser;
UPGRADING and POD explain the change and removal of manual decoding.
Bump the module to 1.63 and add a client-library release note.

Add one core-module regression script to the existing Perl-aware
make check and distribution rules. Require the already documented
Perl 5.005 floor explicitly and use the existing FileHandle dependency
for configuration file opening on that runtime.

Related: #3629 (approved separate Perl follow-up).

Validation:

  • The 235-check regression fails 120 checks on unmodified upstream
    2caa3c87501a1aba25a3070ad66757470bd1bf03. All 235 pass with this change.
  • macOS ARM64 Perl 5.34.1 and Linux ARM64 Perl 5.40.1 and 5.005_04
    pass the regression, including the constructor, fragmented/coalesced
    localhost traffic, escaped credentials and temporary include filenames.
    Privately installed generated modules pass the same regression.
  • 420 permitted-input records match the separately corrected C parser's
    exact token bytes and boundaries. This does not change the C parser's
    character filter: Perl continues to preserve existing high-byte values.
  • Real localhost upsd/dummy-ups checks cover descriptions, lists,
    variables, actual CMDDESC, and AuthConf-to-login credentials containing
    spaces, quotes, backslashes and hashes. Escaped traffic works with the
    unchanged server; raw quoted-hash configuration works with the separately
    corrected C parser. That C change is not part of this patch.
  • Existing NIT_CASE=perl passes 4 groups with no failures or skips on
    current macOS and Linux, including Linux Perl 5.005_04.
  • macOS and Linux builds and make check pass, including 12 Automake tests,
    as do staged installs, POD syntax, spelling and style checks.
    Final make distcheck-light passes with all 270 real man pages present;
    the extracted archive builds, runs the regression and 12 Automake tests,
    installs/uninstalls and cleans successfully. Its five changed source
    files match this patch exactly.

No physical UPS hardware was available for testing. Validation covered
standalone regressions, deterministic localhost socket fixtures, and locally
built upsd with simulated dummy-ups devices on macOS and Linux.
Physical UPS models, firmware versions, and hardware combinations were
not tested.

Other operating systems were not executed. Perl 5.005_04 was provisioned
in an isolated Linux prefix with build adjustments for modern GCC, library
paths, shell dependency generation and a removed Linux header; this does
not establish Solaris 8 acceptance. Its supplemental interpreter self-test
run has four failures in preprocessing, Errno generation and an unavailable
DB module; the NUT regression and integration paths above all pass. There is no standard Perl-module install
rule in NUT, so its generated module was also copied to a private Perl
library directory for installed-path checks.

Relevant checklist:

  • Concrete behavior, compatibility expectations and limitations described.
  • Focused change; maintained templates and test/distribution rules used.
  • New source comments and release-note text use ASCII.
  • NEWS, UPGRADING and POD updated; no driver changes.
  • Build, tests, spelling/style and complete-documentation distcheck-light pass.
  • AI use and actual model disclosed.
  • Human contributor review and acceptance of responsibility completed.
  • Human contributor consciously authorized DCO sign-off for this separate contribution.

AI assistance: OpenAI Codex with gpt-6-astra (high reasoning)
and gpt-daybreak-blue-latest (high reasoning).
The human contributor remains responsible for reviewing and submitting
the change.

Decode NUT reply and configuration tokens once, including escaped INCLUDE
paths, and quote literal authentication credentials. Preserve public return
shapes and accept the actual CMDDESC response. Update POD, upgrade notes
and the module version.

Add a core-module regression script to check/distribution rules. Validated
on Perl 5.005_04, 5.34.1 and 5.40.1, corrected-C comparisons, localhost
upsd/dummy-ups, generated/installed modules and distcheck-light.

Related: networkupstools#3629

AI assistance: OpenAI Codex with gpt-6-astra (high reasoning)
and gpt-daybreak-blue-latest (high reasoning).
The human contributor remains responsible for reviewing and submitting
the change.

Signed-off-by: user01010111 <12504630+user01010111@users.noreply.github.com>
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

A ZIP file with standard source tarball and another tarball with pre-built docs for commit c32a121 is temporarily available: NUT-tarballs-PR-3634.zip.

@AppVeyorBot

Copy link
Copy Markdown

@AppVeyorBot

Copy link
Copy Markdown

Use a portable INCLUDE fixture while checking quote and backslash decoding
at recursive AuthConf dispatch. Flush TAP before fork, exit the child
normally and keep temporary-directory cleanup owned by the parent so the
socket fixture completes under Windows pseudofork. Preserve timeouts,
collision refusal and production behavior.

Validated with all 236 assertions on macOS Perl 5.34.1, Linux 5.40.1 and
5.005_04, and Strawberry 5.42.3 under Wine/QEMU. Build, make check,
spelling/style and distcheck-light pass. Wine does not establish exact
AppVeyor/MSYS2 or Windows-kernel acceptance; MSYS2 Perl could not start
under Wine before loading NUT.

Related: networkupstools#3634

AI assistance: OpenAI Codex with gpt-6-astra (high reasoning).
The human contributor remains responsible for reviewing and submitting
the change.

Signed-off-by: user01010111 <12504630+user01010111@users.noreply.github.com>
@AppVeyorBot

Copy link
Copy Markdown

Build nut 2.8.5.5263-master completed (commit 82eda57ff7 by @user01010111)

@AppVeyorBot

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants