Repository navigation
fix(terminal): disk log of a SATA disk shows "command not found" instead of its log lines - #2825
Conversation
|
Warning Review limit reachedYou'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. View limit details
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. |
|
Still reproducible on Unraid 7.4.0 and 7.4.1: Main → Disk Log Information for a SATA disk only shows I applied the two changes from this PR on a live 7.4.1 system:
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! |
Clicking the disk icon of a SATA disk (Main, or the disk icon in Unassigned Devices, which opens the same window) shows only
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.phpsearches the syslog for the device name or its ATA port, so that kernel messages about the link (for exampleata59: SATA link uporata59.00: exception Emask) are shown too. It writes this command to/var/tmp/<disk>.run.sh:run_cmdgets its arguments from bash with the quotes already removed, joins them with spaces and runs the result throughpopen(), which starts a new shell. That shell readsgrep -P sdj|ata59[.:] …as two commands joined by a pipe:grep -P sdjwaits for input from the terminal, andata59[.:]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 beforerun_cmdsees it.run_cmdexpects the unexpanded pattern as its last argument, to find the log files itself and read them oldest first (glob()sorted byfilemtime). 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_cmdquotes each argument again (array_map('escapeshellarg', $argv)) before it builds the command forpopen(). The arguments were already split by the shell that startedrun_cmd, so quoting each one restores them exactly. Every caller benefits, not only this pattern:tail -f -n <rows> <file>anddocker logs -n <rows> <name>give the same command as before.OpenTerminal.phppasses the log pattern quoted again ('/var/log/syslog*'), sorun_cmdfinds the log files itself and reads them oldest first.The pattern itself is unchanged:
$nameis checked byterminal_identifier()and$atacan only beatafollowed 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:
sh: line 1: ata59[.:]: command not found, then waits for inputA 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:
After:
No changes to other files.