aboutsummaryrefslogtreecommitdiffstats
path: root/config/apache_mod_security
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2010-03-06 20:10:10 -0500
committerScott Ullrich <sullrich@pfsense.org>2010-03-06 20:10:28 -0500
commit4ddcb729b32fe87ac4d6e87c62f62d3ea40f0d4b (patch)
treeeb80d955d0ce9832fe6fec04486b35aa1eeb7b1f /config/apache_mod_security
parent330a0f8fadf1a0882df8ddc678d072bac6ae3472 (diff)
downloadpfsense-packages-4ddcb729b32fe87ac4d6e87c62f62d3ea40f0d4b.tar.gz
pfsense-packages-4ddcb729b32fe87ac4d6e87c62f62d3ea40f0d4b.tar.bz2
pfsense-packages-4ddcb729b32fe87ac4d6e87c62f62d3ea40f0d4b.zip
Check to see if something is already listening on the port selected and refuse to bind if something is already occupying the port. Log an error if needed.
Diffstat (limited to 'config/apache_mod_security')
-rw-r--r--config/apache_mod_security/apache_mod_security.inc38
1 files changed, 26 insertions, 12 deletions
diff --git a/config/apache_mod_security/apache_mod_security.inc b/config/apache_mod_security/apache_mod_security.inc
index 528d284e..593e04b2 100644
--- a/config/apache_mod_security/apache_mod_security.inc
+++ b/config/apache_mod_security/apache_mod_security.inc
@@ -152,19 +152,33 @@ function generate_apache_configuration() {
$servername = "ServerName " . `hostname` . "\n";
}
- // Set global listening directive
- if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoipaddr']) {
- $global_listen = $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoipaddr'];
- if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport'])
- $global_listen .= ":" . $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport'];
- else
- $global_listen .= ":80";
+ // Set global listening directive and ensure nothing is listening on this port already
+ $globalbind = $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoipaddr'];
+ $socksstat = split("\n", `/usr/bin/sockstat | awk '{ print $6 }' | grep ":{$globalbind}" | cut -d ":" -f2`);
+ if(is_array($socksstat)) {
+ foreach($socksstat as $ss) {
+ if($ss == $globalbind) {
+ $already_binded = true;
+ $input_errors[] = "Sorry, there is a process already listening on port {$globalbind}";
+ }
+ }
+ }
+ if(!$already_binded) {
+ if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoipaddr']) {
+ $global_listen = $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoipaddr'];
+ if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport'])
+ $global_listen .= ":" . $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport'];
+ else
+ $global_listen .= ":80";
+ } else {
+ $global_listen = "{$config['system']['hostname']}.{$config['system']['domain']}";
+ if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport'])
+ $global_listen .= ":" . $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport'];
+ else
+ $global_listen .= ":80";
+ }
} else {
- $global_listen = "{$config['system']['hostname']}.{$config['system']['domain']}";
- if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport'])
- $global_listen .= ":" . $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport'];
- else
- $global_listen .= ":80";
+ log_error("Could not start mod_security + mod_proxy on port {$global_listen}. Process is already bound to this port.");
}
// Setup mem_cache