head     1.2;
branch   ;
access   ;
symbols  ;
locks    ; strict;
comment  @# @;


1.2
date     93.07.28.00.50.41;  author www;  state Exp;
branches ;
next     1.1;

1.1
date     93.07.28.00.48.37;  author www;  state Exp;
branches ;
next     ;


desc
@Plexus as it comes with the 2.2.1 package
@


1.2
log
@Added local hacks (changed pathnames)
@
text
@#!/usr/local/bin/perl
# plexus -- the bind-stub for the HyperText Tranfer Protocol Daemon
#
# $Id: plexus,v 1.1 93/07/28 00:48:37 www Exp Locker: www $
#
# This does the critical root-stuff like binding to the port.
# Originally (httpd-stub.pl) by Marc VanHeyningen, March 1993
# Modified by Tony Sanders <sanders@@bsdi.com>, April 1993
#

($#ARGV >= $[) && ($port = shift);		# get port from command line

chdir($http_root = $ENV{'HTTPD'} || "/var/local/www/root")
    || die "chdir: $http_root: $!";
$http_config = $ENV{'HTTPD_CONF'} || "/var/local/www/plexus/src/plexus.conf";
require "$http_config";

$running_as_root = ($< == 0);
$port || ($port = ($running_as_root ? ((getservbyname($http_service,
    $http_proto))[2] || $http_defaultport) : $http_userport));

$proto = (getprotobyname('tcp'))[2] || $http_defaultproto;
$this = pack($sockaddr, &AF_INET, $port, "\0\0\0\0");

socket(S, &AF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
setsockopt(S, &SOL_SOCKET, &SO_REUSEADDR, pack("l", 1));	# non-critical
bind(S, $this) || die "bind: $!";
listen(S, &SOMAXCONN) || die "listen: $!";
select(S); $| = 1; select(STDOUT);

$http_chroot && $running_as_root &&
    (chroot($http_root) || die "chroot: $http_root: $!");

if($running_as_root) {
    $( = $) = (getgrnam("$http_group"))[2] || die "getgrnam: $http_group: $!";
    $< = $> = (getpwnam("$http_user"))[2] || die "getpwnam: $http_user: $!";
}

# exec the server main loop
exec "$http_server", $http_config, $port, $running_as_root, fileno(S);
die "$http_server: $!";
@


1.1
log
@Initial revision
@
text
@d1 1
a1 1
#!/usr/bin/perl
d4 1
a4 1
# $Id: plexus,v 2.3 1993/07/16 18:50:19 sanders Exp $
d13 1
a13 1
chdir($http_root = $ENV{'HTTPD'} || "/usr/local/www")
d15 1
a15 1
$http_config = $ENV{'HTTPD_CONF'} || "server/plexus.conf";
@
