SUMMARY: Propagating $DISPLAY through rlogin ....

From: Thomas Leitner <tom_at_finwds01.tu-graz.ac.at>
Date: Wed, 26 Nov 1997 16:44:59 +0100 (MET)

Hi,

Well: This seems to be a quite common problem as I got a lot of
suggestions. They can be summarized like this:

  1.) use ssh (http://www.cs.hut.fi/ssh) rather than rlogin
  2.) use a wrapper which packs DISPLAY into TERM and
      unpacks it at the remote site in the .login file of the user
  3.) use REMOTEHOST of tcsh (which is what I already do but
      this doesn't work in the X-Term case)
  4.) use a .DISPLAY file in the user's home directory to convey
      the DISPLAY variable (this assumes an NFS mounted home
      directory, of course).

I think I'll go for the TERM variable wrapper script as I've already
got a centralized .cshrc for all users and a centralized rlogin script.
So all I need to do is to modify these two scripts like suggested below
to get it going.

Thanks a lot to: Wesley Darlington <w.darlington_at_am.qub.ac.uk>
                 "John P.Speno" <speno_at_isc.upenn.edu>
                 Kazuro FURUKAWA <kazuro.furukawa_at_kek.jp>
                 Jim Belonis <belonis_at_dirac.phys.washington.edu>
                 Frank Gallacher <franx_at_oas.telstra.com.au>
                 Peter Stern <peter_at_wiscpa.weizmann.ac.il>
                 Stefan Albert <Albert_at_staedtler.de>
                 Harald <hl_at_tekla.fi>
                 Simon Tardell <Simon.Tardell_at_physto.se>
                 Dejan Muhamedagic <dejan_at_yunix.com>
                 Knut Hellebø <Knut.Hellebo_at_nho.hydro.com>

Here are their answers as well as my original posting quoted in
the first answer:

-----------------------------------------------------------------------
From: Wesley Darlington <w.darlington_at_am.qub.ac.uk>

Hi Tom,

I don't have an answer, I'm afraid. No doubt others will
provide you with an elegant solution.

However, I get around the problem by using ssh all the
time. It does this automatically, but more as a side-effect
of what it does very well, namely secure you from packet
sniffing and session hijacking; It encrypts all your
telnet and X11 traffic.

-----------------------------------------------------------------------
From: "John P.Speno" <speno_at_isc.upenn.edu>

> Short question: When I telnet from my alpha to a sun (and to other

Short answer: Use ssh instead of rlogin. :-)

        http://www.cs.hut.fi/ssh
-----------------------------------------------------------------------
From: Kazuro FURUKAWA <kazuro.furukawa_at_kek.jp>

How about passing DISPLAY in TERM env? TERM is passed both on
telnet and rlogin. Thus you can

telnet/rlogin script
 if $DISPLAY == (localhost|unix|""):* setenv DISPLAY `hostname`:*
 setenv TERM $TERM%$DISPLAY
 telnet/rlogin remote

remote .cshrc/.profile
 if $TERM == *%* then
  setenv DISPLAY "second part of $TERM"
  setenv TERM "first part of $TERM"

some day rlogin also may transfer DISPLAY...

-----------------------------------------------------------------------
From: Jim Belonis <belonis_at_dirac.phys.washington.edu>

The only known way is to bundle the DISPLAY environment variable in with a
variable that IS propagated by rlogin. Namely TERM.

We used to do this.

On the originating machine, just before you rlogin, you
setenv TERM ${TERM}.${DISPAY}
or something similar, e.g. in a replacement alias or script for rlogin.
Then the replacement alias or script should clean up when rlogin is done
by fixing TERM again if the originating end has been mangled.
Dot is used as the separator since it is unlikely to be a TERM character
and can be automatically parsed as if it were part of a filename
by the 'History Substitution' modifiers in c-shell.

Then during the .cshrc (or other 'dot' file) on the destination machine,
you dis-entangle it with something like
if ( $?term ) then
    set disp = $term:e # undo merged TERM & DISPLAY variables
    set temp = $term:r

    if ( $disp != "" ) then
        while ( $temp:e != "" )
            set disp = $temp:e.$disp
            set temp = $temp:r
        end
        set term = $temp
        setenv DISPLAY $disp
        unset disp temp
    endif
endif

-----------------------------------------------------------------------
From: franx_at_oas.telstra.com.au

Tom,

This gets a bit messy, but I have stuff like this in my .login:


        set WHO = `who am i`
        set TTY = `echo ${WHO[2]}|sed s/tty//`
        setenv REMOTE `w|fgrep " ${TTY} "|tr -s " " " "|cut -f3 -d\ `
        setenv DISPLAY ":0"

        if("${REMOTE}" == "localhost") goto quit

        #
        # If IP address in valid Class B, Class C , multicast range,
        # use it; otherwise use default..
        # Nb. Fuzzy logic bit!?
        #
        set IP = `echo ${REMOTE}|tr "." " "|tr ":" " "`
        if ( `echo ${IP[1]}|egrep '^[0-9]*$'` != "" ) then
                _at_ FIRSTOCTET = ${IP[1]}
                if(${FIRSTOCTET} < 128 \
                        || ${FIRSTOCTET} >= 255) setenv REMOTE "172.74.10.77"
                else
                        setenv REMOTE "${IP[1]}"
                endif
                setenv DISPLAY "${REMOTE}:0.0"
        endif

        # X Setup..

        # Set Pattern for Root Window...

        xsetroot -bitmap /usr/include/X11/bitmaps/dimple1 >& /dev/null

        if (! ${status} ) then

        # Merge resources:

                xrdb -merge ${HOME}/.Xresources
                ...

                etc.


If you have a better way of doing this, please could you let me know; sometimes the thing
bombs out and just sets $REMOTE to the IP address of my dear little PC..

Even worse, here is the VMS (yuk!) equivalent bit of my LOGIN.COM:

        $ REMOTEPORT = F$GETDVI("SYS$COMMAND", "TT_ACCPORNAM")
        $ REMOTE = F$EDIT(F$EXTRACT(5,F$LOCATE("Port:",REMOTEPORT)-5,-
          REMOTEPORT),"COLLAPSE")
        $ REMOTE_IPADDR :== "''REMOTE'"
        $ SET DISPLAY /CREATE /NODE="''REMOTE_IPADDR'" /TRANSPORT=TCPIP
        $ SHOW SYMBOL REMOTE_IPADDR

Hope this is helpful, fcG.

-----------------------------------------------------------------------
From: Peter Stern <peter_at_wiscpa.weizmann.ac.il>

Hi:

I know that there are other solutions, but this is what I do. In my
.cshrc file I have the following lines:
  if (! $?DISPLAY) then
        setenv DISPLAY `who -mM | awk '{print substr($6,2,length($6)-2)}'`:0.0
  endif

This, unfortunately, does not work on all versions of unix. But things
that work on them, don't work on DU, e.g.
setenv DISPLAY ${REMOTEHOST}:0.0

Hope this helps a bit.

Peter

-----------------------------------------------------------------------
From: Stefan Albert <Albert_at_staedtler.de>

Servus Tom,

das gleiche Problem hatte ich auch...

ich habe das wie folgt gelöst:

ich erzeuge per rsh eine Datei (.DISPLAY) auf dem Zielrechner, die
mein Display angibt. Das wird dann von .login ausgewertet.

Andererseits kann man auch über whoami rauskriegen, "woher" man kommt.
Das ist jedoch systemspezifisch.

Wenn Du da weitere Infos brauchst, sag mir bescheid.
Ich kann Dir auch meine Dateien schicken, die das alles machen...

stefan

---------------------------------

Translation: He basically suggests to create a .DISPLAY file containing
the DISPLAY variable on the target machine using rsh and then process
it in the .login file of the user.

-----------------------------------------------------------------------
From: hl_at_tekla.fi

I made a script called 'rxterm' which starts a remote xterm keeping
things like DISPLAY, CWD etc. A slight variation is 'rstart' which
starts any X client on a remote machine. There is also a thing called
xon which does about the same. But my script even works agains
VMS...

--harald
-----------------------------------------------------------------------
From: Simon Tardell <Simon.Tardell_at_physto.se>

There is a script that does something like that for rsh, called xrsh, I
believe it should be in the contrib directory of the X11 distribution
(otherwise I can mail you a copy). It also takes care of xauth stuff, if you
don't share home directories between the local and remote host (and, if you
use xauth style authentication).

-----------------------------------------------------------------------
From: Dejan Muhamedagic <dejan_at_yunix.com>

Hi,

No, rlogin does not have mechanism to transfer env variables. The only
way is to try tweaking .profile on the destination machine and setting
DISPLAY var accordingly after you login.

Cheers.

-----------------------------------------------------------------------
From: Knut Hellebø <Knut.Hellebo_at_nho.hydro.com>

Regards,

I think there are some nice little wrappers floating around the net
(unfortunately I don't remember where) that wraps DISPLAY,TERM etc into
one,single variable which is unwrapped on the other side. This, however,
require that the wrapper is installed in both ends (in e.g.
/local/bin/rsh and let /local/bin precede /usr/bin in your users PATH)

I know that tcsh have the REMOTEHOST env variable possibility but this
is not sufficient in the X-term case.

Good Luck ;-)

--------------------------------------------------------------------------
T o m L e i t n e r Dept. of Communications
                                            Graz University of Technology,
e-mail : tom_at_finwds01.tu-graz.ac.at Inffeldgasse 12
Phone : +43-316-873-7455 A-8010 Graz / Austria / Europe
Fax : +43-316-463-697
Home page : http://wiis.tu-graz.ac.at/people/tom.html
PGP public key on : ftp://wiis.tu-graz.ac.at/pgp-keys/tom.asc or send
mail with subject "get Thomas Leitner" to pgp-public-keys_at_keys.pgp.net
--------------------------------------------------------------------------
    Before we have the paperless office, we have the paperless toilet!
Received on Wed Nov 26 1997 - 17:24:31 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:37 NZDT