From ae7a9dce2afd60ca3fc6835215dbda1cc11d9bca Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 29 Jun 2024 01:59:03 -0400 Subject: [PATCH 1/8] Fix variable name typo This fixes a bug introduced in commit b154d8ef98b48f93acdc83befb99003abd492b24 --- ddclient.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index a415b2a..25bd8e4 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1567,7 +1567,7 @@ sub write_recap { $recap{$h}{$v} = $config{$h}{$v}; } } else { - for my $v (qw(atime wtime status status-ipv4 status-ivp6)) { + for my $v (qw(atime wtime status status-ipv4 status-ipv6)) { $recap{$h}{$v} = $config{$h}{$v}; } } From de39ac7bcc3a52dfe2895a3facfc4f9f3801fc40 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 29 Jun 2024 02:00:40 -0400 Subject: [PATCH 2/8] Fix undef warning when `daemon` is unset This fixes a bug introduced in commit 88eb2ed4fe9879670ff808dc0703834aac654181 --- ddclient.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index 25bd8e4..ecfa7a6 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1919,7 +1919,7 @@ sub init_config { ## parse an interval expression (such as '5m') into number of seconds $opt{'daemon'} = interval(opt('daemon')) if defined($opt{'daemon'}); ## make sure the interval isn't too short - $opt{'daemon'} = minimum('daemon') if opt('daemon') > 0 && opt('daemon') < minimum('daemon'); + $opt{'daemon'} = minimum('daemon') if opt('daemon') && opt('daemon') < minimum('daemon'); ## define or modify host options specified on the command-line if (defined($opt{'options'})) { From be3c2060eb3c014fc569af0a2f41381500c48d23 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 29 Jun 2024 02:14:16 -0400 Subject: [PATCH 3/8] Fix undefined hash reference warning This fixes a bug introduced in commit 5e3e10d32ec11a9cd9d1275b73e111907bdafa4c For some reason Perl is OK with: my $x = undef; my @k = keys(%$x); # empty list, no warnings but not: my $x = undef; my %h = %$x; my @k = keys(%h); --- ddclient.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index ecfa7a6..dca3bd0 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1950,7 +1950,7 @@ sub init_config { ## merge options into host definitions or globals if (@hosts) { for my $h (@hosts) { - $config{$h} = {%{$config{$h}}, %options}; + $config{$h} = {%{$config{$h} // {}}, %options}; } $opt{'host'} = join(',', @hosts); } else { From 04bdd68415edfe48175fda30e76b96123a3a6ed5 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 29 Jun 2024 02:26:16 -0400 Subject: [PATCH 4/8] Always set the `host` variable The `host` variable is required, so always set it to avoid error messages when validating the host configuration. --- ddclient.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddclient.in b/ddclient.in index dca3bd0..2cd0162 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1950,7 +1950,7 @@ sub init_config { ## merge options into host definitions or globals if (@hosts) { for my $h (@hosts) { - $config{$h} = {%{$config{$h} // {}}, %options}; + $config{$h} = {%{$config{$h} // {}}, %options, 'host' => $h}; } $opt{'host'} = join(',', @hosts); } else { @@ -2031,7 +2031,7 @@ sub init_config { } my $svars = $protocols{$proto}{'variables'}; - my $conf = {'protocol' => $proto}; + my $conf = {'host' => $h, 'protocol' => $proto}; for my $k (keys %$svars) { # Make sure any _env suffixed variables look at their original entry From d8317a730d1614263309e3764ec885e9dfd1a009 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 29 Jun 2024 02:28:43 -0400 Subject: [PATCH 5/8] Fix `die` that should be `return undef` I got ahead of myself -- I intend to replace `return undef` with `die` in a future commit, and somehow this one jumped the gun. This fixes a bug introduced in commit eab72ef6d7044ac7d638d0ab071570d2618db3aa --- ddclient.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index 2cd0162..2bc470d 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2565,7 +2565,7 @@ sub check_value { } elsif (!defined($value) && $required) { # None of the types have 'undef' as a valid value, so check definedness once here for # convenience. - die("$type is required\n"); + return undef; } elsif ($type eq T_DELAY) { $value = interval($value); From 1f31b0e570777ed8a81752dba48a95e18502e054 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 29 Jun 2024 02:32:14 -0400 Subject: [PATCH 6/8] Prevent autovivification of empty definitions for unknown variables --- ddclient.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ddclient.in b/ddclient.in index 2bc470d..958b394 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2405,10 +2405,12 @@ sub split_by_comma { } sub default { my $v = shift; + return undef if !defined($variables{'merged'}{$v}); return $variables{'merged'}{$v}{'default'}; } sub minimum { my $v = shift; + return undef if !defined($variables{'merged'}{$v}); return $variables{'merged'}{$v}{'minimum'}; } sub opt { From 89c84f9f0760a625d249efc1babf0f4746dd43e8 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 29 Jun 2024 02:34:28 -0400 Subject: [PATCH 7/8] Ignore (with warning) unknown vars in `--options` --- ddclient.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ddclient.in b/ddclient.in index 958b394..716682d 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2002,6 +2002,11 @@ sub init_config { # TODO: This might grab an arbitrary protocol-specific variable, which could cause # surprising behavior. my $def = $variables{'merged'}{$k}; + if (!$def) { + warning("ignoring unknown setting '$k=$globals{$k}'"); + delete($globals{$k}); + next; + } # TODO: Isn't $globals{$k} guaranteed to be defined here? Otherwise $k wouldn't appear in # %globals. my $ovalue = $globals{$k} // $def->{'default'}; From f5b369a7ef1c1344aafdfa26fda09526e121763f Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 29 Jun 2024 02:36:44 -0400 Subject: [PATCH 8/8] Fix undef warning when encountering an unset but required var This fixes a bug probably introduced in commit b8a0a264413255891e3699a3414188a952c528cd --- ddclient.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index 716682d..082cc8c 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2046,7 +2046,8 @@ sub init_config { my $ovalue = $config{$h}{$k} // $def->{'default'}; my $value = check_value($ovalue, $def); if ($def->{'required'} && !defined $value) { - warning("skipping host: %s: '%s=%s' is an invalid %s.", $h, $k, $ovalue, $def->{'type'}); + $ovalue //= '(not set)'; + warning("skipping host $h: invalid $def->{type} variable value '$k=$ovalue'"); delete $config{$h}; next HOST; }