Apache "Include" directive with wildcards

Apache's include directive does not accept wildcards, so something like this won't be allowed:

Include /srv/www/vhosts/*/conf/vhost.conf

You can use mod_perl to realize this. Additionally, the following example does a simple permission check to ensure that the included file has not been modified by an ordinary user:

  1. <perl>
  2. use File::stat;
  3. foreach $file (glob '/srv/www/vhosts/*/conf/vhost.conf') {
  4. my $stat = stat($file);
  5. if ($stat-&gt;uid != 0 || $stat-&gt;gid != 0) {
  6. warn "$file is not owned by root:root, skipping!\n";
  7. next;
  8. }
  9. if ($stat-&gt;mode &amp; 0002) {
  10. warn "$file is world-writable, skipping!\n";
  11. next;
  12. }
  13. push @Include, $file;
  14. }
  15. </perl>

Add new comment