Skip to content

ipmicli: repeated -p/-k message, terminal detection on Java 22-24, --no-escape on a terminal, 'power on' hint, owner in sensors and fru output (#218) - #232

Merged
bertysentry merged 2 commits into
mainfrom
218-ipmicli-wrong-message-for-a-repeated--p-k-redirected-runs-taken-for-a-terminal-on-java-22-24-false---no-escape-banner-powerup-hint-no-owner-in-sensors-and-fru-output
Oct 25, 2026
Merged

bertysentry merged 2 commits into
mainfrom
218-ipmicli-wrong-message-for-a-repeated--p-k-redirected-runs-taken-for-a-terminal-on-java-22-24-false---no-escape-banner-powerup-hint-no-owner-in-sensors-and-fru-output

Conversation

@bertysentry

Copy link
Copy Markdown
Contributor

Fixes #218: the five CLI-layer defects, no library API change.

What changes

  1. Repeated -p/-k reported as repeated. CliArguments records the long name of the secret option given (-p and --password are the same) and refuses a repetition with --password is given twice (--bmc-key is given twice); -p with -pf and -k with -kf keep the mutually exclusive message. Other repeated options still take their last value.
  2. Terminal detection on Java 22 to 24. IpmiCli.main() passes isTerminal(System.console()), which calls Console.isTerminal() by reflection when it exists (Java 22+) and takes a non-null console for a terminal otherwise (Java 8 to 21). readConsolePassword() refuses a non-terminal console with the same no interactive console message. A redirected run therefore never prompts, and sol takes the redirected-input path (bytes forwarded as they come) instead of raw or line mode.
  3. --no-escape on a terminal is refused (exit 64): --no-escape needs a redirected input: on a terminal, ~. is the only way out (use --escape to pick another character). The banner's "the end of the input closes it" branch is gone with it: on a terminal, an escape sequence is always set.
  4. power cycle of a system that is off prints ipmicli: the system is off: a power cycle would power it up on some BMCs, use 'power on' (exit 70) instead of the client message naming PowerUp.
  5. Owner in the output. sensors --json adds ownerId (the 7-bit address shifted left, bit 0 set for a system software ID, the encoding of the low byte of the SEL generatorId), ownerLun and ownerChannel, so a script joins sel --json as SelEntry.isFrom() does. fru --json adds address (8-bit, 32 for the BMC), lun and channel; the text header and the problem lines name them when the FRU is not held by the BMC at LUN 0 (FRU 5 at 2Ch channel 6: ..., FRU 5 at 20h LUN 1: ...).

Docs: cli.md (options, sensors, fru, sel join, SOL, exit codes) and the Command-line client section of upgrading.md.

Tests

CliArgumentsTest.usageErrors and the wipe test cover the repeated options; IpmiCliTest adds the owner fields of sensors on the BMC, at LUN 1, on a satellite (2Ch, channel 6) and in the BIOS (B1h), three FRUs numbered 5 on different controllers and LUNs, the --no-escape refusal with terminal=true, and isTerminal() (false for a null console and for the console of the forked test JVM, whose streams are pipes on every JDK). The golden JSON files gain the new fields. mvn clean verify site passes with no new checkstyle, PMD, CPD or SpotBugs finding.

Live checks

With the standalone jar: on JDK 21 and JDK 25, echo secret | ipmicli ... chassis > out.txt fails with no interactive console to ask the password (exit 64); on JDK 25 the reflective Console.isTerminal() returns true on a real terminal (ProxyingConsole). The Java 22 to 24 case itself (a non-null console whose isTerminal() is false) is traced from the JDK API: no such JDK is installed, and Java 25 returns a null console for redirected streams even with -Djdk.console=jdk.internal.le (JDK-8351435), so the issue's JDK 21 reproduction with that provider still prompts there, as isTerminal() does not exist on 21. The repeated -p/-k messages were checked with the jar; the FRU labels of other controllers are by the specification, as no lab BMC has such a FRU (#193).

🤖 Generated with Claude Code

…2-24, refuse --no-escape on a terminal, name 'power on' in the cycle refusal, and print the owner of sensors and FRUs (#218)

- CliArguments: a password or BMC key option given twice, in either of its forms, fails with
  '<option> is given twice'; the mutual-exclusion message is kept for -p with -pf and -k with -kf.
- IpmiCli.main() takes System.console() for a terminal only when Console.isTerminal(), called by
  reflection, says so (Java 22 to 24 return a console for redirected streams); readConsolePassword()
  refuses such a console with the same 'no interactive console' message.
- sol --no-escape is a usage error on a terminal, where no keystroke would close the console; the
  banner no longer promises that the end of the input closes it.
- power cycle of a system that is off says "use 'power on'" instead of the PowerUp constant.
- sensors --json adds ownerId (encoded like the low byte of a SEL generator ID), ownerLun and
  ownerChannel; fru --json adds address, lun and channel, and the text header and problem lines
  name the controller and LUN of a FRU not held by the BMC at LUN 0.

Checked with the standalone jar on JDK 21 and 25: a redirected run refuses to prompt, and the
reflective isTerminal() returns true on a real terminal of Java 25. The Java 22 to 24 case itself
is traced from the JDK API (no such JDK installed; Java 25 returns a null console for redirected
streams even with -Djdk.console=jdk.internal.le).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T20:34:56.748286Z eda92fc New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8496e288b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/java/org/metricshub/ipmi/cli/IpmiCli.java Outdated
…view)

FruReader reads a locator at 20h as a FRU of the BMC whatever its channel (a Supermicro BMC
locates its own FRU 0 at 20h on channel 2): the label depends on the address and LUN only, and
names the channel for another controller.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@bertysentry
bertysentry merged commit 05a0deb into main Oct 25, 2026
4 checks passed
@bertysentry
bertysentry deleted the 218-ipmicli-wrong-message-for-a-repeated--p-k-redirected-runs-taken-for-a-terminal-on-java-22-24-false---no-escape-banner-powerup-hint-no-owner-in-sensors-and-fru-output branch October 25, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant