#368033 s-s-d: --oknodo should exit unsuccessfully if there was stuff to do, but it failed

Package:
dpkg
Source:
dpkg
Description:
Debian package management system
Submitter:
Jari Aalto
Date:
2015-03-29 00:03:13 UTC
Severity:
normal
#368033#5
Date:
2006-05-19 05:37:11 UTC
From:
To:
DESCRIPTION

    foo@host:~$ /etc/init.d/ssh start
    foo@host:~$ echo $?
    0
    foo@host:~$ id -a
    uid=1000(foo) gid=1000(foo) groups=44(video),1000(foo)

SUGGESTION

The service start script

1) Should return error (cannot commence any command non-root)
2) Display error message, that user does not have privileges
   to run the command

Add error checking to the service script. Compare this to

    foo@host:~$ /etc/init.d/shorewall stop; echo $?
    You must be root to start, stop or restart "Shorewall firewall".
    1

#368033#10
Date:
2006-05-19 12:26:10 UTC
From:
To:
clone 367993 -1 -2
reassign -1 dpkg
retitle -1 dpkg: [S-S-D]: --oknodo should exit unsuccessfully if there was stuff to do, but it failed
retitle 367993 ssh: fails to show any error when start/stop as normal user fails
retitle -2 ssh: immediate failure of a child process doesn't cause an unsuccessful exit.
tag 367993 moreinfo
thanks
This is actually a dpkg bug; start-stop-daemon is failing to do
anything, but since --oknodo is given, it succeeds.  IMO this is
incorrect for the case that it does nothing for any reason other than
"there was nothing to do", in particular for the case that permission
was denied:

$ /sbin/start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/sshd.pid; echo $?
/sbin/start-stop-daemon: warning: failed to kill 5870: Operation not permitted
0

Please give the output of bash -x /etc/init.d/ssh start, and then bash -x
/etc/init.d/ssh stop (as a normal user).

This also seems to be an ssh bug, to the effect of "the parent exits
successfully without waiting for necessary startup stuff to happen in
the child, which immediately fails".

$ /usr/sbin/sshd; echo $?
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
0

Hmmm stracing seems to indicate that it isn't an "fork and exit
immediately" problem, but rather an "failure message from the child
doesn't cause unsuccessful exit" problem.

Justin