mirror of https://github.com/digint/btrbk
btrbk: fix filter statement matching for volume="/"
While $vol->{URL} can contain "//" if volume="/" (intentionally, this is an assembled path), the filter statements are sanitized using check_url(). This means we need to match the filter statement against check_url($vol->{URL}). Same applies to subvol.pull/204/merge
parent
90fed6525e
commit
a3641cff74
|
@ -1,6 +1,7 @@
|
||||||
btrbk-current
|
btrbk-current
|
||||||
|
|
||||||
* Bugfix: fix parsing of "openssl_iv_size" configuration option.
|
* Bugfix: fix parsing of "openssl_iv_size" configuration option.
|
||||||
|
* Bugfix: fix filter statement matching for volume=/ (close #209).
|
||||||
|
|
||||||
btrbk-0.26.0
|
btrbk-0.26.0
|
||||||
|
|
||||||
|
|
26
btrbk
26
btrbk
|
@ -2269,6 +2269,8 @@ sub vinfo_child($$;$)
|
||||||
my $subvol_dir = "";
|
my $subvol_dir = "";
|
||||||
$subvol_dir = $1 if($name =~ s/^(.*)\///);
|
$subvol_dir = $1 if($name =~ s/^(.*)\///);
|
||||||
|
|
||||||
|
# Note that PATH and URL intentionally contain "//" if $parent->{PATH} = "/".
|
||||||
|
# For consistency reasons (not required), we dont sanitize PRINT either.
|
||||||
my $vinfo = {
|
my $vinfo = {
|
||||||
HOST => $parent->{HOST},
|
HOST => $parent->{HOST},
|
||||||
NAME => $name,
|
NAME => $name,
|
||||||
|
@ -4874,12 +4876,13 @@ MAIN:
|
||||||
{
|
{
|
||||||
my %match;
|
my %match;
|
||||||
foreach my $sroot (vinfo_subsection($config, 'volume', 1)) {
|
foreach my $sroot (vinfo_subsection($config, 'volume', 1)) {
|
||||||
my $vol_url = $sroot->{URL};
|
my $vol_match = join("", check_url($sroot->{URL})); # sanitize URL (can contain "//", see vinfo_child)
|
||||||
my $found_vol = 0;
|
my $found_vol = 0;
|
||||||
foreach my $filter (@filter_args) {
|
foreach my $filter (@filter_args) {
|
||||||
if(($vol_url eq $filter) || (map { ($filter eq $_) || () } @{$sroot->{CONFIG}->{group}})) {
|
if(($vol_match eq $filter) ||
|
||||||
TRACE "filter argument \"$filter\" matches volume: $vol_url";
|
(map { ($filter eq $_) || () } @{$sroot->{CONFIG}->{group}})) {
|
||||||
$match{$filter} = ($vol_url eq $filter) ? "volume=$sroot->{PRINT}" : "group=$filter";
|
TRACE "filter argument \"$filter\" matches volume: $sroot->{PRINT}";
|
||||||
|
$match{$filter} = ($vol_match eq $filter) ? "volume=$sroot->{PRINT}" : "group=$filter";
|
||||||
$found_vol = 1;
|
$found_vol = 1;
|
||||||
# last; # need to cycle through all filter_args for correct %match
|
# last; # need to cycle through all filter_args for correct %match
|
||||||
}
|
}
|
||||||
|
@ -4888,12 +4891,13 @@ MAIN:
|
||||||
|
|
||||||
my @filter_subvol;
|
my @filter_subvol;
|
||||||
foreach my $svol (vinfo_subsection($sroot, 'subvolume', 1)) {
|
foreach my $svol (vinfo_subsection($sroot, 'subvolume', 1)) {
|
||||||
my $subvol_url = $svol->{URL};
|
my $subvol_match = join("", check_url($svol->{URL})); # sanitize URL (can contain "//", see vinfo_child)
|
||||||
my $found_subvol = 0;
|
my $found_subvol = 0;
|
||||||
foreach my $filter (@filter_args) {
|
foreach my $filter (@filter_args) {
|
||||||
if(($subvol_url eq $filter) || (map { ($filter eq $_) || () } @{$svol->{CONFIG}->{group}})) {
|
if(($subvol_match eq $filter) ||
|
||||||
TRACE "filter argument \"$filter\" matches subvolume: $subvol_url";
|
(map { ($filter eq $_) || () } @{$svol->{CONFIG}->{group}})) {
|
||||||
$match{$filter} = ($subvol_url eq $filter) ? "subvolume=$svol->{PRINT}" : "group=$filter";
|
TRACE "filter argument \"$filter\" matches subvolume: $svol->{PRINT}";
|
||||||
|
$match{$filter} = ($subvol_match eq $filter) ? "subvolume=$svol->{PRINT}" : "group=$filter";
|
||||||
$found_subvol = 1;
|
$found_subvol = 1;
|
||||||
$found_vol = 1;
|
$found_vol = 1;
|
||||||
# last; # need to cycle through all filter_args for correct %match
|
# last; # need to cycle through all filter_args for correct %match
|
||||||
|
@ -4918,17 +4922,17 @@ MAIN:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unless($found_target) {
|
unless($found_target) {
|
||||||
DEBUG "No match on filter command line argument, skipping target: $target_url";
|
DEBUG "No match on filter command line argument, skipping target: $droot->{PRINT}";
|
||||||
ABORTED($droot, "USER_SKIP");
|
ABORTED($droot, "USER_SKIP");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unless($found_subvol) {
|
unless($found_subvol) {
|
||||||
DEBUG "No match on filter command line argument, skipping subvolume: $subvol_url";
|
DEBUG "No match on filter command line argument, skipping subvolume: $svol->{PRINT}";
|
||||||
ABORTED($svol, "USER_SKIP");
|
ABORTED($svol, "USER_SKIP");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unless($found_vol) {
|
unless($found_vol) {
|
||||||
DEBUG "No match on filter command line argument, skipping volume: $vol_url";
|
DEBUG "No match on filter command line argument, skipping volume: $sroot->{PRINT}";
|
||||||
ABORTED($sroot, "USER_SKIP");
|
ABORTED($sroot, "USER_SKIP");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue