Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Writing an rsh client (Moved from Q&A)

by Russ (Deacon)
on Aug 26, 2000 at 10:08 UTC ( [id://29792]=perlquestion: print w/replies, xml ) Need Help??

Russ has asked for the wisdom of the Perl Monks concerning the following question:

This question was moved from Categorized Questions and Answers
Please do not vote for this node. It will affect the wrong user.
Thank You -- Q&AEditors

I'm trying to write an rsh client (long story) and can't seem to get it working. Basically I'm using IO::Socket and am trying to connect to an AIX system. What I'm really looking to do is trying to specify the return port on the connection.

use IO::Socket; $new = IO::Socket::INET->new(PeerAddr=>"$aix", PeerPort=>"514", Proto= +>"tcp"); print $new "$localuser.$remoteuser.$command"; while (<$new>) { print; } close $new;
I believe the above syntax is correct because I'm actually getting back an error from the remshd. After reading the man pages on remshd I've discovered that the first check it does is on the source port of the request. It checks to make sure that the source port is 1023 or lower (makes no sense to me why). I've read through the Socket docs and the IO::Socket docs and didn't see any reference on how to specify the source port (ran sniffer and saw that all my requests were made with a source port of >2000). If anyone has any info on how to do this or if there's a module or even if this has been written already I would really appreciate any pointers.

Thanks,
Blue

Replies are listed 'Best First'.
Re (tilly) 1: Writing an rsh client (Moved from Q&A)
by tilly (Archbishop) on Aug 26, 2000 at 10:23 UTC
    The reason for the check on port number is that generally any user can choose a high port number, but below 1024 is reserved to root. So if you come from a low port you at least have special permisions.

    Incidentally this is why many standard protocols are below 1024. For instance ftp on 21, http on 80, imap3 on 220, https on 443 and so on. (On many *nix systems you can look at /etc/services to find these numbers - I certainly cannot recite these off of the top of my head! :-)

      Beware though: this is a false sense of security if you trust this. Nowadays, anyone can throw a Linux/BSD box on the net, and be "root". And PCs never had this lame "restriction" (after all, you are "root" in DOS).

      Also, the numbering works like so:

      • Ports below 1000 are reserved to root
      • Ports above 1023 were given to users
      • Ports between 1000 and 1023 are ambiguous
      Why the gap? Because the RFC said "1K", and different manufacturers implemented it differently! Some presumed 1000, others presumed 1024. Amazing, huh?

      -- Randal L. Schwartz, Perl hacker

RE: Writing an rsh client (Moved from Q&A)
by merlyn (Sage) on Aug 26, 2000 at 16:55 UTC
    Well, a quick glance at perldoc IO::Socket::INET told me rather directly:
    In addition to the key-value pairs accepted by the IO::Socket manpage, IO::Socket::INET provides. PeerAddr Remote host address <hostname>[:<p +ort>] PeerHost Synonym for PeerAddr PeerPort Remote port or service <service>[(<no +>)] | <no> LocalAddr Local host bind address hostname[:port +] LocalHost Synonym for LocalAddr LocalPort Local host bind port <service>[(<no +>)] | <no> Proto Protocol name (or number) "tcp" | "udp" +| ... Type Socket type SOCK_STREAM | +SOCK_DGRAM | ... Listen Queue size for listen Reuse Set SO_REUSEADDR before binding Timeout Timeout value for various operations MultiHomed Try all adresses for multi-homed hosts
    See LocalPort there? That's your baby. LocalPort => 998, for example.

    So, there's your answer in black and white.

    However, be sure to see my other post on this on why this is a false sense of security.

    -- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://29792]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 06:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found