Debian bug report logs - #1079
Scripts in /etc/init.d cannot be called directly

Package: sysvinit; Reported by: Swen Thuemmler <swen@uni-paderborn.de>; 116 days old.

Message received at debian-bugs:


From cus.cam.ac.uk!iwj10 Fri Jul  7 12:41:50 1995
Return-Path: <iwj10@cus.cam.ac.uk>
Received: from pixar.com by mongo.pixar.com with smtp
	(Smail3.1.28.1 #15) id m0sUJHZ-0006ZUC; Fri, 7 Jul 95 12:41 PDT
Received: from bootes.cus.cam.ac.uk by pixar.com with SMTP id AA03322
  (5.67b/IDA-1.5 for debian-bugs-pipe@mongo.pixar.com); Fri, 7 Jul 1995 12:40:19 -0700
Received: by bootes.cus.cam.ac.uk 
	(Smail-3.1.29.0 #36) id m0sUJHW-000BznC; Fri, 7 Jul 95 20:41 BST
Received: by chiark
	id <m0sUJ6t-0000YFZ@chiark.al.cl.cam.ac.uk>
	(Debian /\oo/\ Smail3.1.29.1 #29.32); Fri, 7 Jul 95 20:30 BST
Message-Id: <m0sUJ6t-0000YFZ@chiark.al.cl.cam.ac.uk>
Date: Fri, 7 Jul 95 20:30 BST
From: iwj10@cus.cam.ac.uk (Ian Jackson)
To: debian-bugs@pixar.com
Subject: Re: Bug#1079: Scripts in /etc/init.d cannot be called directly

Swen Thuemmler writes ("Bug#1079: Scripts in /etc/init.d cannot be called directly"):
> [...]
> In some scripts in /etc/init.d there seems to be a bug. I think it is
> intented to be able to call the scripts directly by e.g.
> [...]
> The problem is the line
> . /etc/init.d/functions
> which changes the Parameter $1

There is little reason for files in /etc/init.d to use the `functions'
file.  The file `functions' on my system contains

* code to set PREVLEVEL and RUNLEVEL based on the output of the
`runlevel' command.  The only scripts in /etc/init.d that use it are
`rc' and `powerfail' - arguably this could be done by using `runlevel'
directly in those scripts.

* shell functions `daemon' and `stop' that do a half-baked version of
`start-stop-daemon'.  Scripts should use `start-stop-daemon' instead;
the `daemon' and `stop' functions are not reliable.  There are no
scripts in my /etc/init.d directory that use `daemon' or `stop'.

I suggest that the file `functions' be removed.

Ian.

Acknowledgement sent to iwj10@cus.cam.ac.uk (Ian Jackson):
Extra info received and forwarded. Full text available.
Information forwarded to debian-devel@pixar.com:
Bug#1079; Package sysvinit. Full text available.

Message received at debian-bugs:


From uni-paderborn.de!swen Fri Jul  7 03:03:13 1995
Return-Path: <swen@uni-paderborn.de>
Received: from pixar.com by mongo.pixar.com with smtp
	(Smail3.1.28.1 #15) id m0sUAFd-0005nTC; Fri, 7 Jul 95 03:03 PDT
Received: from uni-paderborn.de by pixar.com with SMTP id AA04918
  (5.67b/IDA-1.5 for debian-bugs-pipe@mongo.pixar.com); Fri, 7 Jul 1995 03:00:20 -0700
Received: from linux.uni-paderborn.de (linux.uni-paderborn.de [131.234.12.32]) by uni-paderborn.de (8.6.12/8.6.12) with ESMTP id MAA04538 for <debian-bugs@pixar.com>; Fri, 7 Jul 1995 12:01:43 +0200
Received: (swen@localhost) by linux.uni-paderborn.de (8.6.12/client-pb) id MAA00350; Fri, 7 Jul 1995 12:01:42 +0200
Date: Fri, 7 Jul 1995 12:01:41 +0200 (MET DST)
From: Swen Thuemmler <swen@uni-paderborn.de>
To: debian-bugs@pixar.com
Subject: Scripts in /etc/init.d cannot be called directly
Message-Id: <Pine.LNX.3.91.950707115605.312B-100000@linux.uni-paderborn.de>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

Package: sysvinit
Version: 2.56-5

In some scripts in /etc/init.d there seems to be a bug. I think it is 
intented to be able to call the scripts directly by e.g.

$ /etc/init.d/skeleton start
Usage: /etc/init.d/skeleton {start|stop}
$

The problem is the line

. /etc/init.d/functions

which changes the Parameter $1

Suggested fix:

Save the parameter before sourcing functions, e.g.:

...
SAVEARG=$1
. /etc/init.d/functions
case "$SAVEARG" in 
...

Greetings, Swen


Acknowledgement sent to Swen Thuemmler <swen@uni-paderborn.de>:
New bug report received and forwarded. Full text available.
Report forwarded to debian-devel@pixar.com:
Bug#1079; Package sysvinit. Full text available.
Ian Jackson / iwj10@thor.cam.ac.uk, with the debian-bugs tracking mechanism
This page last modified 07:43:01 GMT Wed 01 Nov