Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for 3 bugs in amsamba #48

Closed
platbr opened this issue Aug 19, 2013 · 7 comments
Closed

Fix for 3 bugs in amsamba #48

platbr opened this issue Aug 19, 2013 · 7 comments

Comments

@platbr
Copy link

platbr commented Aug 19, 2013

--- amsamba.original    2013-08-19 00:22:26.532825367 -0300
+++ amsamba     2013-08-19 00:23:41.271825238 -0300
@@ -160,6 +160,7 @@
            if (defined $self->{'subdir'}) {
                $_ =~ s/^\./$self->{'subdir'}/;
            }
+           $_ =~ s/([0-7]{3})/chr oct $1/eg;
            print INC_FILE "$_\n";
        }

@@ -634,7 +635,7 @@
        }
        $comm .= " tar c";
        if ($#{$self->{exclude}} >= 0) {
-           $comm .= "X";
+           $comm .= "rX";
        }
        if ($#{$self->{include}} >= 0) {
            $comm .= "I";
@@ -735,13 +736,13 @@
        debug("stderr: " . $line);
        return if $line =~ /^Domain=/;
        return if $line =~ /^tarmode is now/;
+       return if $line =~ /^tar_re_search set/;
        if ($line =~ /dumped (\d+) files and directories/) {
            $nb_files = $1;
            return;
        }
-
        # message if samba server is configured with 'security = share'
-       return if $line =~ $line =~  /Server not using user level security and no password supplied./;
+      return if $line =~ /Server not using user level security and no password supplied./;
        if ($line =~ /^Total bytes written: (\d*)/) {
            $size = $1;
            return;
+          $_ =~ s/([0-7]{3})/chr oct $1/eg;

Fix a problem when try to restore files in SMB mode with non ascii characters (like áàâãäåāăąèééêëēĕėęěìíîïìĩīĭḩóôõöōŏőùúûüũūŭůäàáâãåæçćĉčöòóôõøüùúûßéèêëýñîìíïş).

-           $comm .= "X";
+            $comm .= "rX";
+        return if $line =~ /^tar_re_search set/;

Fix a problem when try to exclude files in dumptype, it makes possible to use WILD Cards ? and *, need smbclient compiled with HAVE_REGEX_H.

-       return if $line =~ $line =~  /Server not using user level security and no password supplied./;
+      return if $line =~ /Server not using user level security and no password supplied./;

Fix problem like this one:

Unmatched ( in regex; marked by <-- HERE in m/NT_STATUS_OK opening remote file design_grafico_17a_legislatura - deputadosdep_carlosantonio??3CT VISITADOSmosaico.ai ( <-- HERE design_grafico_17a_legislatura - deputadosdep_carlosantonio??3CT VISITADOS)/ at /usr/libexec/amanda/application/amsamba line 743, line 4.]

Slashes need to be escaped to avoid \ to make part of a regex, like \2013 to be understood as octal followed by a "3".

After this fix look the real smbclient line for the error above:
NT_STATUS_OK opening remote file \design_grafico_17a_legislatura - deputados\dep_carlosantonio\2013\CT VISITADOS\mosaico.ai (\design_grafico_17a_legislatura - deputados\dep_carlosantonio\2013\CT VISITADOS)

@martineau
Copy link

Using:
$comm .= "rX";
Change the behavior of amsamba, i would prefer if you add a new property, eg 'use-regex' and add the 'r' only when use-regex is set.

For:
return if $line =~ $line =~ /Server not using user level security and no password supplied./;
The bug is the double ' $line =', can you try with:
return if $line =
/Server not using user level security and no password supplied./;

@platbr platbr closed this as completed Aug 19, 2013
@platbr platbr reopened this Aug 19, 2013
@platbr
Copy link
Author

platbr commented Aug 19, 2013

martineau, i'm not a developer and the double "$line =" drove me nuts trying to understand WHY?
But i guess that it still need the "m/\Q$line\E/ =
", i will try and update.

About the "$comm .= "rX";" where a simple resolution for a problem that i saw a lot of people reported (exclude does not works).

@platbr
Copy link
Author

platbr commented Aug 20, 2013

martineau, u were right about the the double "$line =~".

@martineau
Copy link

About the line:
$_ =~ s/([0-7]+)/chr oct $1/eg;

I do not like to match any number of digit, is it always 3 digits? or anything between 1 and 3?
We could use:
$_ =~ s/([0-7]{3})/chr oct $1/eg;
or:
$_ =~ s/([0-7]{1,3})/chr oct $1/eg;

@platbr
Copy link
Author

platbr commented Aug 20, 2013

martineau,
I agree about it must to be 3 digits:
$_ =~ s/([0-7]{3})/chr oct $1/eg;

@platbr platbr closed this as completed Aug 20, 2013
@platbr platbr reopened this Aug 20, 2013
@martineau
Copy link

I committed a fix

The smbclient man page say that 'r' can be very slow. it is enabled only with a property.
I added a 'regex-match' property, the 'r' mode is enabled only if the property is set to "YES".

I have no setup to try amsamba, can you try the committed patch?

@platbr
Copy link
Author

platbr commented Feb 14, 2014

Using this SAMBA mod https://bitbucket.org/knarf/samba/get/gsoc_clitar_libarchive.tar.bz2 exclude will work.
You will need http://www.4shared.com/folder/6mEYgOcb/libarchive_3_for_rhel6.html to compile it in RHEL6 or Centos 6.

More info: http://diobla.info/doc/gsoc13/journal

I tested with amanda 3.3.5 and RHEL6 and had to change only this in amanda:

--- /usr/libexec/amanda/application/amsamba.original    2014-02-14 13:17:26.422232351 -0200
+++ /usr/libexec/amanda/application/amsamba     2014-02-14 13:55:57.470228421 -0200
@@ -744,6 +744,7 @@
        debug("stderr: " . $line);
        return if $line =~ /^Domain=/;
        return if $line =~ /^tarmode is now /;
+       return if $line =~ /^tar:[0-9 ]*tarmode is now /;
        return if $line =~ /^tar_re_search set/;
        if ($line =~ /dumped (\d+) files and directories/) {
            $nb_files = $1;
@@ -751,7 +752,7 @@
        }
        # 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*)|^tar:[0-9 ]*Total bytes received: (\d*)/) {
            $size = $1;
            return;
        }
@@ -829,6 +830,7 @@
    my($size) = -1;
    while(<$fhin>) {
       next if /^Total bytes written:/;
+      next if /^tar:[0-9 ]*Total bytes received:/;
       next if !/^\.\//;
       s/^\.//;
       print $fhout $_;

@platbr platbr closed this as completed Feb 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants