summaryrefslogtreecommitdiff
path: root/debian/local
diff options
context:
space:
mode:
authorSteve Langasek <vorlon@debian.org>2008-08-20 00:06:24 -0700
committerSteve Langasek <steve.langasek@ubuntu.com>2019-01-03 17:28:24 -0800
commit098e7d1255327f696af468765a04837f53937f29 (patch)
tree172796f076712f889ff10a4d4c0d0d6fa8e63af7 /debian/local
parentbc6104705d50788519a84d83a2096e5949fa420d (diff)
When merging options, handle additions before removals to avoid referencing
an array element we've already deleted. When deleting an option from the config, take care to decrement the counter at the same time since we've just shrunk the array. In diff_profiles, store $1 somewhere more permanent so it doesn't get lost. Fix up the regex used for suppressing jump counts to only apply when it appears between brackets; numbers may also legitimately appear in module options. Quote the module line with \Q\E when doing regex matching.
Diffstat (limited to 'debian/local')
-rwxr-xr-xdebian/local/pam-auth-update15
1 files changed, 9 insertions, 6 deletions
diff --git a/debian/local/pam-auth-update b/debian/local/pam-auth-update
index ffd61770..168bedf8 100755
--- a/debian/local/pam-auth-update
+++ b/debian/local/pam-auth-update
@@ -177,12 +177,13 @@ sub merge_one_line
}
for (my $i = 0; $i <= $#opts; $i++) {
- if ($removes->{$opts[$i]}) {
- splice(@opts,$i,1);
- }
if ($adds->{$opts[$i]}) {
delete $adds->{$opts[$i]};
}
+ if ($removes->{$opts[$i]}) {
+ splice(@opts,$i,1);
+ $i--;
+ }
}
return $modline . " " . join(' ',@opts,keys(%{$adds})) . "\n";
}
@@ -424,6 +425,7 @@ sub diff_profiles
}
my $found = 0;
+ my $curopts;
while (!$found && $#saved >= 0) {
my $line;
($modname,$line) = @{$saved[0]};
@@ -434,10 +436,11 @@ sub diff_profiles
# FIXME: the key isn't derived from the config
# name, so collisions are possible if more
# than one config references the same module
- $curmod =~ s/(end|[0-9]+)//g;
+ $_ =~ s/=[0-9]+/=/g;
# check if this is a match for the current line
- if ($_ =~ /^$curmod\s*(.*)$/) {
+ if ($_ =~ /^\Q$curmod\E\s*(.*)$/) {
$found = 1;
+ $curopts = $1;
} else {
push(@{$diff{$type}{'del'}},$modname);
}
@@ -450,7 +453,7 @@ sub diff_profiles
# didn't come from a package.
return 0 if (!$found);
- for my $opt (split(/\s+/,$1)) {
+ for my $opt (split(/\s+/,$curopts)) {
my $found = 0;
for (my $i = 0; $i <= $#prev_opts; $i++) {
if ($prev_opts[$i] eq $opt) {