PATCH: make contrib/redhat/sshd.init work with older RH releases
Jim Knoble
jmknoble at jmknoble.cx
Sun Feb 18 06:14:10 EST 2001
Circa 2001-Feb-17 17:14:34 +0200 dixit Pekka Savola:
: On Fri, 16 Feb 2001, Jim Knoble wrote:
: > Attached is a patch to contrib/redhat/sshd.init which eliminates the
: > dependency on the success() and failure() functions from
: > initscripts>=4.16. This allows sshd.init to be used for both early and
: > recent releases of Red Hat Linux (i've confirmed it works on both 4.2
: > and 5.2 as well as 6.2).
:
: IMO, this is a wrong way to do this.
:
: Rather, if we want to do this, I propose something like (sshd-funcs may
: not be the best name to describe this..):
What you suggest would make a lot more changes to the file; i was
trying to keep the number of changes to a minimum, since it's right
before release.
If folks think it's a good idea to redo the whole thing, then by all
means do it right.
: --- sshd~ Sat Feb 17 16:16:33 2001
: +++ sshd Sat Feb 17 17:07:00 2001
: @@ -15,6 +15,9 @@
: # source function library
: . /etc/rc.d/init.d/functions
:
: +# source local sshd functions
: +. /etc/rc.d/init.d/sshd-funcs
: +
I think one of the following names is better (i myself prefer the first):
sshd-functions
sshd.functions
functions.sshd
Remember also that in RHL-7.0 (and in FHS >= 2.0), the location of
'init.d' changes. This looks more robust to me:
SSHD_FUNCTIONS=""
for i in \
/etc/init.d/sshd-functions \
/etc/rc.d/init.d/sshd-functions \
; do
if [ -f "${i}" ]; then
SSHD_FUNCTIONS="${i}"
. "${SSHD_FUNCTIONS}"
break
fi
done
if [ -z "${SSHD_FUNCTIONS}" -o $? -ne 0 ]; then
exit 1
fi
But it's rather complex. Even this would be acceptable:
if [ -f /etc/init.d/sshd-functions ]; then
. /etc/init.d/sshd-functions
else
. /etc/rc.d/init.d/sshd-functions
fi
if [ $? -ne 0 ]; then
exit 1
fi
: ---
: [no further changes in the main file!]
:
: Where sshd-funcs would redefine success, failure, action, and whatever
: other things that might come up, with something of it's own, like:
The problem is with redefining the stock functions is that success()
and failure() work slightly differently than the equivalent actions for
RHL <= 5.2.
That's why the my_success() and my_failure() functions i defined take
an optional second argument, to make them Act The Right Way(R) for all
RH releases. In RHL-6.2, success() and failure() only care about their
first argument ($1), and it , but there's no guarantee that Red Hat
won't change the functions in the future. Using our own functions
avoids that potential problem.
Note, though, that my main goal is to make one sshd.init work for RHL
releases >= 4.2. However we can agree to do that properly is fine with
me.
--
jim knoble | jmknoble at jmknoble.cx | http://www.jmknoble.cx/
More information about the openssh-unix-dev
mailing list