PATCH: make contrib/redhat/sshd.init work with older RH releases

Jim Knoble jmknoble at jmknoble.cx
Sun Feb 18 05:34:59 EST 2001


Circa 2001-Feb-17 17:45:09 +0200 dixit Pekka Savola:

: Ok, here's my initial work.  I have yet to hear back from RH about my
: proposed modifications for their file, but I believe this shouldn't take
: too long.
: 
: A few highlights:
:  - $SSHD used (for path + name) instead of sshd
:  - supports RHL'isque i18n in a backward-compatible manner (echo $"...)

Bash-1.14.x doesn't handle the $"..." construct properly:

  $ /bin/bash
  $ echo $BASH_VERSION
  1.14.7(1)
  $ echo $"Generating SSH1 RSA host key: "
  $Generating SSH1 RSA host key: 
 ^^^
    \
     Note the spurious '$' character

If you want to use the $"..." construct, then using the following
function instead of plain 'echo' ought to work with both bash-1.14.7
and bash-2.x (so that this will work without modification under older
releases):

  my_echo() {
    local args=""
    while [ $# -gt 0 ]; do
      case "$1" in
        --)
	  break
	;;
        -*)
	  args="${args} $1"
	  shift
	;;
	*)
	  break
	;;
      esac
    done
    case "${BASH_VERSION}" in
      1.*)
        echo ${args} "$@"
      ;;
      *)
        echo ${args} $"$@"
      ;;
    esac
  }

:  - testing for keys clarified, -s used.
:  - start/stop functions used, also 'function' keyword for consistency

I think it would be better to call the start() and stop() functions by
more specific names to avoid potential namespace conflict.  Any of
these would be better (i myself prefer the second):

  - start_sshd, stop_sshd
  - sshd_start, sshd_stop
  - start_ssh, stop_ssh
  - ssh_start, ssh_stop


In fact, i would suggest prefixing all function names defined here with
'sshd_' or 'ssh_'.

Also, if you're going to use the 'function' keyword, then please don't
use parentheses:

  $ echo $BASH_VERSION
  1.14.7(1)
  $ help function |head -1
  function: function NAME { COMMANDS ; } or NAME () { COMMANDS ; }
  $ /bin/bash2
  $ echo $BASH_VERSION
  2.03.8(1)-release
  $ help function |head -1
  function: function NAME { COMMANDS ; } or NAME () { COMMANDS ; }
  $ 
	    
Using both is bad syntax, even though bash doesn't complain.

:  - if [ ! -f $PID_FILE ] check removed.
: [This might be a bit controversial, but IMO it doesn't make much
: sense for stop, and start exits with errorlevel 0 if it's already running
: anyway]

This is fine; sshd Does The Right Thing(R) when somebody is already
bound to the relevant address+port, and it's possible for the PID file
to disappear due to filesystem problems or operator error, so it's an
unreliable indicator that sshd is or isn't running.

:  - add reload (does HUP)
: 
: Comments are welcome, of course.

It's a good thing.  :)  Good work, Pekka.

-- 
jim knoble | jmknoble at jmknoble.cx | http://www.jmknoble.cx/





More information about the openssh-unix-dev mailing list