Retrieving remote host and user from Perl login shell. 
Author Message
 Retrieving remote host and user from Perl login shell.

Keywords:

< Warning newbie post...>

 Hi,

    I setup a Perl login shell on my HP-UX system to parse a text file and
return results via rexec.   It seems to work fine (I think that I finally figured
out eval.)   Now I would like to log the remote user and remote host to a file.
The man pages say that inetd calls rexecd which establishes the connection,
authenticates the user and passes the socket on to the login shell.  Is there
any way to look back up the socket to see where it came from?   I tried some of
the getxxxxx  perl functions but I guess that I didn't hit the right combination.
Any help ( or a pointer to a good book on the subject) would be greatly
appreciated.

Thank you.

--
================================================================================

Todd Beverly     Kodak Research Labs

The above opinions are mine.

================================================================================



Sat, 15 Mar 1997 21:12:40 GMT  
 Retrieving remote host and user from Perl login shell.
|>     I setup a Perl login shell on my HP-UX system to parse a text file and
|> return results via rexec.   It seems to work fine (I think that I finally figured
|> out eval.)   Now I would like to log the remote user and remote host to a file.
|> The man pages say that inetd calls rexecd which establishes the connection,
|> authenticates the user and passes the socket on to the login shell.  Is there
|> any way to look back up the socket to see where it came from?   I tried some of
|> the getxxxxx  perl functions but I guess that I didn't hit the right combination.
|> Any help ( or a pointer to a good book on the subject) would be greatly
|> appreciated.

This might point you in the right direction:

#! /bin/perl

# Sets the DISPLAY variable when backquoted within a file which gets sourced
# via rsh or rexec, e.g.
#    set $setdisp = `setdisplay.pl`
#    $setdisp

# Mostly written by Spencer Thomas with a wee bit of help by Jeff Aspinall

$sockaddr='S n a4 ';
$hersockaddr=getpeername(STDIN) ;

print "setenv DISPLAY $addr[0].$addr[1].$addr[2].$addr[3]:0\n";

# End

--

Informatics Core -+- Human Genome Center -+- University of Michigan, Ann Arbor



Mon, 17 Mar 1997 01:01:20 GMT  
 Retrieving remote host and user from Perl login shell.

Quote:

>    I setup a Perl login shell on my HP-UX system to parse a text file and
>return results via rexec.   It seems to work fine (I think that I finally figured
>out eval.)   Now I would like to log the remote user and remote host to a file.
>The man pages say that inetd calls rexecd which establishes the connection,
>authenticates the user and passes the socket on to the login shell.  Is there
>any way to look back up the socket to see where it came from?   I tried some of
>the getxxxxx  perl functions but I guess that I didn't hit the right combination.
>Any help ( or a pointer to a good book on the subject) would be greatly
>appreciated.

#!/usr/bin/perl

use Socket;

if (defined ($sockaddr = getpeername (STDIN)))
{
  $theirAddress = (unpack ('S n a4 x8', getpeername (STDIN)))[2];
  $theirName = (gethostbyaddr ($theirAddress, AF_INET))[0];

  print "Their name is $theirName\n";

Quote:
}

else
{
  print "Stdin doesn't look like a socket to me\n";

Quote:
}

When this is run locally & remotely this is what happens (on a Sun):


Stdin doesn't look like a socket to me

Their name is hibbert

If you're using perl 4 then the line

  use Socket;

should be

  require 'sys/socket.ph'

and you need an & before the AF_INET.

Hope this helps,

Mike

--
The "usual disclaimers" apply.    | Meiko
Mike Stok                         | 130C Baker Ave. Ext

Meiko tel: (508) 371 0088 x124    |



Sun, 16 Mar 1997 18:40:15 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. NOVICE: Perl and retrieving info from remote host

2. inetd: remote host/user identification

3. Expect PERL: execute command on remote host and play with its output

4. Perl security as login shell

5. perl as login shell

6. LWP: How do I retrieve a page that requires login + passwd

7. perl as a login shell

8. Perl as login shell?

9. Perl script as login shell?

10. Retrieving mail from host

11. Need Perl User Login Source code

12. Perl user login source needed

 

 
Powered by phpBB® Forum Software