SUMMARY 2 (better) rsh, which host is calling me ?

From: Thomas Bleek (bl@gfz-potsdam.de)
Date: Tue Oct 18 1994 - 19:52:44 CDT


Hi, Managers!
I have to post a 2nd summary. The echo to the summary was very
much better in quality and quantity. I assume, many people are only
reading mails with summaries 8-).

The best way for me is to use getpeername in a little c-program.
See the mail from Harish below.
Other suggested perl-scripts.
I have only included the c-source, I will use. If anybody wants to get
the whole stuff, please send me a mail, lets save resources!
Thanxs to all below, Thomas
BTW: Sun-Managers ist the most helpful list I know !
ruupoe@thijssen.nl (Ruud van Poelgeest)
don@mars.dgrc.doc.ca (Donald McLachlan)
Jose.Montilla@gain.com (Joey R. Montilla)
vc@glass.geol.lsu.edu (Venkat Chalasani)
"Henry Katz" <hkatz@lehman.com>
Veselin Terzic <terzic@deneb.mda.ca>
Mic Kaczmarczik <mic@uts.cc.utexas.edu>
barmar@near.net
Juergen Wagner <gandalf@Csli.Stanford.EDU>
sysadmin@odetics.com (System Administrator - David Rossman)
Bryan Curnutt <curnutt@Stoner.COM>
Harish Malneedi <harishm@pcsdnfs1.eq.gs.com>
Guy Polis <polis_guy@jpmorgan.com>
perryh@pluto.rain.com (Perry Hutchison)
bec@pri-z.cv.com (Juergen Becker)

From: Harish Malneedi <harishm@pcsdnfs1.eq.gs.com>
Subject: Re: SUMMARY: rsh, which host is calling me ?
In-Reply-To: bl@gfz-potsdam.de (Thomas Bleek)
 "SUMMARY: rsh, which host is calling me ?" (Oct 17, 10:52am)
To: bl@gfz-potsdam.de (Thomas Bleek)

Thomas,

A small 'c ' code which i am appending to my mail might help you out.
We use this executable to bascially set the display variable for a PC
from which an unix application is invoked via rsh/rexec.

This executable "whoru", figures out which PC is calling it and
based on the IPAddress/hostname, which it derives, sets the DISPLAY variable.
This works only for PC's and not workstations (we didn't had the time
to get to that part yet) may be you can hack the script on those lines
and come up with what you want.
Good Luck.

HarisH
===========================<< CUT HERE >>===========================

/* Program : WHO aRe yoU?
 * Date : 23-Aug-1994
 * Desc :
 * Designed to provide the remote
 * host IP address during an RSH or
 * REXEC. Used for eXceed and PC's
 */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>

main()
{
   struct sockaddr n;
   struct sockaddr_in *addr;
   int len, x;
   char *inet_ntoa();

   for( x = 0; x <= 2; x++ )
   {
      len = sizeof( struct sockaddr );
      if( getpeername( x, &n, &len ) == 0 )
      {
         addr = (struct sockaddr_in *)&n;
         printf( "%s", inet_ntoa( addr->sin_addr ) );
         break;
       }
     }
}
===========================<< CUT HERE >>===========================



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:09:12 CDT