#!/usr/local/bin/perl # index.cgi # Display the vnc applet BEGIN { push(@INC, ".."); }; use WebminCore; use Socket; &init_config(); &ui_print_header(undef, $text{'index_title'}, "", undef, &get_product_name() eq 'webmin', 1); if ($config{'program'}) { # Check if Xvnc is installed if (!&has_command("Xvnc")) { &error_exit(&text('index_ecmd', "Xvnc")); } # Pick a free VNC number for($num=1; $num<1000; $num++) { $port = 5900+$num; last; # XXX need to test } # Generate a password using vncpasswd # XXX # Start Xvnc in a background process, and kill it after one client if (!fork()) { close(STDIN); close(STDOUT); local $pid = open(VNC, "Xvnc :$num 2>&1 |"); while() { if (/Client\s+(\S+)\s+gone/i) { kill(TERM, $pid); last; } } close(VNC); exit; } # Run the specified program, using the selected display $ENV{'DISPLAY'} = "localhost:$num"; system("$config{'program'} >/dev/null 2>&1 $text{'index_warn'}", "
\n"; } print "
\n"; print "\n"; if ($config{'host'}) { print "\n"; } print "$text{'index_nojava'}

\n"; print "


\n"; print "$text{'index_credits'}
\n"; &ui_print_footer("/", $text{'index'}); sub connect_timeout { } sub error_exit { print "

",@_,"

\n"; &ui_print_footer("/", $text{'index'}); exit; }