Re: Detecting whether a session is locally or remotely log ged in
Brendon Oliver <[email protected]>
| Newsgroups | gmane.org.user-groups.mlug.main |
|---|---|
| Message-ID | <[email protected]> |
On Friday 26 August 2005 12:10, Tony Langdon (ATC) wrote:
> > Are you trying to determine this from within the shell session or
> > by looking at it from the outside?
>
> Within the session
>
> > If you're doing it from within the shell, then ssh usually sets a
> > few env variables which might be helpful. eg. SSH_CLIENT,
> > SSH_CONNECTION,
> > SSH_TTY. There might be others too... Obviously, they won't be
> > present if the shell is local to the system.
>
> I saw those. Thay might cover the cases I need to deal with, though
> there is a small probability of remote X sessions (which I also want
> the script to avoid)...
In those cases, will the DISPLAY value help? I'd have thought you would
be able to tell the difference that way:
:0 = local
localhost:0 = local
foo.domain.com:N = local (regardless of 'N') if machine is really
foo.domain.com
anything.else.com:N = remote display
If you're doing X over ssh, then when forwarding X connections, I think
sshd controls which offset to start display numbering, so maybe parse
$DISPLAY & work from there.
Cheers,
- Brendon.
--
_________________________________________
/ The solution of this problem is trivial \
| and is left as an exercise for the |
\ reader. /
-----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||