Hello Michael,

In looking at the code, I am not sure why the leading | was not skipped.  In 
any case, it looks like a bug, so I have made the following change, which 
should fix it:

Index: src/lib/lex.c
===================================================================
--- src/lib/lex.c       (revision 6019)
+++ src/lib/lex.c       (working copy)
@@ -174,7 +174,7 @@


    if (fname[0] == '|') {
-      if ((bpipe = open_bpipe(fname, 0, "rb")) == NULL) {
+      if ((bpipe = open_bpipe(fname+1, 0, "rb")) == NULL) {
          free(fname);
          return NULL;
       }

Concerning modifying lex.c not to skip spaces (your second hunk at -572) -- 
that seems to me very likely to introduce another bug.  I suspect that you 
need it because you are not quoting the command line string with double 
quotes.  If you want an argument to be passed in to Bacula in full, you 
*must* enclose it in double quotes not single quotes.  So, it seems to me 
that your example, if written as the following ...

  ... -c "|sed s/foo/bar/g <file>"

should work fine.  I haven't actually tried it though.  If that doesn't work, 
then I suggest putting everything into a single script file.  

Best regards,

Kern


On Friday 14 December 2007 07:10, Michael Stapelberg wrote:
> Hi Kern,
>
> firstly thanks for 'your' great backup program. I use it since quite some
> time and finally got my RAID-5 with enough capacity to backup all machines
> here.
>
> The problem is now: The configuration looks nearly identical for every
> machine and it's a real pain to set it up the ordinary way (pain as in
> 'copy & paste').
>
> So, I thought of a way to make this easier, for example by specifing
> variables in included configuration files. I then found out that one could
> basically do this already, as filenames can be pipes and sed is just fine
> to replace variables ;-).
>
> However, I noticed that the parser (src/lib/lex.c) stops after whitespace
> which is quite unuseful: you'll only get '|sed' instead of '|sed
> "s/foo/bar/g" <file>'.
>
> Also, in src/lib/bpipe.c when building the argv-list, the leading | sign
> isn't skipped. Here is a patch I've made for this:
>
>
> --- bpipe.c   2007-06-07 16:46:43.000000000 +0200
> +++ /Users/michael/Desktop/bacula-2.2.6/src/lib/bpipe.c       2007-12-13
> 20:15:56.000000000 +0100 @@ -280,7 +280,7 @@
>
>     p = cmd;
>     quote = 0;
> -   while  (*p && (*p == ' ' || *p == '\t'))
> +   while  (*p && (*p == ' ' || *p == '\t' || *p == '|'))
>        p++;
>     if (*p == '\"' || *p == '\'') {
>        quote = *p;
> --- lex.c     2007-08-19 08:13:00.000000000 +0200
> +++ /Users/michael/Desktop/bacula-2.2.6/src/lib/lex.c 2007-12-13
> 20:18:00.000000000 +0100 @@ -572,7 +572,7 @@
>              token = T_ERROR;
>              break;
>           }
> -         if (B_ISSPACE(ch) || ch == '\n' || ch == L_EOL || ch == '}' || ch
> == '{' || +         if (ch == '\n' || ch == L_EOL || ch == '}' || ch == '{'
> || ch == ';' || ch == ','   || ch == '"' || ch == '#') { /* Keep the
> original LEX so we can print an error if the included file can't be opened.
> */ LEX* lfori = lf;
>
> Hunk #2 is probably a workaround and could break some other parsing which I
> don't use in my configuration files and therefore probably don't notice.
>
> Please have a look at it and find a better solution for hunk #2 if
> possible. It would be nice to have working pipe handling in future
> versions.
>
> Thanks in advance,
> Michael Stapelberg
>
> PS: I've also attached the patch-file in case you don't like copy & paste
> from mails ;-)

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bacula-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to