6917caa
Index: configure.pl
6917caa
===================================================================
6917caa
RCS file: /cvsroot/backuppc/BackupPC/configure.pl,v
6917caa
retrieving revision 1.51
6917caa
diff -u -w -r1.51 configure.pl
6917caa
--- configure.pl	12 Jan 2015 00:56:40 -0000	1.51
6917caa
+++ configure.pl	17 Oct 2016 10:42:05 -0000
6917caa
@@ -253,6 +253,7 @@
6917caa
     nmblookup      => "NmbLookupPath",
6917caa
     rsync          => "RsyncClientPath",
6917caa
     ping           => "PingPath",
6917caa
+    'ping6/ping'   => "PingPath6",
6917caa
     df             => "DfPath",
6917caa
     'ssh/ssh2'     => "SshPath",
6917caa
     sendmail       => "SendmailPath",
6917caa
Index: bin/BackupPC_dump
6917caa
===================================================================
6917caa
RCS file: /cvsroot/backuppc/BackupPC/bin/BackupPC_dump,v
6917caa
retrieving revision 1.51
6917caa
diff -u -w -r1.51 BackupPC_dump
6917caa
--- bin/BackupPC_dump	12 Jan 2015 00:56:40 -0000	1.51
6917caa
+++ bin/BackupPC_dump	17 Oct 2016 10:42:05 -0000
6917caa
@@ -493,7 +493,7 @@
6917caa
     } else {
6917caa
         $host = $client;
6917caa
     }
