Friday, October 14, 2005

Solaris 9 sshd / ssh exit codes

Solaris 9 sshd / ssh exit codes

On Solaris 9, with the latest ssh/sshd patches installed ...

114356-03: SunOS 5.9: /usr/bin/ssh Patch
113273-06: SunOS 5.9: /usr/lib/ssh/sshd Patch

... why is there inconsistent behaviour with ssh exit codes? Why are
there sporadic exit codes of 0 from the following ssh command?

% repeat 100 sh -c 'ssh -n localhost "exit 33" ; echo $?'
33
33
33
33
33
33
33
33
33
33
33
33
33
33
33
33
33
33
33
33
33
0
33
33
33
33
33
0
0
0
0
33
33
33
33
33
33
33
33
33
33
33
^Z
Suspended

Juergen Keil <j...@tools.de> writes:
>On Solaris 9, with the latest ssh/sshd patches installed ...
> 114356-03: SunOS 5.9: /usr/bin/ssh Patch
> 113273-06: SunOS 5.9: /usr/lib/ssh/sshd Patch
>... why is there inconsistent behaviour with ssh exit codes? Why are
>there sporadic exit codes of 0 from the following ssh command?

It's a bug which is being addressed.

(There's a race condition between processes exiting and stdin/stdout
being closed, so sshd can close the connection before it has seen
the exit status)

Casper

>>... why is there inconsistent behaviour with ssh exit codes? Why are
>>there sporadic exit codes of 0 from the following ssh command?

> It's a bug which is being addressed.

> (There's a race condition between processes exiting and stdin/stdout
> being closed, so sshd can close the connection before it has seen
> the exit status)

Is that the same bug that causes my CVS over ssh sessions to hang?

Dragan

-
>0
>33
>33
>^Z
>Suspended

Obviously your "localhost" is round-robin DNS to hosts with different
definitions of "exit" ! Have you had a visit from my SAs ?

Is it more informative to do "uname ; exit 33" to let you see
whether the remote command got run ?

>Is that the same bug that causes my CVS over ssh sessions to hang?

It happens mostly on Linux clients.... Here is what I do for my Star
backup script:

_cmd=` eval echo "$STAR -cM -time f=$RTAPE VOLHDR= $host:$i
$STAR_ARGS $STAR_EXTRA -C $i . \; r=\$\? \; sleep 10 \; exit \$\r"`
ssh -q "$host" -l root "$_cmd"
excode=$?
if [ $excode -ne 0 ]; then
echo "----> EXICODE: $excode for $host:$i"
fi

0 Comments:

Post a Comment

<< Home