Amanda-Users

Re: FW: amrecover problem

2007-05-30 15:19:58
Subject: Re: FW: amrecover problem
From: Jean-Louis Martineau <martineau AT zmanda DOT com>
To: "McGraw, Robert P." <rmcgraw AT purdue DOT edu>
Date: Wed, 30 May 2007 15:06:14 -0400
The regex library you use is more strict than mine.

Try the attached patch.

Jean-Louis

McGraw, Robert P. wrote:
I am forwarding this from my partner SA.  Is this a know problem with a fix
or something newly discovered?

Thanks

Robert


-----Original Message-----
From: Chapman Flack [mailto:jflack AT math.purdue DOT edu]
Sent: Wednesday, May 30, 2007 12:03 PM
To: Robert McGraw
Subject: amrecover


Robert,

Heads up - the cd command seems broken in the latest amrecover. The
cdx command still works though, in case you need to recover something.

Could you forward this to whoever was working with you on patching
other problems in amanda recently? I'm not sure this isn't something
only we are seeing, so I don't know if it's in the exact distributed
sources or it's connected somehow to modifications here.

Here's what happens:

AMRECOVER Version 2.5.2-20070523. Contacting server on zorn ...
220 zorn AMANDA index server (2.5.2-20070523) ready.
Setting restore date to today (2007-05-30)
200 Working date set to 2007-05-30.
200 Config set to daily.
Trying host zorn.math ...
501 Host zorn.math is not in your disklist.
Trying host zorn ...
200 Dump host set to zorn.
Use the setdisk command to choose dump disk to recover
amrecover> setdisk /export/users-j
200 Disk set to /export/users-j.
amrecover> setdate 2007-05-29
200 Working date set to 2007-05-29.
amrecover> cd jflack
amrecover: regex "/jflack/$/": unknown regex error

... and amrecover exits out to the shell.

The trouble seems to be in set_commands.c where cd_glob()
appends a /$ to the target directory, and then calls
cd_dir() which appends another / so the result is a regex
where $ is not the last character, and that's invalid.

Browsing the CVS shows that some of this stuff was changed
in set_commands.c in the last few months. It's kind of
surprising though to have something as noticeable as cd not
working go unnoticed, so I am not sure why I haven't found it
discussed.

The reason cdx still works is it treats the argument you give
as a regex already, so doesn't break it by adding extra
characters.

-Chap

diff -u -r --show-c-function --new-file 
--exclude-from=/home/martinea/src.orig/amanda.diff 
--ignore-matching-lines='$Id:' amanda-2.5.2/recover-src/set_commands.c 
amanda-2.5.2.regex/recover-src/set_commands.c
--- amanda-2.5.2/recover-src/set_commands.c     2007-05-30 15:02:45.000000000 
-0400
+++ amanda-2.5.2.regex/recover-src/set_commands.c       2007-05-30 
15:02:16.000000000 -0400
@@ -413,6 +413,7 @@ cd_dir(
 {
     char *path_on_disk_slash = NULL;
     char *dir = NULL;
+    char *s;
 
     int nb_found;
     size_t i;
@@ -420,14 +421,21 @@ cd_dir(
     DIR_ITEM *ditem;
 
     path_on_disk_slash = stralloc2(path_on_disk, "/");
+    if ((s = validate_regexp(path_on_disk_slash)) != NULL) {
+       amfree(path_on_disk_slash);
+    }
+
+    if ((s = validate_regexp(path_on_disk)) != NULL) {
+       path_on_disk = NULL;
+    }
 
     nb_found = 0;
 
     for (ditem=get_dir_list(); ditem!=NULL && nb_found <= 1; 
                               ditem=get_next_dir_item(ditem))
     {
-       if (match(path_on_disk, ditem->path)
-           || match(path_on_disk_slash, ditem->path))
+       if ((path_on_disk && match(path_on_disk, ditem->path))
+           || (path_on_disk_slash && match(path_on_disk_slash, ditem->path)))
        {
            i = strlen(ditem->path);
            if((i > 0 && ditem->path[i-1] == '/')
<Prev in Thread] Current Thread [Next in Thread>