Skip to content

RMS_Update: restore bounded sudo prompt and raise UDP buffers to 16MB - #972

Draft
Cybis320 wants to merge 2 commits into
CroatianMeteorNetwork:prereleasefrom
Cybis320:rms-update-udp-buffers
Draft

RMS_Update: restore bounded sudo prompt and raise UDP buffers to 16MB#972
Cybis320 wants to merge 2 commits into
CroatianMeteorNetwork:prereleasefrom
Cybis320:rms-update-udp-buffers

Conversation

@Cybis320

Copy link
Copy Markdown
Contributor

Two related changes to RMS_Update.sh, kept as separate commits.

1. Restore the bounded sudo password prompt

sudoWithTimeout() was added in 52b085ec and removed in c5fd3ab5 ("Prevent corruption of config and mask file", a 384-line restructure). Nothing in that commit was about sudo and no reference to it survives, so this looks like collateral of the rewrite rather than a decision.

Without it, the fallback branch runs a bare sudo apt-get and waits on sudo's own prompt. Sudo's passwd_timeout defaults to 0 (no timeout), so an unattended run can block indefinitely — which matters because GRMSUpdater.sh stops all stations before calling this script.

Reinstated as ensure_sudo "<reason>": 30s read -t timeout, 3 attempts, background keep-alive to survive a long apt-get. install_missing_dependencies now goes through it, collapsing the apt-get loop that was previously written out twice.

Four deliberate differences from the original:

  • the keep-alive is trapped (stop_sudo_keep_alive from emergency_cleanup and a new EXIT trap) — the original leaked it
  • background refresh uses sudo -n -v so it can never compete for the terminal, plus a kill -0 "$$" guard
  • printf instead of echo for the password, which echo can mangle on backslashes
  • returns 1 without prompting when no terminal is attached, so non-interactive callers skip instead of hanging

2. Raise UDP buffers to 16MB during update

BufferedCapture.py asks rtspsrc for a 16MB udp-buffer-size, but the kernel clamps that to net.core.rmem_max. Where the limit is lower the request is a no-op and frames drop under load. UpdateBuffers.sh already sets this, but nothing ever called it, so stations only got it if run by hand.

  • UpdateBuffers.sh gains --check (unprivileged, exit 0 adequate / 10 needs raising) and --yes; argument parsing moved above the root gate so --check works without sudo
  • fixes a silent no-op: with no tty and no --yes, the confirm prompt used to read empty, print "No changes made" and exit 0 — indistinguishable from success to a caller. It now fails loudly
  • applying verifies the values actually took instead of assuming
  • RMS_Update.sh gains update_udp_buffers() after the dependency step, plus --skip-buffers

The check is unprivileged, so sudo is only requested when there is real work: one prompt per station, silent no-op on every update after. It always returns 0 — buffer sizing affects capture at runtime and should never fail a build.

Testing

Against a mock Linux sysctl (macOS has no net.core.*):

  • --check at 208KB / 1MB / 16MB returns 10 / 10 / 0
  • no tty without --yes exits 1; with --yes proceeds; already-adequate exits 0 without applying
  • timeout path measured at exactly one 30s interval, not 3x
  • all three update_udp_buffers paths return 0
  • both scripts pass bash -n

Nothing was executed against /etc — the apply stage was stubbed in the test copy.

Note

GRMSUpdater.sh:595 now takes the skip path and prints the manual command rather than stalling with stations stopped. That also means multi-camera hosts won't get the buffer bump automatically and will need one manual sudo ./Scripts/UpdateBuffers.sh --yes. If that should be automatic, the cleaner fix is for GRMSUpdater to establish sudo up front, before stop_stations.

🤖 Generated with Claude Code

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.

1 participant