64 lines
1.5 KiB
Perl
64 lines
1.5 KiB
Perl
#!/usr/bin/env perl
|
|
#
|
|
# Replace apache's mod_access_compat directives to mod_authz_host ones, to
|
|
# securly migrate to apache 2.2 to 2.4. This script only migrate most
|
|
# common pattern.
|
|
|
|
#use re "debug";
|
|
use strict;
|
|
use warnings;
|
|
|
|
# TODO Maybe use a redo in of clauses to avoid missing substitutions
|
|
|
|
# our $^I = '.bak';
|
|
|
|
# our @ARGV = ($ARGV[0]); # We don't want to use STDIN when eof get called
|
|
|
|
# open(my $fh, "+<", $ARGV[0])
|
|
# or die "Can't open ARGv[0]!";
|
|
|
|
# Regex for spaces bettwen word (including comment character)
|
|
my $s = '[#\s]*';
|
|
|
|
while (<ARGV>) {
|
|
# ** Order
|
|
# Default of mod_access_compat
|
|
next if /Order${s}deny,allow/i;
|
|
|
|
if (/(Order${s}Allow,Deny)/i) {
|
|
$_ .= <ARGV>;
|
|
s/${1}${s}(Deny${s}from${s}all)/$1/i;
|
|
};
|
|
|
|
# ** Satisfy
|
|
# Correspond to the new default, from mod_authz_host, to have an implicit <RequireAny>
|
|
next if /Satisfy${s}any/i;
|
|
|
|
# ** Misc
|
|
if (/(Require${s}valid-user)/i) {
|
|
$_ .= <ARGV>.<ARGV>.<ARGV>;
|
|
s/(${1})${s}Order${s}Deny,Allow${s}Deny${s}from${s}all/$1/i;
|
|
};
|
|
|
|
# ** Deny
|
|
if (/(Deny${s}from${s}all)/i) {
|
|
# unless (eof(ARGV)) {
|
|
$_ .= <ARGV>;
|
|
# };
|
|
s/${1}${s}Allow${s}from/Require ip/i;
|
|
s/Deny${s}from${s}all/Require all denied/i;
|
|
};
|
|
|
|
s/Deny${s}from${s}env=/Require not env /i;
|
|
|
|
# ** Allow
|
|
s/Allow${s}from${s}all/Require all granted/i;
|
|
s/Allow${s}from/Require ip/i;
|
|
|
|
print ARGV;
|
|
}
|
|
|
|
# close $fh;
|
|
|
|
# print 'END THIS SHIT!!!!\n';
|