Nathan,

Thanks for reporting the issue.
I committed the attached patch.

Jean-Louis

On 15/03/17 05:45 PM, Nathan Stratton Treadway wrote:
> I'm running Amanda 3.4.3 (built under Ubuntu from Jose's Debian
> "experimental" source package, v3.4.3-1).
>
> The man page for "amlabel" includes the following paragraph:
>         Label 'label' doesn't match labelstr 'labelstr'
>             The given label does not match the configured labelstr. Even with
>             -f, this is an error.
> ... but in practice it lets me create labels that don't match without
> any warning:
>
> ======
> # amgetconf TestBackup labelstr
> "^TESTBACKUP-[0-9][0-9]*$"
>
> # su backup -c "amlabel TestBackup BLAH-05 slot 5"
> Reading label...
> Found an empty tape.
> Writing label 'BLAH-05'...
> Checking label...
> Success!
>
> # grep BLAH tapelist
> 0 BLAH-05 reuse BLOCKSIZE:32 POOL:TestBackup STORAGE:TestBackup 
> CONFIG:TestBackup
> ======
>
>
> Other commands do show that the label doesn't match the labelstr, though:
> ======
> # su backup -c "amtape TestBackup show 1,5"
> slot   1: date X              label TESTBACKUP-01
> slot   5: date X              label BLAH-05 (label do not match labelstr)
> ======
>
>
> Am I correct that amlabel should be refusing to create this non-matching
> label?
>
> Thanks.
>
>                                                       Nathan
>
> ----------------------------------------------------------------------------
> Nathan Stratton Treadway  -  natha...@ontko.com  -  Mid-Atlantic region
> Ray Ontko & Co.  -  Software consulting services  -   http://www.ontko.com/
>   GPG Key: http://www.ontko.com/~nathanst/gpg_key.txt   ID: 1023D/ECFB6239
>   Key fingerprint = 6AD8 485E 20B9 5C71 231C  0C32 15F3 ADCD ECFB 6239
>
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/installcheck/amlabel.pl b/installcheck/amlabel.pl
index 165f455..86619d9 100644
--- a/installcheck/amlabel.pl
+++ b/installcheck/amlabel.pl
@@ -138,7 +138,7 @@ like($Installcheck::Run::stdout,
 ok(!run('amlabel', 'TESTCONF', 'SomeTape'),
     "amlabel refuses to write on a  tape already labeled");
 like($Installcheck::Run::stdout,
-    qr/Reading label...\nLabel 'TESTCONF92' doesn't match the labelstr 'TESTCONF\[0-9\]\[0-9\]'/,
+    qr/Reading label...\nFound label 'TESTCONF92' but it doesn't match the labelstr 'TESTCONF\[0-9\]\[0-9\]'/,
     "with correct message on stdout");
 like($Installcheck::Run::stderr,
     qr/Not writing label./,
diff --git a/perl/Amanda/Label.pm b/perl/Amanda/Label.pm
index 6d3cb3e..ad16ece 100644
--- a/perl/Amanda/Label.pm
+++ b/perl/Amanda/Label.pm
@@ -669,7 +669,7 @@ sub label {
 		$self->user_msg(Amanda::Label::Message->new(
 					source_filename => __FILE__,
 					source_line => __LINE__,
-					code      => 1000013,
+					code      => 1000016,
 					severity  => $Amanda::Message::ERROR,
 					label     => $label,
 					labelstr  => $labelstr));
@@ -768,7 +768,21 @@ sub label {
 	    }
 	}
 
-	if ($dev_ok) {
+	if ($params{'label'} && $dev_ok) {
+	    my $barcode = $res->{'barcode'};
+	    my $meta = $meta;
+
+	    if (!match_labelstr($labelstr, $autolabel, $params{'label'}, $barcode, $meta, $storage_name)) {
+		return $steps->{'releasing'}->(Amanda::Label::Message->new(
+					source_filename => __FILE__,
+					source_line => __LINE__,
+					code      => 1000013,
+					severity  => $Amanda::Message::ERROR,
+					label     => $label,
+					labelstr  => $labelstr));
+	    }
+	}
+	if ($dev_ok){
 	    $self->user_msg(Amanda::Label::Message->new(
 				source_filename => __FILE__,
 				source_line => __LINE__,

Reply via email to