Skip to content

fix(terminal): disk log of a SATA disk shows "command not found" instead of its log lines - #2825

Merged
tom mortensen (limetech) merged 1 commit into
unraid:masterfrom
luuvasara:fix/disk-log-pattern
Dec 4, 2026
Merged

tom mortensen (limetech) merged 1 commit into
unraid:masterfrom
luuvasara:fix/disk-log-pattern

Conversation

@luuvasara

Copy link
Copy Markdown

Clicking the disk icon of a SATA disk (Main, or the disk icon in Unassigned Devices, which opens the same window) shows only

sh: line 1: ata59[.:]: command not found

and no log lines. The window then waits for input instead of offering "Press ANY KEY to close this window". Disks that are not on an ATA port, such as NVMe disks, are not affected, because their log is searched by the device name alone.

Cause

For a SATA disk, OpenTerminal.php searches the syslog for the device name or its ATA port, so that kernel messages about the link (for example ata59: SATA link up or ata59.00: exception Emask) are shown too. It writes this command to /var/tmp/<disk>.run.sh:

run_cmd grep -P 'sdj|ata59[.:]' /var/log/syslog*

run_cmd gets its arguments from bash with the quotes already removed, joins them with spaces and runs the result through popen(), which starts a new shell. That shell reads grep -P sdj|ata59[.:] … as two commands joined by a pipe: grep -P sdj waits for input from the terminal, and ata59[.:] is not found.

Before f7e1ba6 the pattern was quoted twice (escapeshellarg("'$dev'")), so a pair of quotes survived to that second shell. f7e1ba6 removed the extra quotes, and with them the protection. It also removed the quotes around /var/log/syslog*, so bash expands the pattern before run_cmd sees it. run_cmd expects the unexpanded pattern as its last argument, to find the log files itself and read them oldest first (glob() sorted by filemtime). With the pattern expanded, it only treats the last file as the log and passes the others to grep, which then prints file names in front of the lines and reads the files in name order.

The fix

  • run_cmd quotes each argument again (array_map('escapeshellarg', $argv)) before it builds the command for popen(). The arguments were already split by the shell that started run_cmd, so quoting each one restores them exactly. Every caller benefits, not only this pattern: tail -f -n <rows> <file> and docker logs -n <rows> <name> give the same command as before.
  • OpenTerminal.php passes the log pattern quoted again ('/var/log/syslog*'), so run_cmd finds the log files itself and reads them oldest first.

The pattern itself is unchanged: $name is checked by terminal_identifier() and $ata can only be ata followed by digits.

How it was tested

On Unraid 7.3.4, in a terminal window (ttyd), with example log lines in a syslog and a rotated syslog.1:

Window shows
7.3.4 only sh: line 1: ata59[.:]: command not found, then waits for input
this PR the four lines for sdj and ata59 from both files, oldest first, then "Press ANY KEY to close this window"

A line for another port, ata5.00, is not shown, so the [.:] after the port number still does its job. run_cmd tail -n 1 <file> gives the same output as before.

Before:

before

After:

after

No changes to other files.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 25 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5b7ea696-332d-43fd-b9bc-112695f7923b
Commits

Reviewing files that changed from the base of the PR and between b135287 and 6c22730.

Files selected for processing: 2

  • emhttp/plugins/dynamix/include/OpenTerminal.php
  • emhttp/plugins/dynamix/scripts/run_cmd
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@unraid-bot Unraid Bot (unraid-bot) added QA Passed QA passed (auto-managed by notification-worker) 7.4.2 Approved for release 7.4.2 (auto-managed by notification-worker) labels Nov 27, 2026
@nicandr0

Copy link
Copy Markdown

Still reproducible on Unraid 7.4.0 and 7.4.1: Main → Disk Log Information for a SATA disk only shows sh: line 1: ata6[.:]: command not found (NVMe disks are fine), same as described in #2785.

I applied the two changes from this PR on a live 7.4.1 system:

  • Disk Log Information for the SATA disk shows its matching syslog lines again (oldest file first).
  • The plain tail path through run_cmd (syslog viewer) still works.

Since this is a regression from the OpenTerminal input validation (#2761 / #2763) and affects every SATA disk, it would be great to see this merged for the next 7.4.x release. Thanks!

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

Labels

7.4.2 Approved for release 7.4.2 (auto-managed by notification-worker) QA Passed QA passed (auto-managed by notification-worker)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants