From 57f15bcb976e47fd37b5549f8fbaff298830ac99 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 15 Mar 2024 15:02:42 -0700 Subject: [PATCH 1/3] Don't modify `$usev6` to avoid misleading log messages --- ddclient.in | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/ddclient.in b/ddclient.in index 55bef67..61a7bcd 100755 --- a/ddclient.in +++ b/ddclient.in @@ -3281,9 +3281,7 @@ sub get_ipv6 { ## Static IPv6 address is provided in "ipv6=
" if ($usev6 eq 'ip') { warning("'--usev6=ip' is deprecated. Use '--usev6=ipv6'"); - $usev6 = 'ipv6'; - ## If there is a value for ipv6= use that, else use value for ip= - $arg = opt($usev6, $h) // $arg; + $arg = opt('ipv6', $h) // $arg; } $ipv6 = $arg; if (!is_ipv6($ipv6)) { @@ -3296,9 +3294,7 @@ sub get_ipv6 { ## Obtain IPv6 address from interface mamed in "ifv6=" if ($usev6 eq 'if') { warning("'--usev6=if' is deprecated. Use '--usev6=ifv6'"); - $usev6 = 'ifv6'; - ## If there is a value for ifv6= use that, else use value for if= - $arg = opt($usev6, $h) // $arg; + $arg = opt('ifv6', $h) // $arg; } warning("'--if-skip' is deprecated and does nothing for IPv6") if (opt('verbose') && opt('if-skip', $h)); $ipv6 = get_ip_from_interface($arg,6); @@ -3307,9 +3303,7 @@ sub get_ipv6 { ## Obtain IPv6 address by executing the command in "cmdv6=" if ($usev6 eq 'cmd') { warning("'--usev6=cmd' is deprecated. Use '--usev6=cmdv6'"); - $usev6 = 'cmdv6'; - ## If there is a value for cmdv6= use that, else use value for cmd= - $arg = opt($usev6, $h) // $arg; + $arg = opt('cmdv6', $h) // $arg; } warning("'--cmd-skip' is deprecated and does nothing for IPv6") if (opt('verbose') && opt('cmd-skip', $h)); if ($arg) { @@ -3322,9 +3316,7 @@ sub get_ipv6 { ## Obtain IPv6 address by accessing website at url in "webv6=" if ($usev6 eq 'web') { warning("'--usev6=web' is deprecated. Use '--usev6=webv6'"); - $usev6 = 'webv6'; - ## If there is a value for webv6= use that, else use value for web= - $arg = opt($usev6, $h) // $arg; + $arg = opt('webv6', $h) // $arg; } warning("'--web-skip' does nothing for IPv6. Use '--webv6-skip'") if (opt('web-skip', $h)); $url = $arg; @@ -3369,7 +3361,7 @@ sub get_ipv6 { ## If $ipv6 not set yet look for IPv6 address in the $reply text $ipv6 //= extract_ipv6($reply); ## Return undef for loopback address unless statically assigned by "ipv6=::" - $ipv6 = undef if (($usev6 ne 'ipv6') && (($ipv6 // '') eq '::')); + $ipv6 = undef if (($usev6 ne 'ipv6') && ($usev6 ne 'ip') && (($ipv6 // '') eq '::')); debug("get_ipv6: using (%s, %s) reports %s", $usev6, $arg, $ipv6 // ""); return $ipv6; } From b7dd590300fd1e71c437c02fd88e3cf0d5be7653 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 15 Mar 2024 15:09:08 -0700 Subject: [PATCH 2/3] Fix misleading, unclear, redundant, and unnecessary warnings --- ddclient.in | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/ddclient.in b/ddclient.in index 61a7bcd..c63155b 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1592,8 +1592,9 @@ sub _read_config { if ($mode & 077 && -o FD) { if (-f FD && (chmod 0600, $file)) { warning("file $file must be accessible only by its owner (fixed)."); + } else { + warning("file $file must be accessible only by its owner."); } - warning("file $file must be accessible only by its owner."); } elsif (! -o FD && -w FD) { warning("file $file should be owned only by ddclient or not be writable."); } @@ -3163,12 +3164,11 @@ sub get_ipv4 { } elsif ($usev4 eq 'ifv4') { ## Obtain IPv4 address from interface mamed in "ifv4=" - warning("'--if-skip' is deprecated and does nothing for IPv4") if (opt('verbose') && opt('if-skip', $h)); $ipv4 = get_ip_from_interface($arg,4); } elsif ($usev4 eq 'cmdv4') { ## Obtain IPv4 address by executing the command in "cmdv4=" - warning("'--cmd-skip' is deprecated and does nothing for IPv4") if (opt('verbose') && opt('cmd-skip', $h)); + warning("'--cmd-skip' ignored for '--usev4=$usev4'") if (opt('verbose') && opt('cmd-skip', $h)); if ($arg) { my $sys_cmd = quotemeta($arg); $reply = qx{$sys_cmd}; @@ -3198,9 +3198,12 @@ sub get_ipv4 { # Stuff added to support Cisco router ip http or ASA https daemon # User fw-login should only have level 1 access to prevent # password theft. This is pretty harmless. - warning("'--if' does nothing for IPv4. Use '--ifv4'") if (opt('if', $h)); - warning("'--fw' does nothing for IPv4. Use '--fwv4'") if (opt('fw', $h)); - warning("'--fw-skip' does nothing for IPv4. Use '--fwv4-skip'") if (opt('fw-skip', $h)); + warning("'--if' is deprecated for '--usev4=$usev4'; use '--ifv4' instead") + if (!defined(opt('ifv4', $h)) && defined(opt('if', $h))); + warning("'--fw' is deprecated for '--usev4=$usev4'; use '--fwv4' instead") + if (!defined(opt('fwv4', $h)) && defiend(opt('fw', $h))); + warning("'--fw-skip' is deprecated for '--usev4=$usev4'; use '--fwv4-skip' instead") + if (!defined(opt('fwv4-skip', $h)) && defined(opt('fw-skip', $h))); my $queryif = opt('ifv4', $h) // opt('if', $h); $skip = opt('fwv4-skip', $h) // opt('fw-skip', $h) // ''; # Convert slashes to protected value "\/" @@ -3227,8 +3230,10 @@ sub get_ipv4 { $reply = ''; } else { - warning("'--fw' does nothing for IPv4. Use '--fwv4'") if (opt('fw', $h)); - warning("'--fw-skip' does nothing for IPv4. Use '--fwv4-skip'") if (opt('fw-skip', $h)); + warning("'--fw' is deprecated for '--usev4=$usev4'; use '--fwv4' instead") + if (!defined(opt('fwv4', $h)) && defined(opt('fw', $h))); + warning("'--fw-skip' is deprecated for '--usev4=$usev4'; use '--fwv4-skip' instead") + if (!defined(opt('fwv4-skip', $h)) && defined(opt('fw-skip', $h))); $url = opt('fwv4', $h) // opt('fw', $h) // ''; $skip = opt('fwv4-skip', $h) // opt('fw-skip', $h) // ''; @@ -3296,7 +3301,6 @@ sub get_ipv6 { warning("'--usev6=if' is deprecated. Use '--usev6=ifv6'"); $arg = opt('ifv6', $h) // $arg; } - warning("'--if-skip' is deprecated and does nothing for IPv6") if (opt('verbose') && opt('if-skip', $h)); $ipv6 = get_ip_from_interface($arg,6); } elsif ($usev6 eq 'cmdv6' || $usev6 eq 'cmd') { @@ -3305,7 +3309,7 @@ sub get_ipv6 { warning("'--usev6=cmd' is deprecated. Use '--usev6=cmdv6'"); $arg = opt('cmdv6', $h) // $arg; } - warning("'--cmd-skip' is deprecated and does nothing for IPv6") if (opt('verbose') && opt('cmd-skip', $h)); + warning("'--cmd-skip' ignored for '--usev6=$usev6'") if (opt('verbose') && opt('cmd-skip', $h)); if ($arg) { my $sys_cmd = quotemeta($arg); $reply = qx{$sys_cmd}; @@ -3318,7 +3322,8 @@ sub get_ipv6 { warning("'--usev6=web' is deprecated. Use '--usev6=webv6'"); $arg = opt('webv6', $h) // $arg; } - warning("'--web-skip' does nothing for IPv6. Use '--webv6-skip'") if (opt('web-skip', $h)); + warning("'--web-skip' ignored for '--usev6=$usev6'; use '--webv6-skip' instead") + if (!defined(opt('webv6-skip', $h)) && defined(opt('web-skip', $h))); $url = $arg; $skip = opt('webv6-skip', $h) // ''; if (exists $builtinweb{$url}) { @@ -3337,13 +3342,7 @@ sub get_ipv6 { ) // ''; } - } elsif ($usev6 eq 'cisco' || $usev6 eq 'cisco-asa') { - warning("'--usev6=cisco' and '--usev6=cisco-asa' are not implemented and do nothing"); - $reply = ''; - } elsif ($usev6 eq 'disabled') { - ## This is a no-op... Do not get an IPv6 address for this host/service - warning("'--usev6=no' is deprecated. Use '--usev6=disabled'") if ($usev6 eq 'no'); $reply = ''; } else { From d525e28c2028ce5aa232813384e550fd18bf7e12 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 5 May 2024 17:48:44 -0400 Subject: [PATCH 3/3] Show original user input in debug message Also add comments explaining the purpose of the lines, because it's not immediately clear. --- ddclient.in | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ddclient.in b/ddclient.in index c63155b..07c55af 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2803,14 +2803,15 @@ sub get_ip { $reply = ''; } else { - $url = opt('fw', $h) // ''; + # Note that --use=firewallname uses --fw=arg, not --firewallname=arg. + $arg = opt('fw', $h) // ''; + $url = $arg; $skip = opt('fw-skip', $h) // ''; if (exists $builtinfw{$use}) { $skip = $builtinfw{$use}->{'skip'} unless $skip; $url = "http://${url}" . $builtinfw{$use}->{'url'} unless $url =~ /\//; } - $arg = $url; if ($url) { $reply = geturl( @@ -3234,14 +3235,15 @@ sub get_ipv4 { if (!defined(opt('fwv4', $h)) && defined(opt('fw', $h))); warning("'--fw-skip' is deprecated for '--usev4=$usev4'; use '--fwv4-skip' instead") if (!defined(opt('fwv4-skip', $h)) && defined(opt('fw-skip', $h))); - $url = opt('fwv4', $h) // opt('fw', $h) // ''; + # Note that --usev4=firewallname uses --fwv4=arg (or --fw=arg), not --firewallname=arg. + $arg = opt('fwv4', $h) // opt('fw', $h) // ''; + $url = $arg; $skip = opt('fwv4-skip', $h) // opt('fw-skip', $h) // ''; if (exists $builtinfw{$usev4}) { $skip = $builtinfw{$usev4}->{'skip'} unless $skip; $url = "http://${url}" . $builtinfw{$usev4}->{'url'} unless $url =~ /\//; } - $arg = $url; if ($url) { $reply = geturl( url => $url,