karl@spruce.gsfc.nasa.gov (karl anderson) (06/13/91)
I'm just getting acquainted with SGI machines after using Suns alot. I see that when I rlogin to one of our Irises, an environment variable named "REMOTEHOST" is set to the name of the machine I'm logging in from. Is this something unique to IRIX? I'd love to be able to do that on my Suns - can anyone tell me how? Please answer by email, as I don't ordinarily take this group. TIA. -- Karl A. Anderson | Internet: karl@forest.gsfc.nasa.gov NASA/GSFC code 923 (STX) | voice: (301) 286-3815 Greenbelt, MD 20771 | #include "std_disclaimer"
ajd@cs.mu.OZ.AU (Ashley Dreier) (06/13/91)
karl@spruce.gsfc.nasa.gov (karl anderson) writes: >I'm just getting acquainted with SGI machines after using Suns alot. >I see that when I rlogin to one of our Irises, an environment variable >named "REMOTEHOST" is set to the name of the machine I'm logging in >from. Is this something unique to IRIX? I'd love to be able to do >that on my Suns - can anyone tell me how? Please answer by email, >as I don't ordinarily take this group. TIA. >-- >Karl A. Anderson | Internet: karl@forest.gsfc.nasa.gov >NASA/GSFC code 923 (STX) | voice: (301) 286-3815 >Greenbelt, MD 20771 | #include "std_disclaimer" I'd like to know that too... It's very helpful when trying to run X-windows applications remotely. Presently I'm using a combination of 'finger', 'awk' and 'tty' to work out where I logged in from in order to set my DISPLAY variable. Either email or post. I'm not fussy. Ash (ajd@cs.mu.OZ.AU)
rpw3@rigden.wpd.sgi.com (Rob Warnock) (06/14/91)
In article <1991Jun12.174725@spruce.gsfc.nasa.gov> karl@spruce.gsfc.nasa.gov (karl anderson) writes: +--------------- | I'm just getting acquainted with SGI machines after using Suns alot. | I see that when I rlogin to one of our Irises, an environment variable | named "REMOTEHOST" is set to the name of the machine I'm logging in | from. Is this something unique to IRIX? +--------------- Sorry, yes, as far as I know. +--------------- | I'd love to be able to do that on my Suns - can anyone tell me how? +--------------- It's done in "rlogind", if you feel energetic enough to go get Berkeley "rlogind" source from UUNET (or your favorite archive), (re)invent the changes [hint: use getpeername()], and make it run on your Suns. -Rob p.s. We also define the "REMOTEUSER" variable, as well. ----- Rob Warnock, MS-1L/515 rpw3@sgi.com rpw3@pei.com Silicon Graphics, Inc. (415)335-1673 Protocol Engines, Inc. 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311
bernie@umbc3.umbc.edu (Bernard J. Duffy) (06/22/91)
In article <1991Jun12.174725@spruce.gsfc.nasa.gov> karl@spruce.gsfc.nasa.gov (karl anderson) writes: >I'm just getting acquainted with SGI machines after using Suns alot. >I see that when I rlogin to one of our Irises, an environment variable >named "REMOTEHOST" is set to the name of the machine I'm logging in >from. Is this something unique to IRIX? I'd love to be able to do >that on my Suns - can anyone tell me how? Please answer by email, >as I don't ordinarily take this group. TIA. You can make a simple C program that could set this for you and it would be pretty easy to port to most of your un*x-es . I've noticed that the who command on most machines states which host a terminal or X session started a particular login. I think most of the "login" (like rlogin and telnet) programs / daemons provide this information. The informat for the REMOTEHOST is held in the world readable /etc/utmp that the who utility reads for you. Your non-suid (non-prived) program can scan /etc/utmp and extract the REMOTEHOST. This would be of use to X users because you can make various terminal settings based on the originating host (like ^? for DEL when it's not a window on an IRIS server). > >-- >Karl A. Anderson | Internet: karl@forest.gsfc.nasa.gov >NASA/GSFC code 923 (STX) | voice: (301) 286-3815 >Greenbelt, MD 20771 | #include "std_disclaimer" Have fun, Bernie bernie@pinhead.acs.umbc.edu UMBC: the only University with "County" in its name... that's why they want to change it. MD has lots of schools and very few big cities. -- Bernie Duffy Systems Programmer II | Bitnet : BERNIE@UMBC2 Academic Computing Services - L005e | Internet : BERNIE@UMBC2.UMBC.EDU Univ. of Maryland Baltimore County | UUCP : ...!uunet!umbc3!bernie Baltimore, MD 21228 (U.S.A.) | W: (301) 455-3231 H: (301) 744-2954
rpw3@rigden.wpd.sgi.com (Rob Warnock) (06/22/91)
In article <1991Jun21.173050.9868@umbc3.umbc.edu> bernie@umbc3.umbc.edu (Bernard J. Duffy) writes: +--------------- | karl@spruce.gsfc.nasa.gov (karl anderson) writes: | >I see that when I rlogin to one of our Irises, an environment variable | >named "REMOTEHOST" is set to the name of the machine I'm logging in from. | >I'd love to be able to do that on my Suns - can anyone tell me how? | >as I don't ordinarily take this group. TIA. | You can make a simple C program that could set this for you... | The informat for the REMOTEHOST is held in the world readable /etc/utmp | that the who utility reads for you. Your non-suid (non-prived) program | can scan /etc/utmp and extract the REMOTEHOST. This would be of use | to X users because you can make various terminal settings based on | the originating host... +--------------- Problems with this: 1. The remote-host field in utmp is only 16 characters, not enough to hold a long fully-qualified domain name. This means that you can't reliably use the utmp info to set the $DISPLAY variable (which is one of the most useful things about $REMOTEHOST). 2. Not all Unices provide the (remote) "host" field in utmp. Sun does. SGI *doesn't*! [...but we have $REMOTEHHOST] 3. Few (no?) Unices provide utmp entries for "rsh" jobs. Yet many X apps are run via "rsh". 4. Both the utmp hack and the $REMOTEHOST hack fail on more than one hop. That is, if from host "A" you rlogin to host "B", and from there you rlogin/rsh to host "C", the utmp/$REMOTEHOST you see on "C" will point back to "B". But odds are your X terminal is "A". Oops! As far as I can tell, the *only* thing which works reliably across multiple hops and multiple system types is (1) for rlogin, encoding the DISPLAY into the $term variable (e.g. "set term=rigden.wpd.sgi.com:vt100"), which *is* propagated by rlogin, setting DISPLAY in your .login file from the $term, and (2) *always* provide "-display $DISPLAY" on rsh'd commands. [Yes, the mechanisms for rlogin and rsh are *different*!] Only in this way does $DISPLAY consistently point back to your real display (instead of some intermediate black hole). And the trouble with my (1) is that it requires that the .login file on *every* machine you rlogin to have the $term-cracking-$DISPLAY-setting code. This makes it hard to have "generic" open guest accounts, unless all the guest accounts' .logins have the common $term-cracking hack. -Rob ----- Rob Warnock, MS-1L/515 rpw3@sgi.com rpw3@pei.com Silicon Graphics, Inc. (415)335-1673 Protocol Engines, Inc. 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311
bernie@umbc3.umbc.edu (Bernard J. Duffy) (06/22/91)
In article <1991Jun21.173050.9868@umbc3.umbc.edu> bernie@umbc3.umbc.edu (Bernard J. Duffy) writes: >In article <1991Jun12.174725@spruce.gsfc.nasa.gov> karl@spruce.gsfc.nasa.gov (karl anderson) writes: >>I'm just getting acquainted with SGI machines after using Suns alot. >>I see that when I rlogin to one of our Irises, an environment variable >>named "REMOTEHOST" is set to the name of the machine I'm logging in >>from. Is this something unique to IRIX? I'd love to be able to do >>that on my Suns - can anyone tell me how? Please answer by email, >>as I don't ordinarily take this group. TIA. > You can make a simple C program that could set this for you and >it would be pretty easy to port to most of your un*x-es . ... Well I had this question around here lately ... so I wrote some code and lucky for you, this works just fine for SUNs. It only seems to work on BSD related systems like DECs and SUNs (I don't have any other BSD systems). HP-UX has the ut_host (remote host info), but they (the kernal/ login) don't fill in the information. Stardent (Titan P3)'s /etc/utmp is not cleanly layed out... the have multiple records for the same tty and they don't fill the ut_host entry with x-terms sessions (started via rsh). >The information for the REMOTEHOST is held in the world readable /etc/utmp >that the who utility reads for you. Your non-suid (non-prived) program >can scan /etc/utmp and extract the REMOTEHOST. This would be of use ... so here that code: /* remote_host.c - author: Bernie Duffy date: 6/21/91 cut / paste abuse code at will ... you can even remove this comment section if that saves you some disk space. :-) */ #include <stdio.h> #include <sys/types.h> /* needed for HP-UX */ #include <utmp.h> /* utmp struct */ main() { char tty_name[20]; int index; FILE *utmp_file; struct utmp user_entry; utmp_file = fopen("/etc/utmp", "r"); strcat (tty_name, ttyname(0)); /* only need the end part tty... */ index = strlen(tty_name); while (--index) if (tty_name[index] == '/') break; index++; while (fread((char *)&user_entry, sizeof(user_entry), 1, utmp_file) == 1) if (strcmp (&tty_name[index], user_entry.ut_line) == 0) { printf("user = %-10s REMOTEHOST = %s\n", user_entry.ut_name, user_entry.ut_host); break; } fclose (utmp_file); } Have fun, Bernie bernie@pinhead.acs.umbc.edu UMBC: the only University with "County" in its name... that's why they want to change it. MD has lots of schools and very few big cities. -- Bernie Duffy Systems Programmer II | Bitnet : BERNIE@UMBC2 Academic Computing Services - L005e | Internet : BERNIE@UMBC2.UMBC.EDU Univ. of Maryland Baltimore County | UUCP : ...!uunet!umbc3!bernie Baltimore, MD 21228 (U.S.A.) | W: (301) 455-3231 H: (301) 744-2954