Control: tag -1 + patch Hi,
Axel Beckert wrote: > I have more and more IPv6-only hosts. But if I add one of them to > hosts.cfg, I always get "host not found" as error message. > > In the documentation under "How BackupPC Finds Hosts", it says: > > > First DNS is used to lookup the IP address given the client's name > > using perl's gethostbyname() function. This should succeed for > > machines that have fixed IP addresses that are known via DNS. You can > > manually see whether a given host have a DNS entry according to perl's > > gethostbyname function with this command: > > > > perl -e 'print(gethostbyname("myhost") ? "ok\n" : "not found\n");' > > Example: > > → host ipv6.google.com > ipv6.google.com is an alias for ipv6.l.google.com. > ipv6.l.google.com has IPv6 address 2a00:1450:4016:80a::200e > $ perl -e 'print(gethostbyname("ipv6.google.com") ? "ok\n" : "not found\n");' > not found > > So I can't backup this host despite SSH has no problem at all to reach > that host. > > BackupPC should probably move to use Socket.pm's getaddrinfo instead as > it is IP-version agnostic. > > So far I found no configuration-only workaround (i.e. disabling DNS > lookups at all as SSH does that already.) Ubuntu ships a patch for this for quite a while now, it is included in e.g. https://patches.ubuntu.com/b/backuppc/backuppc_3.3.1-4ubuntu1.patch Relevant parts seem to me these changes: + - (Inline) apply patch to add support for ipv6. (LP: #54918). Depend and + Build-Depend on libsocket6-perl for that. (LP: #1515986) and diff -pruN 3.3.1-4/lib/BackupPC/Config/Meta.pm 3.3.1-4ubuntu1/lib/BackupPC/Config/Meta.pm --- 3.3.1-4/lib/BackupPC/Config/Meta.pm 2015-01-12 00:19:53.000000000 +0000 +++ 3.3.1-4ubuntu1/lib/BackupPC/Config/Meta.pm 2016-12-15 00:07:34.000000000 +0000 @@ -85,6 +85,7 @@ use vars qw(%ConfigMeta); SshPath => {type => "execPath", undefIfEmpty => 1}, NmbLookupPath => {type => "execPath", undefIfEmpty => 1}, PingPath => {type => "execPath", undefIfEmpty => 1}, + Ping6Path => {type => "execPath", undefIfEmpty => 1}, DfPath => {type => "execPath", undefIfEmpty => 1}, DfCmd => "string", SplitPath => {type => "execPath", undefIfEmpty => 1}, diff -pruN 3.3.1-4/lib/BackupPC/Lib.pm 3.3.1-4ubuntu1/lib/BackupPC/Lib.pm --- 3.3.1-4/lib/BackupPC/Lib.pm 2016-12-15 00:07:33.000000000 +0000 +++ 3.3.1-4ubuntu1/lib/BackupPC/Lib.pm 2016-12-15 00:07:34.000000000 +0000 @@ -46,6 +46,7 @@ use Carp; use File::Path; use File::Compare; use Socket; +use Socket6; use Cwd; use Digest::MD5; use Config; @@ -972,6 +973,7 @@ sub CheckHostAlive { my($bpc, $host) = @_; my($s, $pingCmd, $ret); + my($family, @res, $args); # # Return success if the ping cmd is undefined or empty. @@ -982,10 +984,20 @@ sub CheckHostAlive return 0; } - my $args = { - pingPath => $bpc->{Conf}{PingPath}, - host => $host, - }; + ($family, @res) = getaddrinfo($host, "22"); + if ( $family eq AF_INET ) { + $args = { + pingPath => $bpc->{Conf}{PingPath}, + host => $host, + }; + } + if ( $family eq AF_INET6 ) { + $args = { + pingPath => $bpc->{Conf}{Ping6Path}, + host => $host, + }; + } + $pingCmd = $bpc->cmdVarSubstitute($bpc->{Conf}{PingCmd}, $args); # Regards, Axel -- ,''`. | Axel Beckert <a...@debian.org>, https://people.debian.org/~abe/ : :' : | Debian Developer, ftp.ch.debian.org Admin `. `' | 4096R: 2517 B724 C5F6 CA99 5329 6E61 2FF9 CD59 6126 16B5 `- | 1024D: F067 EA27 26B9 C3FC 1486 202E C09E 1D89 9593 0EDE