From f2c9ef66418cdee50f6bb708a16f9e1f7a92e7cd Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 1 Sep 2024 03:06:46 -0400 Subject: [PATCH] read_recap: Scrub recap values without var declarations --- ddclient.in | 8 +++++++- t/read_recap.pl | 5 ----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ddclient.in b/ddclient.in index bc6fdb9..86b86d6 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1635,8 +1635,14 @@ sub read_recap { %opt = %saved; $recap{$_} //= {} for keys(%config); for my $h (keys(%recap)) { - next if !exists($config{$h}); + if (!exists($config{$h})) { + delete($recap{$h}); + next; + } my $vars = $protocols{opt('protocol', $h)}{variables}; + for my $v (keys(%{$recap{$h}})) { + delete($recap{$h}{$v}) if !$vars->{$v} || !$vars->{$v}{recap}; + } # Only status variables are copied from `%recap` into `%config` because the recap should # not change the configuration. See the documenting comments for `%recap`. # TODO: Hard-coding this list impairs readability and maintainability. In particular, diff --git a/t/read_recap.pl b/t/read_recap.pl index cafabd3..b601eae 100644 --- a/t/read_recap.pl +++ b/t/read_recap.pl @@ -50,13 +50,11 @@ my @test_cases = ( desc => "unknown host", cachefile_lines => ["var_a=yes host_c"], want => {}, - want_TODO => "longstanding minor issue, doesn't affect functionality", }, { desc => "unknown var", cachefile_lines => ["var_b=123 host_a"], want => {host_a => {host => 'host_a'}}, - want_TODO => "longstanding minor issue, doesn't affect functionality", }, { desc => "invalid value", @@ -142,21 +140,18 @@ my @test_cases = ( desc => "non-recap vars are not loaded to %recap or copied to %config", cachefile_lines => ["mtime=1234567890 host_b"], want => {host_b => {host => 'host_b'}}, - want_TODO => "longstanding minor issue, doesn't affect functionality", }, { desc => "non-recap vars are scrubbed from %recap", cachefile_lines => ["mtime=1234567890 host_b"], recap => {host_b => {host => 'host_b', mtime => 1234567891}}, want => {host_b => {host => 'host_b'}}, - want_TODO => "longstanding minor issue, doesn't affect functionality", }, { desc => "unknown hosts are scrubbed from %recap", cachefile_lines => ["host_a", "host_c"], recap => {host_a => {host => 'host_a'}, host_c => {host => 'host_c'}}, want => {host_a => {host => 'host_a'}}, - want_TODO => "longstanding minor issue, doesn't affect functionality", }, );