dealing with RH initscripts backward compatibility
Pekka Savola
pekkas at netcore.fi
Sun Feb 18 19:22:53 EST 2001
On Sun, 18 Feb 2001, Jim Knoble wrote:
> Circa 2001-Feb-17 22:34:26 +0200 dixit Pekka Savola:
>
> : Hello all,
> :
> : Continuing the thread:
> :
> : Re: PATCH: make contrib/redhat/sshd.init work with older RH releases
> :
> : Attached are newer versions of initscripts. These are smaller and
> : probably more readable than patches. Backward compability features
> : haven't been tested that extensively.
> :
> : I think the issue of legacy initscripts support should be handled like
> : with these patches (sshd-functions could be refined, of course), or in
> : addition:
> :
> : * in openssh.spec, there would be a %define to enable "backward
> : compability". There might even be autodetection for this using
> : /etc/redhat-release.
> :
> : * with this defined, sshd-functions would be taken from contrib and
> : installed in /etc/rc.d/init.d/.
> :
> : * this would give the implementor of sshd-functions more liberty at how he
> : could redefine echo/failure/success/action/etc., because he would know
> : that the changes would only kick in for users using RHL5.2 or earlier
> : [currently]
> :
> : With this, there might be no need for the "do we require this" -checks
> : (~30 first lines of sshd-functions).
> :
> : What do you think? IMO, I think the new idea is probably better because
> : it allows for more freedom when it comes to the implementation. Also,
> : there are other issues that will be version-specific (pam, ...).
I'd like comments about this approach.
> : # source initscripts backward compatibility functions if they exist
> : if [ -r /etc/rc.d/init.d/sshd-functions ]; then
> : . /etc/rc.d/init.d/sshd-functions
>
> I don't like this at all. If this file goes away due to filesystem or
> operator error, things will unexplainably break. Having them break
> with an immediate message such as:
>
> bash: /etc/rc.d/init.d/sshd-functions: No such file or directory
>
> is much easier to diagnose.
The new idea was that sshd-functions would not need to be present on
recent systems. With this approach, you could cut out the additional
checks (below).
>
> : fi
> :
> : RETVAL=0
> : prog="sshd"
> :
> : # Some functions to make the below more readable
> /^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> /
> You probably mean to move this line down to where the functions are.
Sorry, typo. I meant definitions. :-)
> --------[file: sshd-functions]--------
>
> : # Backward compability functions for initscripts, parts by Red Hat.
> :
> : # Find out whether we need to use the local functions
> : # Unnecessary use should be avoided.
> :
> : if [ ! "`type -type success`" = "function" ]; then
> : success() {
> : my_success "$*"
> /^^^^^^
> /
> No, no no. Use "$@", not "$*". "$*" turns multiple arguments into one
> argument---this is almost never what you want, and certainly isn't here.
Ok.
> : # Required for old initscripts < 4.16 or so (RHL5.2)
> : my_success() {
> : local msg
> : if [ $# -gt 1 ]; then
> : msg="$2"
> : else
> : msg="done"
> : fi
> : case "`type -type success`" in
>
> If you're going to go about things this way, why do you check whether
> 'success' is a function twice? Do it above, or here, but not both.
Well, I'm not sure which approach if preferable:
1) include sshd-functions for everyone
2) include sshd-functions for old os versions only
I think changes to newer systems to newer systems should be weeded off as
soon as possible, hence the checks in 30 first lines. Which to remove
depends on the approach.
> : # Required for old initscripts < 4.16 or so (RHL5.2)
> : my_action() {
> : STRING=$1
> : echo -n "$STRING "
> /^^^^^^^^^^^^^^^^^^^^
> /
> my_success() and my_failure() already echo their string . Why do you
> do it again here?
True.
> : 1.*)
> : echo ${args} "$@"
> /^^^^^^
> /
> This won't work at all they way you've done things. echo() is defined
> as my_echo(), which calls echo(), which calls ... ad finitum memoriae.
Changing to /bin/echo would fix this, not sure if that'd take advantage of
$".." locales though.
--
Pekka Savola "Tell me of difficulties surmounted,
Netcore Oy not those you stumble over and fall"
Systems. Networks. Security. -- Robert Jordan: A Crown of Swords
More information about the openssh-unix-dev
mailing list