Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Jan 1999 19:19:30 -0500 (EST)
From:      jwhite@cryogen.com
To:        root@swimsuit.internet.dk
Cc:        freebsd-isp@FreeBSD.ORG
Subject:   Re: dummy-pop3 server
Message-ID:  <199901252013.PAA16533@mcclane2.erols.com>
In-Reply-To: <Pine.BSF.4.05.9901260031590.3837-100000@gina.neland.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
#!/usr/bin/perl -Tw
require 5.003;
use strict;
use Socket;
use Carp;

sub spawn;  # forward declaration

my $port = 110;
my $proto = getprotobyname('tcp');
socket(Server, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("l", 1))
                                             or die "setsockopt: $!";
bind(Server, sockaddr_in($port, INADDR_ANY)) or die "bind: $!";
listen(Server,SOMAXCONN)                     or die "listen: $!";


my $waitedpid = 0;
my $paddr;

sub REAPER {
    $SIG{CHLD} = \&REAPER;  # if you don't have sigaction(2)
    $waitedpid = wait;
}

$SIG{CHLD} = \&REAPER;

for ( ; $paddr = accept(Client,Server); close Client) {
    my($port,$iaddr) = sockaddr_in($paddr);
    my $name = gethostbyaddr($iaddr,AF_INET);


    spawn sub {
        print "Hey dummy, we have moved the pop3-server; don't
use this ip-adress, use the name: mail.our.domain instead.\n";
    };

}
    
sub spawn {
    my $coderef = shift;

    unless (@_ == 0 && $coderef && ref($coderef) eq 'CODE') {
        confess "usage: spawn CODEREF";
    }
    
    my $pid;
    if (!defined($pid = fork)) {
        return;
    } elsif ($pid) {
        return; # i'm the parent
    }
    # else i'm the child -- go spawn
        
    open(STDIN,  "<&Client")    or die "can't dup client to stdin";
    open(STDOUT, ">&Client")    or die "can't dup client to stdout";
    ## open(STDERR, ">&STDOUT") or die "can't dup stdout to stderr";
    exit &$coderef();
}


#So I was bored :)



On 26 Jan, Leif Neland wrote:
> I'm looking for a dummy pop3-server, which can authorize anybody, and just
> send a single message: 'Hey dummy, we have moved the pop3-server; don't
> use this ip-adress, use the name: "mail.our.domain" instead.'
> 
> leif@neland.dk
> 
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-isp" in the body of the message
> 



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isp" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901252013.PAA16533>