From a0240345bfa79719c4c5fbc3336935bfaded015d Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 3 Jun 2024 22:01:32 -0400 Subject: [PATCH 1/4] Use `Module->import(...)` instead of `import(Module, ...)` This matches the documentation of the `use` statement. --- ddclient.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ddclient.in b/ddclient.in index fa6e5ec..571e16e 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2610,9 +2610,9 @@ On Debian, the package libdigest-sha1-perl or libdigest-sha-perl must be install EOM } if ($sha1_loaded) { - import Digest::SHA1 (qw/sha1_hex/); + Digest::SHA1->import(qw/sha1_hex/); } elsif ($sha_loaded) { - import Digest::SHA (qw/sha1_hex/); + Digest::SHA->import(qw/sha1_hex/); } } ###################################################################### @@ -2626,7 +2626,7 @@ sub load_json_support { Error loading the Perl module JSON::PP needed for $why update. EOM } - import JSON::PP (qw/decode_json encode_json/); + JSON::PP->import(qw/decode_json encode_json/); } ###################################################################### From 1e1e100d7f3c9a87643f0fef972366b3ac5faf4b Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 3 Jun 2024 22:19:45 -0400 Subject: [PATCH 2/4] Prefer `Digest::SHA` over `Digest::SHA1` `Digest::SHA` is a core module; `Digest::SHA1` is not. --- ddclient.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ddclient.in b/ddclient.in index 571e16e..51ce3f9 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2609,10 +2609,10 @@ Error loading the Perl module Digest::SHA1 or Digest::SHA needed for $why update On Debian, the package libdigest-sha1-perl or libdigest-sha-perl must be installed. EOM } - if ($sha1_loaded) { - Digest::SHA1->import(qw/sha1_hex/); - } elsif ($sha_loaded) { + if ($sha_loaded) { Digest::SHA->import(qw/sha1_hex/); + } elsif ($sha1_loaded) { + Digest::SHA1->import(qw/sha1_hex/); } } ###################################################################### From 1401ff4aeaa918106f22bb0ab3cb30b01e22dfcf Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 3 Jun 2024 22:37:59 -0400 Subject: [PATCH 3/4] Only attempt to load `Digest::SHA` `Digest::SHA` has been a core module for a long time, and `Digest::SHA1` has not been updated in a long time. --- ChangeLog.md | 4 ++++ ddclient.in | 19 ++++++------------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index f376ad9..6ac8d0c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -15,6 +15,10 @@ repository history](https://github.com/ddclient/ddclient/commits/master). [5b104ad1](https://github.com/ddclient/ddclient/commit/5b104ad116c023c3760129cab6e141f04f72b406) * All log messages are now written to STDERR, not a mix of STDOUT and STDERR. [#676](https://github.com/ddclient/ddclient/pull/676) + * For `--protocol=freedns` and `--protocol=nfsn`, the core module + `Digest::SHA` is now required. Previously, `Digest::SHA1` was used (if + available) as an alternative to `Digest::SHA`. + [#685](https://github.com/ddclient/ddclient/pull/685) ### New features diff --git a/ddclient.in b/ddclient.in index 51ce3f9..b758420 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2600,21 +2600,14 @@ sub encode_base64 ($;$) { ## load_sha1_support ###################################################################### sub load_sha1_support { - my $why = shift; - my $sha1_loaded = eval { require Digest::SHA1 }; - my $sha_loaded = eval { require Digest::SHA }; - unless ($sha1_loaded || $sha_loaded) { - fatal("%s", <<"EOM"); -Error loading the Perl module Digest::SHA1 or Digest::SHA needed for $why update. -On Debian, the package libdigest-sha1-perl or libdigest-sha-perl must be installed. + my ($protocol) = @_; + eval { require Digest::SHA; } or fatal(<<"EOM"); +Error loading the Perl module Digest::SHA needed for $protocol update. +On Debian, the package libdigest-sha-perl must be installed. EOM - } - if ($sha_loaded) { - Digest::SHA->import(qw/sha1_hex/); - } elsif ($sha1_loaded) { - Digest::SHA1->import(qw/sha1_hex/); - } + Digest::SHA->import(qw/sha1_hex/); } + ###################################################################### ## load_json_support ###################################################################### From bb658d763ac7aa6e78b7305c42291dfc06878afe Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 3 Jun 2024 22:09:23 -0400 Subject: [PATCH 4/4] Simplify loading of `JSON::PP` --- ddclient.in | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ddclient.in b/ddclient.in index b758420..9af3867 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2612,13 +2612,9 @@ EOM ## load_json_support ###################################################################### sub load_json_support { - my $why = shift; - my $json_loaded = eval { require JSON::PP }; - unless ($json_loaded) { - fatal("%s", <<"EOM"); -Error loading the Perl module JSON::PP needed for $why update. -EOM - } + my ($protocol) = @_; + eval { require JSON::PP; } + or fatal("Error loading the Perl module JSON::PP needed for $protocol update."); JSON::PP->import(qw/decode_json encode_json/); }