Bonjour Luc,
You found a bug, In 3.4, amanda automatically prepend a '^' and append a
'$' to the labelstr, It should be done only when using the autolabel
template.
I applied the attached patch to fix the issue.
The work around is to set labelstr to "000[0-9][0-9][0-9].*"
Jean-Louis
On 01/05/17 09:19 PM, Luc Lalonde wrote:
Hello Folks,
Since upgrading to 3.4.3 I seem to having problems with Amanda recognizing my
tapes.
Here’s the ‘labelstr’ directive in my ‘amanda.conf’:
labelstr "^000[0-9][0-9][0-9]*”
This worked fine when I was running version 3.3.4-1… But now, I’m getting
errors.
Here are examples of some of my labels:
000253L5
000254L5
000276L5
000267L5
000228L
000213L
000219L
I commented out the ‘labelstr’ directive and things are working fine… I just
have one Amanda config using tapes…
Can someone explain what changed?
Thank You!
This message is the property of CARBONITE, INC. and may contain confidential or
privileged information.
If this message has been delivered to you by mistake, then do not copy or
deliver this message to anyone. Instead, destroy it and notify me by reply
e-mail
diff --git a/common-src/match.c b/common-src/match.c
index a0cdca5..78118f4 100644
--- a/common-src/match.c
+++ b/common-src/match.c
@@ -1139,6 +1139,7 @@ illegal:
static char *
make_template(
+ const gboolean add_begin_and_end,
const char *al_template,
const char *barcode,
const char *meta,
@@ -1150,7 +1151,8 @@ make_template(
if (al_template == NULL)
at = "";
- *t++ = '^';
+ if (add_begin_and_end)
+ *t++ = '^';
while (*at != '\0') {
if (*at == '$') {
at++;
@@ -1206,10 +1208,12 @@ make_template(
}
}
at++;
- } else if (*at == '$' || *at == '\0') {
+ } else if (*at == '$') {
/* two $, copy one */
- /* $ at end, copy it */
*t++ = *at++;
+ } else if (*at == '\0') {
+ /* $ at end, copy it */
+ *t++ = '$';
} else {
/* Copy the $ and continue withthe next character */
*t++ = *at;
@@ -1235,7 +1239,8 @@ make_template(
*t++ = *at++;
}
}
- *t++ = '$';
+ if (add_begin_and_end)
+ *t++ = '$';
*t = '\0';
return template;
@@ -1250,7 +1255,7 @@ match_labelstr_template(
const char *meta,
const char *storage)
{
- char *ztemplate = make_template(template, barcode, meta, storage);
+ char *ztemplate = make_template(FALSE, template, barcode, meta, storage);
int result;
result = match(ztemplate, label);
@@ -1271,9 +1276,9 @@ match_labelstr(
int result;
if (labelstr->match_autolabel) {
- template = make_template(autolabel->template, barcode, meta, storage);
+ template = make_template(TRUE, autolabel->template, barcode, meta, storage);
} else {
- template = make_template(labelstr->template, barcode, meta, storage);
+ template = make_template(FALSE, labelstr->template, barcode, meta, storage);
}
result = match(template, label);
g_free(template);
diff --git a/installcheck/Amanda_Util.pl b/installcheck/Amanda_Util.pl
index 013aa6f..2af2128 100644
--- a/installcheck/Amanda_Util.pl
+++ b/installcheck/Amanda_Util.pl
@@ -18,7 +18,7 @@
# Contact information: Carbonite Inc., 756 N Pastoria Ave
# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
-use Test::More tests => 130;
+use Test::More tests => 139;
use lib '@amperldir@';
use warnings;
@@ -414,3 +414,32 @@ is_deeply(Amanda::Util::unmarshal_tapespec(0, "\\\\\\:3"), # three slashes
is_deeply(Amanda::Util::unmarshal_tapespec(0, "\\\\\\\\:3"), # four slashes
[ undef, "\\\\", [3] ],
"four slashes escape to two");
+
+my $labelstr = {'match_autolabel'=> 0,
+ 'template' => ""};
+my $autolabel = {'autolabel'=> 0,
+ 'template' => ""};
+$labelstr->{'template'} = "^000[0-9][0-9][0-9]L[0-9]\$";
+is(Amanda::Util::match_labelstr($labelstr, $autolabel, "000123L7", undef, undef, undef), 1, "match_labelstr 1");
+$labelstr->{'template'} = "^000[0-9][0-9][0-9]L\$";
+is(Amanda::Util::match_labelstr($labelstr, $autolabel, "000123L7", undef, undef, undef), '', "match_labelstr 2");
+$labelstr->{'template'} = "^000[0-9][0-9][0-9]L[0-9]";
+is(Amanda::Util::match_labelstr($labelstr, $autolabel, "000123L7", undef, undef, undef), 1, "match_labelstr 3");
+$labelstr->{'template'} = "^000[0-9][0-9][0-9]L";
+is(Amanda::Util::match_labelstr($labelstr, $autolabel, "000123L7", undef, undef, undef), 1, "match_labelstr 4");
+$labelstr->{'template'} = "000[0-9][0-9][0-9]L[0-9]\$";
+is(Amanda::Util::match_labelstr($labelstr, $autolabel, "000123L7", undef, undef, undef), 1, "match_labelstr 5");
+$labelstr->{'template'} = "00[0-9][0-9][0-9]L[0-9]\$";
+is(Amanda::Util::match_labelstr($labelstr, $autolabel, "000123L7", undef, undef, undef), 1, "match_labelstr 6");
+
+$labelstr = {'match_autolabel'=> 1,
+ 'template' => ""};
+$autolabel = {'autolabel'=> 0,
+ 'template' => ""};
+$autolabel->{'template'} = "000[0-9][0-9][0-9]L[0-9]";
+is(Amanda::Util::match_labelstr($labelstr, $autolabel, "000123L7", undef, undef, undef), 1, "match_labelstr 7");
+$autolabel->{'template'} = "000[0-9][0-9][0-9]L";
+is(Amanda::Util::match_labelstr($labelstr, $autolabel, "000123L7", undef, undef, undef), '', "match_labelstr 8");
+$autolabel->{'template'} = "00[0-9][0-9][0-9]L[0-9]";
+is(Amanda::Util::match_labelstr($labelstr, $autolabel, "000123L7", undef, undef, undef), '', "match_labelstr 9");
+