Skip to content

add saned runscript

Andrew Bower requested to merge abower/runit-services:saned into next

Add runscript for Debian's saned scanner daemon service.

This uses the standalone foreground server mode, which is distinct from the background server mode of the initscript and socket activation of the systemd service.

This combination uniquely results in unclean shutdown and I found three bugs in the implementation of this mode in the upstream code. Without a fix, an Avahi server process under saned's process title remains and runit reports an abnormal failure, although this is not catastrophic failure mode.

I have created fixes to the issues in the upstream code and added an enhancement for recent Linux kernels that avoids waking up the CPU every 500ms to check for terminated child processes. This seems worth having. I have proposed fixes: https://gitlab.com/sane-project/backends/-/merge_requests/854

The result is clean shutdown:

$ sudo tail -f /var/log/runit/saned/current 
2024-10-13_23:38:25.92038 [saned] do_bindings: [0] socket () using IPv4
2024-10-13_23:38:25.92039 [saned] do_bindings: [0] setsockopt ()
2024-10-13_23:38:25.92039 [saned] do_bindings: [0] bind () to port 6566
2024-10-13_23:38:25.92039 [saned] do_bindings: [0] bind failed: Address already in use
2024-10-13_23:38:25.92041 [saned] Dropped privileges to uid 105 gid 115
2024-10-13_23:38:25.92041 [saned] run_standalone: spawning Avahi process
2024-10-13_23:38:25.92048 [saned] run_standalone: waiting for control connection
2024-10-13_23:38:25.92098 [saned] saned_avahi_callback: AVAHI_CLIENT_S_RUNNING
2024-10-13_23:38:25.92106 [saned] saned_create_avahi_services: adding service 'saned'
2024-10-13_23:38:26.73586 [saned] saned_avahi_group_callback: service 'saned' successfully established
2024-10-13_23:39:04.79644 [saned] bailing out, waiting for children...
2024-10-13_23:39:04.79657 [saned] bail_out: all children exited

I think there is more that can be done to tidy up the server process but this is probably enough for now!

It may be that it is more appropriate to propose this runscript with, or at least after, a future version of the sane-utils package that includes these fixes, if accepted.

Edited by Andrew Bower

Merge request reports

Loading