Finally working
This commit is contained in:
parent
ca18a45319
commit
cf2017a863
20
convert.pl
20
convert.pl
|
@ -4,7 +4,7 @@
|
|||
# securly migrate to apache 2.2 to 2.4. This script only migrate most
|
||||
# common pattern.
|
||||
|
||||
#use re "debug";
|
||||
# use re "debug";
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
|
@ -20,14 +20,17 @@ use warnings;
|
|||
# Regex for spaces bettwen word (including comment character)
|
||||
my $s = '[#\s]*';
|
||||
|
||||
while (<ARGV>) {
|
||||
while (<>) {
|
||||
# ** Order
|
||||
# Default of mod_access_compat
|
||||
next if /Order${s}deny,allow/i;
|
||||
|
||||
if (/(Order${s}Allow,Deny)/i) {
|
||||
$_ .= <ARGV>;
|
||||
$_ .= <> unless eof;
|
||||
# NOTE We replace with dpreceated directive, because they are
|
||||
# replaced with the current one down the line.
|
||||
s/${1}${s}(Deny${s}from${s}all)/$1/i;
|
||||
s/${1}${s}(Allow${s}from${s}localhost.*)/$1/i;
|
||||
};
|
||||
|
||||
# ** Satisfy
|
||||
|
@ -36,15 +39,13 @@ while (<ARGV>) {
|
|||
|
||||
# ** Misc
|
||||
if (/(Require${s}valid-user)/i) {
|
||||
$_ .= <ARGV>.<ARGV>.<ARGV>;
|
||||
$_ .= <>.<>.<> unless eof;
|
||||
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>;
|
||||
# };
|
||||
$_ .= <> unless eof;
|
||||
s/${1}${s}Allow${s}from/Require ip/i;
|
||||
s/Deny${s}from${s}all/Require all denied/i;
|
||||
};
|
||||
|
@ -53,11 +54,10 @@ while (<ARGV>) {
|
|||
|
||||
# ** Allow
|
||||
s/Allow${s}from${s}all/Require all granted/i;
|
||||
s/Allow${s}from${s}localhost.*/Require ip local/i;
|
||||
s/Allow${s}from/Require ip/i;
|
||||
|
||||
print ARGV;
|
||||
print;
|
||||
}
|
||||
|
||||
# close $fh;
|
||||
|
||||
# print 'END THIS SHIT!!!!\n';
|
||||
|
|
29
migrate.sh
29
migrate.sh
|
@ -1,13 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
newline="\n[[:blank:]]"
|
||||
set -e
|
||||
|
||||
# 2.2 Directives
|
||||
all_denied="s/Order deny,allow${newline}Deny from all/Require all denied/"
|
||||
-
|
||||
## Last
|
||||
deny_from_env="s/Deny from env=/Require not env /"
|
||||
allow_all="s/Allow from all/Require all granted/"
|
||||
inventory=$1
|
||||
|
||||
# Mixed directives
|
||||
mix_allow_all_require_all="s/Allow from all${newline}Require all granted/Require all granted/"
|
||||
tmp_dir=/tmp/apache-require
|
||||
inventory=$tmp_dir/inventory
|
||||
to_convert=$tmp_dir/to_convert
|
||||
|
||||
# Create a backup of the FILE specific for this project
|
||||
backup() {
|
||||
file=$1
|
||||
|
||||
cp "$file" "$file".apreq.bak
|
||||
}
|
||||
|
||||
awk '{ print $1 }' "$inventory" > "$to_convert"
|
||||
|
||||
while IFS= read -r file; do
|
||||
echo $file
|
||||
backup "$file"
|
||||
perl -i ~bwaegeneire/convert.pl "$file"
|
||||
done < "$to_convert"
|
||||
|
|
Loading…
Reference in a new issue