6917caa
-    if ( !defined(gethostbyname($host)) ) {
6917caa
+    if ( !defined($bpc->resolve($host)) ) {
6917caa
         #
6917caa
         # Ok, NS doesn't know about it.  Maybe it is a NetBios name
6917caa
         # instead.
6917caa
Index: bin/BackupPC_restore
6917caa
===================================================================
6917caa
RCS file: /cvsroot/backuppc/BackupPC/bin/BackupPC_restore,v
6917caa
retrieving revision 1.36
6917caa
diff -u -w -r1.36 BackupPC_restore
6917caa
--- bin/BackupPC_restore	12 Jan 2015 00:56:40 -0000	1.36
6917caa
+++ bin/BackupPC_restore	17 Oct 2016 10:42:05 -0000
6917caa
@@ -167,7 +167,7 @@
6917caa
 # Find its IP address
6917caa
 #
6917caa
 if ( $hostIP !~ /\d+\.\d+\.\d+\.\d+/ ) {
6917caa
-    if ( !defined(gethostbyname($host)) ) {
6917caa
+    if ( !defined($bpc->resolve($host)) ) {
6917caa
 	#
6917caa
 	# Ok, NS doesn't know about it.  Maybe it is a NetBios name
6917caa
 	# instead.
6917caa
Index: conf/config.pl
6917caa
===================================================================
6917caa
RCS file: /cvsroot/backuppc/BackupPC/conf/config.pl,v
6917caa
retrieving revision 1.58
6917caa
diff -u -w -r1.58 config.pl
6917caa
--- conf/config.pl	12 Jan 2015 00:56:40 -0000	1.58
6917caa
+++ conf/config.pl	17 Oct 2016 10:42:06 -0000
6917caa
@@ -1652,9 +1652,24 @@
6917caa
 $Conf{PingPath} = '';
6917caa
 
6917caa
 #
6917caa
+# Like PingPath, but for IPv6.  Security caution: normal users
6917caa
+# should not be allowed to write to this file or directory.
6917caa
+# In some environments, this is something like '/usr/bin/ping6'.
6917caa
+# In modern environments, the regular ping command can handle both
6917caa
+# IPv4 and IPv6. In the latter case, just set it to  $Conf{PingPath}
6917caa
+#
6917caa
+# If you want to disable ping checking for IPv6 hosts, set this to
6917caa
+# some program that exits with 0 status, eg:
6917caa
+#
6917caa
+#     $Conf{PingPath6} = '/bin/echo';
6917caa
+#
6917caa
+$Conf{PingPath6} = '';
6917caa
+
6917caa
+#
6917caa
 # Ping command.  The following variables are substituted at run-time:
6917caa
 #
6917caa
-#   $pingPath      path to ping ($Conf{PingPath})
6917caa
+#   $pingPath      path to ping ($Conf{PingPath} or $Conf{PingPath6})
6917caa
+#                  depending on the address type of $host.
6917caa
 #   $host          host name
6917caa
 #
6917caa
 # Wade Brown reports that on solaris 2.6 and 2.7 ping -s returns the wrong
6917caa
Index: lib/BackupPC/Config.pm
6917caa
===================================================================
6917caa
RCS file: /cvsroot/backuppc/BackupPC/lib/BackupPC/Config.pm,v
6917caa
retrieving revision 1.3
6917caa
diff -u -w -r1.3 Config.pm
6917caa
--- lib/BackupPC/Config.pm	2 Aug 2003 08:01:43 -0000	1.3
6917caa
+++ lib/BackupPC/Config.pm	17 Oct 2016 10:42:06 -0000
6917caa
@@ -269,6 +269,9 @@
6917caa
     PingPath                     => {struct => 'SCALAR',
6917caa
                                      type   => 'STRING', },
6917caa
 
6917caa
+    PingPath6                    => {struct => 'SCALAR',
6917caa
+                                     type   => 'STRING', },
6917caa
+
6917caa
     PingArgs                     => {struct => 'SCALAR',
6917caa
                                      type   => 'STRING', },
6917caa
 
6917caa
Index: lib/BackupPC/Lib.pm
6917caa
===================================================================
6917caa
RCS file: /cvsroot/backuppc/BackupPC/lib/BackupPC/Lib.pm,v
6917caa
retrieving revision 1.53
6917caa
diff -u -w -r1.53 Lib.pm
6917caa
--- lib/BackupPC/Lib.pm	12 Jan 2015 00:56:41 -0000	1.53
6917caa
+++ lib/BackupPC/Lib.pm	17 Oct 2016 10:42:06 -0000
6917caa
@@ -982,7 +982,7 @@
6917caa
     }
6917caa
 
6917caa
     my $args = {
6917caa
-	pingPath => $bpc->{Conf}{PingPath},
6917caa
+	pingPath => $bpc->getPingPathByAddressType( $host ),
6917caa
 	host     => $host,
6917caa
     };
6917caa
     $pingCmd = $bpc->cmdVarSubstitute($bpc->{Conf}{PingCmd}, $args);
6917caa
@@ -1543,4 +1543,27 @@
6917caa
     return $glob;
6917caa
 }
6917caa
 
6917caa
+#
6917caa
+# Attempts to resolve a hostname.
6917caa
+# Return 4 if it resolves to an IPv4 address, 6 if it resolves to an IPv6
6917caa
+# address or undef if it can not be resolved.
6917caa
+#
6917caa
+sub resolve
6917caa
+{
6917caa
+    my ( $bpc, $host ) = @_;
6917caa
+    my ( $err, @addrs ) = Socket::getaddrinfo($host);
6917caa
+    return undef if ( $err );
6917caa
+    return (($addrs[0])->{'family'} == Socket::AF_INET6) ? 6 : 4;
6917caa
+}
6917caa
+
6917caa
+#
6917caa
+# Return pingPath depending on address type of target.
6917caa
+#
6917caa
+sub getPingPathByAddressType
6917caa
+{
6917caa
+    my ( $bpc, $host ) = @_;
6917caa
+    my $at = $bpc->resolve( $host ) || 4;
6917caa
+    return ($at == 6) ? $bpc->{Conf}{PingPath6} : $bpc->{Conf}{PingPath};
6917caa
+}
6917caa
+
6917caa
 1;
6917caa
Index: lib/BackupPC/CGI/EditConfig.pm
6917caa
===================================================================
6917caa
RCS file: /cvsroot/backuppc/BackupPC/lib/BackupPC/CGI/EditConfig.pm,v
6917caa
retrieving revision 1.29
6917caa
diff -u -w -r1.29 EditConfig.pm
6917caa
--- lib/BackupPC/CGI/EditConfig.pm	12 Jan 2015 00:56:41 -0000	1.29
6917caa
+++ lib/BackupPC/CGI/EditConfig.pm	17 Oct 2016 10:42:06 -0000
6917caa
@@ -86,6 +86,7 @@
6917caa
 	    {name => "SshPath"},
6917caa
 	    {name => "NmbLookupPath"},
6917caa
 	    {name => "PingPath"},
6917caa
+	    {name => "PingPath6"},
6917caa
 	    {name => "DfPath"},
6917caa
 	    {name => "SplitPath"},
6917caa
 	    {name => "ParPath"},
6917caa
Index: lib/BackupPC/Config/Meta.pm
6917caa
===================================================================
6917caa
RCS file: /cvsroot/backuppc/BackupPC/lib/BackupPC/Config/Meta.pm,v
6917caa
retrieving revision 1.28
6917caa
diff -u -w -r1.28 Meta.pm
6917caa
--- lib/BackupPC/Config/Meta.pm	12 Jan 2015 00:56:41 -0000	1.28
6917caa
+++ lib/BackupPC/Config/Meta.pm	17 Oct 2016 10:42:06 -0000
6917caa
@@ -85,6 +85,7 @@
6917caa
     SshPath	 	=> {type => "execPath", undefIfEmpty => 1},
6917caa
     NmbLookupPath 	=> {type => "execPath", undefIfEmpty => 1},
6917caa
     PingPath	 	=> {type => "execPath", undefIfEmpty => 1},
6917caa
+    PingPath6	 	=> {type => "execPath", undefIfEmpty => 1},
6917caa
     DfPath	 	=> {type => "execPath", undefIfEmpty => 1},
6917caa
     DfCmd	 	=> "string",
6917caa
     SplitPath	 	=> {type => "execPath", undefIfEmpty => 1},