From 6cb78a3d4b73a06c28f379f37d1eb8fe3dabc589 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 3 Mar 2015 13:13:02 +0000 Subject: [PATCH] allow files: Support negation syntax We now support !, which undoes the effect of a specified previously (perhaps in another file). Note that the logic is a bit poor: !... only undoes the effect of an identical (or equivalent) earlier pattern; it doesn't provide a specific override. Improving that would involve a more invasive change to sg-report-flight which I don't want to do right now. Signed-off-by: Ian Jackson --- sg-report-flight | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sg-report-flight b/sg-report-flight index 062107a..d2aff58 100755 --- a/sg-report-flight +++ b/sg-report-flight @@ -76,13 +76,20 @@ while (@ARGV && $ARGV[0] =~ m/^-/) { next unless m/\S/; next if m/^\#/; s/\s+/ /g; + my $remove = s/^!\s*//; die if m/ /g > 1; $_ .= ' @@' unless m/ /; s/\@\@/ '[^ ]*' /ge; s/\@/ '[^ -\/]*' /ge; $_= '^(?:'.$_.')$'; - print DEBUG "ALLOW $_\n"; - push @allows, $_; + my $entry = $_; + if (!$remove) { + print DEBUG "ALLOW $entry\n"; + push @allows, $entry; + } else { + print DEBUG "DEALLOW $entry\n"; + @allows = grep { $_ ne $entry } @allows; + } } A->error and die "$allowfile $!"; close A or die "$allowfile $!"; -- 2.39.5