Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 7198 - rc script "runscripts.sh" is not handling bad daemon correctly
Summary: rc script "runscripts.sh" is not handling bad daemon correctly
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: x86 All
: Low normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords: InVCS
: 7812 9929 15141 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-08-28 20:55 UTC by Nicholas Veeser
Modified: 2005-11-20 03:12 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicholas Veeser 2002-08-28 20:55:09 UTC
I have just installed samba 2.2.5-r1
I copied over an old configuration file to get it working.
I start samba by using the script /etc/init.d/samba start
No errors reported by start script,  samba is not running.
Check logs for the error, change config file to solve problem.

I rerun /etc/init.d/samba start.
It says samba is already started, so it will not start it. ok
I run /etc/init.d/samba stop
It says it cannot kill samba as its pid's arent running.

I am stuck.   After an hour I removed the link ${svcdir}/started/samba
Then I can run /etc/init.d/samba start.

BUG:  Given that samba fails quietly (which is bad), why 
does "/etc/init.d/samba stop" not fix the problem.   

After reading runscripts.sh, I found that at the end of svc_stop(), if stop() 
has failed, the ${svcdir}/started/samba link is recreated.  (Why I am not sure).

The comment says that if the stop fails and the system is halting, then 
recreate the link.  It defines "system is halting" as, runlevel as neither 
in "reboot" or "shutdown".  The runlevel "default", not "reboot" or "shutdown" 
so the statement is true, but the system is not halting.  

As per the comment, the logic is false.
Comment 1 Martin Schlemmer (RETIRED) gentoo-dev 2002-08-28 23:35:45 UTC
--------------------------------------------------------------------------------
  if [ "${retval}" -ne 0 ]
  then
          #did we fail to stop? create symlink to stop multible attempts at
          #runlevel change
          if [ -d ${svcdir}/failed ]
          then
                  ln -sf /etc/init.d/${myservice} ${svcdir}/failed/${myservice}
          fi
          #if we are halting the system, do it as cleanly as possible
          if [ "${SOFTLEVEL}" != "reboot" ] && [ "${SOFTLEVEL}" != "shutdown" ]
          then
                  ln -sf /etc/init.d/${myservice} ${svcdir}/started/${myservice}
          fi
  fi
-------------------------------------------------------------------------------

No, its not.  If it fails to stop, it means it *could* still be running.  The
admin should thus intervene, and check what the problem is.  This is why the
link is recreated.  If you also maybe did read a bit more, you would have
seen that if you ran:

# /etc/init.d/samba zap

it would have removed the link.

If the system is shutting down, or rebooting, it will set $SOFTLEVEL to either
"reboot" or "shutdown", even if there is no such runlevels in /etc/runlevels.

Please read the whole /sbin/runscript.sh and /sbin/rc and then comment
again.
Comment 2 SpanKY gentoo-dev 2002-08-29 09:23:04 UTC
if you just do
/etc/init.d/samba
it'll show you the help

also, if you just run `runscript` it'll show you the help
Comment 3 Nicholas Veeser 2002-08-29 15:17:10 UTC
I was aware that the link was removed earlier in the function.
(which is presumably what I wanted)
That is why I knew to see that the link was recreated at the point in question.
 
So if I get this correctly, what that code means is that if the stop has
failed and the runlevel is not shutdown or reboot, then recreate the 
link, as the service may not have been shutdown at all, and may still be 
running. And that when halting (either reboot or shutdown) don't recreate the 
link as init will kill the daemon and the system should be clean before we go 
down.

This makes much more sense to me.  I read the comment (way) wrong.  Maybe the 
comment could state the above rationale.

As for my original problem, I will assume it lies with samba (and its start 
script), not the rc-scripts.  When Samba fails, it can do so quietly without 
telling its start script (by way of a return value to the start-stop-daemon 
tool).  This puts the rc-scripts system in an incorrect state of thinking the 
daemon is started when it has not.

Should the rc-scripts be able to handle this somehow?  If I were to fix the 
samba start script, without fixing samba, to get around this, what could I do?

I had to go through alot of reading to get the one service started. ;) 


btw, so far this rc system is pretty awesome.  I have only played with is for a 
day or so, but its intuitive, clean (especially for bourne), and well executed. 
Thanx.
Comment 4 Martin Schlemmer (RETIRED) gentoo-dev 2002-08-29 15:54:07 UTC
Ditto.

Yep, samba have that problem of failing to start without letting start-stop-daemon
know about it.

Actually, it is in the works to check that the service did stop/start.  Just a
bit hairy, as I dont want to implement something that I will have to change
20 times again due to design problems.

If you have a look at /sbin/functions.sh, you will see there is already some
initial code for stop-daemon(), which uses the pid of the service to check if
it stopped or not.  It is however very alpha code as i havent had time to
work on it again.  The idea is also to implement a start-daemon(), which
uses checkpid() to see if it did start.
Comment 5 Martin Schlemmer (RETIRED) gentoo-dev 2002-09-11 15:42:22 UTC
*** Bug 7812 has been marked as a duplicate of this bug. ***
Comment 6 Martin Schlemmer (RETIRED) gentoo-dev 2002-11-07 01:32:17 UTC
*** Bug 9929 has been marked as a duplicate of this bug. ***
Comment 7 Martin Schlemmer (RETIRED) gentoo-dev 2003-02-09 04:58:06 UTC
*** Bug 15141 has been marked as a duplicate of this bug. ***
Comment 8 Roy Marples (RETIRED) gentoo-dev 2005-03-01 10:00:44 UTC
I've put code in CVS which will provide a working wrapper to start-stop-daemon which should fix this nicely.

Will be in baselayout-1.12.0
Comment 9 SpanKY gentoo-dev 2005-11-20 03:12:32 UTC
should be much better now