Subject: bug#921: sane-utils: init script prompts for file removal when status is queried by nonroot user

From: Alexander Rehbein <[email-masked]>
Date: Fri, 31 Oct 2025 18:01:42 +0100

Package: sane-utils
Version: 1.2.1-2
Severity: normal
Tags: patch upstream
X-Debbugs-Cc: [email-masked]

Dear Maintainer,

when running the command '/usr/sbin/service --status-all' as nonroot,
the script hangs inside '/etc/init.d/saned' until I press 'Enter'.
Same for '/usr/sbin/service saned status'.

I would expect the command to just finish outputting all statuses.

It's an easy fix, just add the '-f' flag to the 'rm' command.

I did this and now both commands run through for nonroot without waiting for input.

Thank you

Alexander

-- System Information:
Distributor ID:	Devuan
Description:	Devuan GNU/Linux 5 (daedalus)
Release:	5
Codename:	daedalus
Architecture: x86_64

Kernel: Linux 6.1.0-40-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled

Versions of packages sane-utils depends on:
ii  adduser                          3.134
ii  debconf [debconf-2.0]            1.5.82
ii  init-system-helpers              1.65.2devuan1
ii  libavahi-client3                 0.8-10+deb12u1devuan1
ii  libavahi-common3                 0.8-10+deb12u1devuan1
ii  libc6                            2.36-9+deb12u13
ii  libelogind-compat [libsystemd0]  246.10-5
ii  libieee1284-3                    0.2.11-14
ii  libjpeg62-turbo                  1:2.1.5-2
ii  libpng16-16                      1.6.39-2
ii  libsane1                         1.2.1-2
ii  libusb-1.0-0                     2:1.0.26-1
ii  libxml2                          2.9.14+dfsg-1.3~deb12u4
ii  update-inetd                     4.53

sane-utils recommends no packages.

Versions of packages sane-utils suggests:
ii  avahi-daemon  0.8-10+deb12u1devuan1
pn  unpaper       <none>

-- Configuration Files:
/etc/init.d/saned changed:
. /lib/lsb/init-functions
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/saned
NAME=saned
DESC="SANE network scanner server"
test -x $DAEMON || exit 0
RUN=no
RUN_AS_USER=saned
. /lib/lsb/init-functions
if [ -f /etc/default/saned ] ; then
    . /etc/default/saned
fi
DAEMON_OPTS="-a $RUN_AS_USER"
set -e
case "$1" in
  start)
	log_daemon_msg "Starting $DESC" "$NAME"
	start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON -- $DAEMON_OPTS
	log_end_msg $?
	;;
  stop)
	log_daemon_msg "Stopping $DESC" "$NAME"
	start-stop-daemon --stop --oknodo --quiet --pidfile /var/run/$NAME.pid \
		--retry 10 --exec $DAEMON
	log_end_msg $?
	;;
  force-reload)
	# check whether $DAEMON is running. If so, restart
	start-stop-daemon --stop --test --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON \
	&& $0 restart \
	|| exit 0
	;;
  restart)
	log_daemon_msg "Restarting $DESC" "$NAME"
	$0 stop
	$0 start
	;;
  status)
	if [ -s /var/run/$NAME.pid ]; then
            RUNNING=$(cat /var/run/$NAME.pid)
            if [ -d /proc/$RUNNING ]; then
                if [ $(readlink /proc/$RUNNING/exe) = $DAEMON ]; then
                    log_success_msg "$NAME is running"
                    exit 0
                fi
            fi
            # No such PID, or executables don't match
            log_failure_msg "$NAME is not running, but pidfile existed"
            rm -f /var/run/$NAME.pid
            exit 1
        else
            rm -f /var/run/$NAME.pid
            log_failure_msg "$NAME not running"
            exit 1
        fi
	;;
  *)
	N=/etc/init.d/$NAME
	log_failure_msg "Usage: $N {start|stop|restart|force-reload}"
	exit 1
	;;
esac

-- debconf information excluded