Wrapper for constructing a privileged socket 
Author Message
 Wrapper for constructing a privileged socket

I want to write a wrapper, which builds a socket (in future on a privileged port)
and then starts a server. The server should get the opened socket from the
wrapper to communicate on it.
But the problem is:
When the wrapper starts the server with exec (I also tried system), the server
always gets a closed socket.
Here is the code:

The wrapper:
#!/usr/local/dist/bin/perl -w

require 5.002;
#use strict;
use Socket;
use Carp;

my ($rsockname,$rec, $proto, $pid);
local ($port, $socket);
my ($debug);

$port = shift || 2000;
$proto = getprotobyname('tcp');
socket(Server, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
setsockopt(Server, SOL_SOCKET, SO_KEEPALIVE, pack("l", 1)) ||
die "setsockopt $!";
bind(Server, sockaddr_in($port, INADDR_ANY)) || die "bind: $!";
if ($debug) { print ("Socket gebunden, rufe lcnd auf\n"); }
#print ("$socket\n");
#print ("$$socket\n");

The server:
#!/usr/local/dist/bin/perl -w

require 5.002;
#use strict;
use Socket;
use Carp;

my ($ok, $rsockname,$rec, $socket);
$ok = 200;
my ($debug);
print ("Server $ARGV[1]\n");

print ("port=$port, socket=$socket\n");

listen($socket,SOMAXCONN) || die "listen: $!";

the error message:
listen() on closed fd at ./lcnd1 line 20.
listen: Bad file number at ./lcnd1 line 20.



Sun, 05 Sep 1999 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Perl sockets with suid C wrapper

2. correctly dropping privileges

3. how to solve when no root privilege?

4. ora_login with SYSDBA privileges

5. administrator insufficient privileges

6. How to install a module without AD privilege??

7. write privilege for script.

8. Scripts with root privileges

9. NTPerl and privileges

10. need help with foreach construct and parsing of list

11. Question about %var construct

12. Using perl to construct Gopher ASK blocks


Powered by phpBB® Forum Software