#!/usr/local/bin/perl # Starts the flash policy server on port 843, then outputs an HTML page that # references the flash object BEGIN { push(@INC, ".."); }; use WebminCore; use Socket; &init_config(); &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1); # Work out host and port $host = $ENV{'HTTP_HOST'}; $host =~ s/\:\d+$//; $telnetport = $config{'telnetport'} || 23; # Check for telnet &open_socket($host, $telnetport, TEST, \$err); $err && &error(&text('index_etelnet', $telnetport)); close(TEST); # Start the policy file server on port 843 $port = 843; $proto = getprotobyname('tcp'); socket(MAIN, PF_INET, SOCK_STREAM, $proto) || &error(&text('index_esocket', "$!")); setsockopt(MAIN, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)); bind(MAIN, sockaddr_in($port, INADDR_ANY)) || &error(&text('index_eport', $port)); listen(MAIN, SOMAXCONN); # Fork the process that will accept the connection $pid = fork(); if (!$pid) { $rmask = undef; vec($rmask, fileno(MAIN), 1) = 1; $sel = select($rmask, undef, undef, 10); exit(1) if ($sel <= 0); accept(SOCK, MAIN); close(MAIN); select(SOCK); $| = 1; $header = "\000"; read(SOCK, $buf, length($header)); $buf eq $header || die "Invalid message $buf"; print SOCK < EOF close(SOCK); exit(0); } close(MAIN); # Output HTML for the flash object print <
EOF &ui_print_footer("/", $text{'index'});