BEGIN { $^W = 1; } use IO::Socket; use strict 'refs'; local $/ = "\r\n"; my $port = '7070'; my $root = '/home/beth/gopher/gopher'; die "can't chroot: $!\n" unless chroot $root; local $SIG{'HUP'} = 'IGNORE'; exit if my $pid = fork; die "Couldn't create socket: $!\n" unless my $sock = 'IO::Socket::INET'->new('LocalPort', $port, 'Type', SOCK_STREAM(), 'Listen', 1, 'Reuse', 1); my $s = $sock->accept; while (defined(my $req = <$s>)) { chomp(my $req = shift @ARGV); $req = '/' . $req; &error unless -r $req; $req .= '/.cache' if -d _; printfile($req); close $sock; } sub printfile { use strict 'refs'; open FILE, shift @_; binmode FILE; print $s ; close FILE; } sub error { use strict 'refs'; my $req = shift @_; print $s "iBad Request: $! \tfake\t(NULL)\t0" . $/; }