Hi Monks,

Congratulations for your nice Web which I've used as reference several times. This is my first post.

I started to study perl around 3 months ago playing with basic stuff. While studying sockets in Perl, and as part of my "training" I played with dup2 system call to redirect file descritors like this (I used another piece of software as reference):

while (1) { my $client = $server->accept(); fcntl $client, F_SETFD, 0 or warn "$!"; die "can't fork: $!" unless defined( my $sspid = fork() ); if ( !$sspid ) { close($server); while ( defined( my $line = <$client> ) ) { if ( $line =~ /_exec_/i ) { POSIX::close(0); if ( defined( my $fd = fileno $client ) ) { POSIX::dup2( $fd, 0 ); POSIX::close($fd); POSIX::dup2( 0, 1 ); POSIX::dup2( 0, 2 ); eval { exec "/bin/bash" or warn "$!"; }; warn "TRAP : $@\n" if $@; } } else { print $client $line; } } close($client); exit 1; } }

Now I would like to do exactly the same but using SSL (Net::SSLeay, I've used CPAN SSLeay documentation as reference)

How can I redirect STDIN, STDOUT and STDERR to a socket using SSL? The idea is to execute commands remotely, just as in the previous example.

Thanks in advance and kind regards,
Ernesto

In reply to dup2 socket descriptor using SSL by Ernesto81

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.