mirror of
https://github.com/dikeckaan/mu300-linux.git
synced 2026-12-06 00:03:00 +00:00
mu300dash and the cell collector: the /proc cmdline reads are braced too, and a static test keeps every one braced
cb30080 braced the reads in mu300-at and its neighbours; the panel's collector checks (collecting, fast_busy, cell's
alive) still had the unbraced form, whose "can't open /proc/PID/cmdline" escapes its own 2>/dev/null when the
process goes between the -d check and the read. The new test scans every shipped shell script for the unbraced form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DqKKtBQZCfxYnHuBCuDqqn
This commit is contained in:
1 parent
dd9b862a88
commit
b6d15ec8d1
3 files changed
+17
-3
No files matched your search
@@ -121,12 +121,12 @@ at_client_busy() { printf '%s\n' "$1" | grep -qxE '(mu300|unisoc)-at: busy'; }
|
||||
collecting() {
|
||||
_p=$(cat "$COLLECT_LCK/pid" 2>/dev/null)
|
||||
[ -n "$_p" ] && [ -d "/proc/$_p" ] &&
|
||||
tr '\0' ' ' < "/proc/$_p/cmdline" 2>/dev/null | grep -q '/unisoc-modem/cell'
|
||||
{ tr '\0' ' ' < "/proc/$_p/cmdline"; } 2>/dev/null | grep -q '/unisoc-modem/cell'
|
||||
}
|
||||
fast_busy() {
|
||||
_p=$(cat "$FAST_LCK/pid" 2>/dev/null)
|
||||
[ -n "$_p" ] && [ -d "/proc/$_p" ] &&
|
||||
tr '\0' ' ' < "/proc/$_p/cmdline" 2>/dev/null | grep -q '/unisoc-modem/cell'
|
||||
{ tr '\0' ' ' < "/proc/$_p/cmdline"; } 2>/dev/null | grep -q '/unisoc-modem/cell'
|
||||
}
|
||||
age_of() { [ -s "$1" ] && echo $(( $(now) - $(date -r "$1" +%s 2>/dev/null || echo 0) )) || echo -1; }
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ qs() { json_str_or_null "$1"; }
|
||||
# --------------------------------------------------------------- one collector
|
||||
# the same "one owner, spare waits/takes over" pattern mu300-atd uses, so two
|
||||
# kicks (page reload while a refresh runs) cannot interleave AT replies
|
||||
alive() { [ -n "$1" ] && [ -d "/proc/$1" ] && tr '\0' ' ' < "/proc/$1/cmdline" 2>/dev/null | grep -q '/unisoc-modem/cell'; }
|
||||
alive() { [ -n "$1" ] && [ -d "/proc/$1" ] && { tr '\0' ' ' < "/proc/$1/cmdline"; } 2>/dev/null | grep -q '/unisoc-modem/cell'; }
|
||||
take_lock() { # take_lock DIRVAR - drop overlap, take over a dead holder
|
||||
local lock=$1 owner
|
||||
while ! mkdir "$lock" 2>/dev/null; do
|
||||
|
||||
@@ -260,6 +260,20 @@ class Rules(unittest.TestCase):
|
||||
# and that its init works with Linux on either slot (mu300-update refuses one without it on slot a)
|
||||
self.assertIn(' tar -xzOf "$D/$a.tar.gz" ./features 2>/dev/null | grep -qx linux-slot', mr)
|
||||
|
||||
def test_proc_reads_are_braced(self):
|
||||
# `tr < /proc/$pid/cmdline 2>/dev/null` reports a failed redirection (the process just went) before its own
|
||||
# 2>/dev/null applies, so "can't open /proc/..." reaches the log: the read is braced, `{ tr < ...; } 2>/dev/null`
|
||||
files = [p for p, _ in shell_scripts()]
|
||||
files += [p for p in (TOP / 'openwrt' / 'luci-app-mu300' / 'root').rglob('*')
|
||||
if p.is_file() and shebang(p).endswith('sh')]
|
||||
bad = re.compile(r'<\s*"?/proc/\$[^\s;|]*\s+2>\s*/dev/null')
|
||||
found = []
|
||||
for p in sorted(set(files)):
|
||||
for n, line in enumerate(p.read_text(errors='replace').splitlines(), 1):
|
||||
if bad.search(line):
|
||||
found.append(f'{p.relative_to(TOP)}:{n}')
|
||||
self.assertEqual(found, [])
|
||||
|
||||
def test_quiet_console_sysctl_on_both_systems(self):
|
||||
# K24: both images carry the same drop-in (systemd-sysctl on Ubuntu, procd's /etc/init.d/sysctl on OpenWrt)
|
||||
a = (TOP / 'rootfs' / 'overlay' / 'etc' / 'sysctl.d' / '99-mu300-console.conf').read_text()
|
||||
|
||||
Reference in new issue
Block a user