From 877ac35dc99371c7a854a4b9d0a79aa04901bb22 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 26 Nov 2005 22:06:23 +0000 Subject: Use Lighty. Hopefully it's here to stay, and mini_httpd is dead, jim. --- etc/inc/captiveportal.inc | 40 +++++++-------------- etc/inc/system.inc | 90 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 28 deletions(-) diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index ebf6271..34167e7 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -187,32 +187,18 @@ EOD; $procs = 16; } - /* start web server */ - mwexec("/usr/local/sbin/mini_httpd -a -M 0 -u root -maxproc {$procs}" . - " -p 8000 -i {$g['varrun_path']}/mini_httpd.cp.pid"); - - /* fire up another one for HTTPS if requested */ - if (isset($config['captiveportal']['httpslogin']) && - $config['captiveportal']['certificate'] && $config['captiveportal']['private-key']) { - - $cert = base64_decode($config['captiveportal']['certificate']); - $key = base64_decode($config['captiveportal']['private-key']); - - $fd = fopen("{$g['varetc_path']}/cert-portal.pem", "w"); - if (!$fd) { - printf("Error: cannot open cert-portal.pem in system_webgui_start().\n"); - return 1; - } - chmod("{$g['varetc_path']}/cert-portal.pem", 0600); - fwrite($fd, $cert); - fwrite($fd, "\n"); - fwrite($fd, $key); - fclose($fd); - - mwexec("/usr/local/sbin/mini_httpd -S -a -M 0 -E {$g['varetc_path']}/cert-portal.pem" . - " -u root -maxproc 16 -p 8001" . - " -i {$g['varrun_path']}/mini_httpd.cps.pid"); - } + /* TEMPORARY! FAST_CGI reports _FALSE_ client ip + * addresses. + */ + $use_fastcgi = false; + + /* generate lighttpd configuration */ + system_generate_lighty_config("{$g['varetc_path']}/lighty-CaptivePortal.conf", + $key, $cert, "lighty-CaptivePortal.pid", "8000", "/usr/local/captiveportal/", + "cert-portal.pem", "1", $procs, $use_fastcgi); + + /* attempt to start lighttpd */ + $res = mwexec("/usr/local/sbin/lighttpd -f {$g['varetc_path']}/lighty-CaptivePortal.conf"); /* start pruning process (interval = 60 seconds) */ mwexec("/usr/local/bin/minicron 60 {$g['varrun_path']}/minicron.pid " . @@ -792,4 +778,4 @@ function captiveportal_logportalauth($user,$mac,$ip,$status) { closelog(); } -?> \ No newline at end of file +?> diff --git a/etc/inc/system.inc b/etc/inc/system.inc index 30a7366..e732a97 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -332,6 +332,94 @@ function system_pccard_start() { function system_webgui_start() { global $config, $g; + + if ($g['booting']) + echo "Starting webConfigurator... "; + + /* kill any running mini_httpd */ + killbypid("{$g['varrun_path']}/lighty-webConfigurator.pid"); + + /* generate password file */ + system_password_configure(); + + chdir($g['www_path']); + + /* non-standard port? */ + if ($config['system']['webgui']['port']) + $portarg = "-p {$config['system']['webgui']['port']}"; + else + $portarg = ""; + + if ($config['system']['webgui']['protocol'] == "https") { + + if ($config['system']['webgui']['certificate'] && $config['system']['webgui']['private-key']) { + $cert = base64_decode($config['system']['webgui']['certificate']); + $key = base64_decode($config['system']['webgui']['private-key']); + } else { + /* default certificate/key */ + $cert = << \ No newline at end of file +?> -- cgit v1.1