[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

apacheconfig patch review requested



Hi.  Anyone know perl?  :-)

Bug #12094 (apache's oldest still-open bug!), #59998, #105820 and now
#129372 would seem to all be fixable by the patch attached to #105820.
Thanks to Steve Stock for supplying the patch.  Since I don't grok perl,
I'd just like someone to review it and see if it looks reasonable.
If it is, I'll incorporate it in apache 1.3.22-6.

The -6 changelog currently looks like:

  * Exclude suexec from dh_fixperm.  Closes: #126706 #127605 #127323
  * Depend on a sufficiently recent version of logrotate to support
    sharedscripts.  Closes: #124339
  * Split out mod_auth_mysql & mod_auth_pgsql into separate packages.
    Closes: #78670 #88338 #116650 #118843
  * Rewrite init script to use start-stop-daemon instead of using
    apachectl.  Closes: #126743 #126827 #128909
  * Forward-port suexec changes to 1.3.22 rather than replace 1.3.22's
    suexec with a patched one from 1.3.9.
  * Add a wildcard match for SSL_* to suexec's acceptable variables for
    the benefit of mod_ssl users.  Closes: #40226

I'll copy and paste the patch here:

--- apacheconfig-1.3.22-5	Sun Dec 16 13:11:58 2001
+++ apacheconfig	Fri Dec 28 02:17:19 2001
@@ -20,6 +20,7 @@
 
 use strict;
 no strict 'vars';
+use IO::File;
 
 $HTTPD_CONF="/etc/apache/httpd.conf";
 $HTTPD_EX="/usr/share/doc/apache/examples/httpd.conf";
@@ -65,10 +66,20 @@
 
 sub load_config_files ()
 {
+    # Can't use read_config for httpdconf, accessconf, or srmconf as
+    # the contents of these replace the existing config file.  If
+    # we used read_config here all included files would be flattened
+    # into one config file.  This would really upset most people.
+    # Only allconf (and nonvirtconf) use read_config as allconf is
+    # the variable searched for directives when attempting to determine
+    # which modules to activate.
     $main::httpdconf = `cat $HTTPD_CONF`;
     $main::accessconf = `cat $ACCESS_CONF 2> /dev/null`;
     $main::srmconf = `cat $SRM_CONF 2> /dev/null`;
-    $main::allconf = "$httpdconf\n$accessconf\n$srmconf";
+    $main::allconf = join("\n",
+        read_config($HTTPD_CONF),
+        read_config($ACCESS_CONF),
+        read_config($SRM_CONF));
     ($main::nonvirtconf = $allconf) =~ s/\n\s*<Virtual.*VirtualHost>//gs;
     $main::aliasesconf = `cat $ALIASES_CONF 2> /dev/null`;
     $main::servername = loadconf ("ServerName", "localhost");
@@ -96,6 +107,33 @@
     $main::servergroup = "www-data" if $main::servergroup =~ m/-/;
 }
 
+sub read_config {
+    # BUG: doesn't detect include loops
+    my $file = shift;
+    my $config = '';
+    if (-d $file) {
+        # We have a directory, per apache docs this means that all files in
+        # this directory and below are to be parsed as configuration files.
+        foreach (`find $file -type f -print`) {
+            chomp $_;
+            $config .= read_config($_);
+        }
+    } elsif (-f $file) {
+        # We have a file, store every line except include directives.
+        # For an include replace it with the contents of the file or
+        # set of files (aka directory) it references.
+        my $reader = IO::File->new($file);
+        while (<$reader>) {
+            # BUG: doesn't work for relative paths like conf/something.conf
+            if (/^\s*include\s+([\S]+)/i) {
+                $config .= read_config($1);
+            } else {
+                $config .= $_;
+            }
+        }
+    }
+    return $config;
+}
 
 sub yorn ($;$)
 {

Thanks.

-- 
Revolutions do not require corporate support.



Reply to: