Hi.

I can reproduce this bug (using a kFreeBSD AMD64 in VirtualBox).

As noted, this bug does only happen when root access is gained using
sudo, because $SSH_CONNECTION is not passed to sudo's children. Using su
or logging directly as root works fine.

Unfortunately the patch suggested by Martin doesn't completely solve the
Linux-ism, because under kFreeBSD sshd apparently doesn't retain the TTY
name in the children it spawns:

> r...@bestiola:~# ps ax | grep sshd
>   911 ?        R+     0:00 grep sshd
>   862 ?        S      0:00 /usr/sbin/sshd -R
>   858 ?        Ss     0:00 /usr/sbin/sshd -R
>   468 ?        Ss     0:00 /usr/sbin/sshd

Thus the pgrep test always fails and isn't able to detect SSH
connections (unless $SSH_CONNECTION is set, that triggers the other test).

I don't know why, but ps seems to be unable to detect the running TTY of
a program (here, the TTY column is the one full of "?": the same happens
for the rest of processes in "ps ax"). One could rely on the fact that
"ps" (without arguments) displays the processes with the same TTY and
calling user and test if its output contains a sshd. It doesn't seem to
be the Right Way(tm), but it may work.

Thanks, Giovanni.
-- 
Giovanni Mascellani <mascell...@poisson.phc.unipi.it>
Pisa, Italy

Web: http://poisson.phc.unipi.it/~mascellani
Jabber: g.mascell...@jabber.org / giova...@elabor.homelinux.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to