Author: Jean-Louis Martineau <martineau@zmanda.com>
Description: application-src/amsamba.pl: Fix for newer samba version
Index: amanda.git/application-src/amsamba.pl
===================================================================
--- amanda.git.orig/application-src/amsamba.pl	2017-01-20 20:06:03.072852865 +0000
+++ amanda.git/application-src/amsamba.pl	2017-01-20 20:09:43.765048470 +0000
@@ -309,6 +309,7 @@ sub findpass {
 		if ($password =~ /^6G\!dr(.*)/) {
 		    my $base64 = $1;
 		    $password = MIME::Base64::decode($base64);
+		    chomp($password);
 		}
 	        $self->{password} = $password;
 		$self->{password} = undef if (defined $password && $password eq "");
@@ -439,13 +440,15 @@ sub command_selfcheck {
 	push @ARGV, "-c", "quit";
 	debug("execute: " . $self->{smbclient} . " " .
 	      join(" ", @ARGV));
+	$ENV{'LC_CTYPE'} = 'en_US.UTF-8';
 	exec {$self->{smbclient}} @ARGV;
     }
     #parent
     if (defined $self->{password}) {
         my $ff = $password_wtr->fileno;
         debug("password_wtr $ff");
-        $password_wtr->print($self->{password});
+        $password_wtr->print("$self->{password}\n");
+        $password_wtr->print("$self->{password}\n");
         $password_wtr->close();
         $password_rdr->close();
     } else {
@@ -457,6 +460,7 @@ sub command_selfcheck {
 	chomp;
 	debug("stderr: " . $_);
 	next if /^Domain=/;
+	next if /^WARNING/g;
 	# message if samba server is configured with 'security = share'
 	next if /Server not using user level security and no password supplied./;
 	$self->print_to_server("smbclient: $_",
@@ -516,14 +520,15 @@ sub command_estimate {
 	}
 	debug("execute: " . $self->{smbclient} . " " .
 	      join(" ", @ARGV));
+	$ENV{'LC_CTYPE'} = 'en_US.UTF-8';
 	exec {$self->{smbclient}} @ARGV;
     }
     #parent
     if (defined $self->{password}) {
         my $ff = $password_wtr->fileno;
         debug("password_wtr $ff");
-        debug("password $self->{password}");
-        $password_wtr->print($self->{password});
+        $password_wtr->print("$self->{password}\n");
+        $password_wtr->print("$self->{password}\n");
         $password_wtr->close();
         $password_rdr->close();
     }
@@ -547,6 +552,7 @@ sub parse_estimate {
 	next if /^\s*$/;
 	next if /^Domain=/;
 	next if /dumped \d+ files and directories/;
+	next if /^WARNING/g;
 	# message if samba server is configured with 'security = share'
 	next if /Server not using user level security and no password supplied./;
 	debug("stderr: $_");
@@ -658,13 +664,15 @@ sub command_backup {
 	push @ARGV, "-c", $comm;
 	debug("execute: " . $self->{smbclient} . " " .
 	      join(" ", @ARGV));
+	$ENV{'LC_CTYPE'} = 'en_US.UTF-8';
 	exec {$self->{smbclient}} @ARGV;
     }
 
     if (defined $self->{password}) {
         my $ff = $password_wtr->fileno;
         debug("password_wtr $ff");
-        $password_wtr->print($self->{password});
+        $password_wtr->print("$self->{password}\n");
+        $password_wtr->print("$self->{password}\n");
         $password_wtr->close();
         $password_rdr->close();
     } else {
@@ -672,11 +680,12 @@ sub command_backup {
     }
     close($smbclient_wtr);
 
-    #index process 
-    my $index_rdr;
+    #index process
     my $index_wtr;
+    my $index_rdr;
+    my $index_err = Symbol::gensym;;
     debug("$self->{gnutar} -tf -");
-    my $pid_index1 = open2($index_rdr, $index_wtr, $self->{gnutar}, "-tf", "-");
+    my $pid_index1 = open3($index_wtr, $index_rdr, $index_err, $self->{gnutar}, "-tf", "-");
     my $size = -1;
     my $index_fd = $index_rdr->fileno;
     debug("index $index_fd");
@@ -694,6 +703,8 @@ sub command_backup {
 				$G_IO_IN|$G_IO_HUP|$G_IO_ERR);
     my $index_tar_stdout_src = Amanda::MainLoop::fd_source($index_rdr,
 				$G_IO_IN|$G_IO_HUP|$G_IO_ERR);
+    my $index_tar_stderr_src = Amanda::MainLoop::fd_source($index_err,
+				$G_IO_IN|$G_IO_HUP|$G_IO_ERR);
 
     my $smbclient_stdout_done = 0;
     my $smbclient_stderr_done = 0;
@@ -742,16 +753,20 @@ sub command_backup {
 	}
 	chomp $line;
 	debug("stderr: " . $line);
-	return if $line =~ /^Domain=/;
-	return if $line =~ /^tarmode is now /;
-	return if $line =~ /^tar_re_search set/;
+	return if $line =~ /Domain=/;
+	return if $line =~ /tarmode is now /;
+	return if $line =~ /tar_re_search set/;
+	return if $line =~ /WARNING/g;
 	if ($line =~ /dumped (\d+) files and directories/) {
 	    $nb_files = $1;
 	    return;
 	}
 	# message if samba server is configured with 'security = share'
 	return if $line =~  /Server not using user level security and no password supplied./;
-	if ($line =~ /^Total bytes written: (\d*)/) {
+	if ($line =~ /Total bytes written: (\d*)/) {
+	    $size = $1;
+	    return;
+	} elsif ($line =~ /Total bytes received: (\d*)/) {
 	    $size = $1;
 	    return;
 	}
@@ -777,6 +792,27 @@ sub command_backup {
 	    }
 	} else {
 	    chomp $line;
+	    if ($line =~ /Ignoring unknown extended header keyword/) {
+		debug("tar stderr: $line");
+	    } else {
+		$self->print_to_server($line, $Amanda::Script_App::ERROR);
+	    }
+	}
+    });
+
+    $index_tar_stderr_src->set_callback(sub {
+	my $line = <$index_err>;
+	if (!defined $line) {
+	    $file_to_close--;
+	    $index_tar_stderr_src->remove();
+	    close($index_err);
+	    Amanda::MainLoop::quit() if $file_to_close == 0;
+	    return;
+	}
+	chomp $line;
+	if ($line =~ /Ignoring unknown extended header keyword/) {
+	    debug("tar stderr: $line");
+	} else {
 	    $self->print_to_server($line, $Amanda::Script_App::ERROR);
 	}
     });
Index: amanda.git/ChangeLog
===================================================================
--- amanda.git.orig/ChangeLog	2017-01-20 20:06:03.072852865 +0000
+++ amanda.git/ChangeLog	2017-01-20 20:06:03.068852861 +0000
@@ -1,3 +1,6 @@
+2016-06-09  Jean-Louis Martineau <JMartineau@carbonite.com>
+	* application-src/amsamba.pl: Fix for newer samba version
+
 2016-02-05  Jean-Louis Martineau <martineau@zmanda.com>
 	* config/libtool.m4, config/ltmain.sh, config/ltoptions.m4,
 	  config/ltsugar.m4, config/ltversion.m4,
