Bacula-users

Re: [Bacula-users] How to properly escape Linux shell commands for ClientRunBeforeJob?

2009-02-16 08:58:51
Subject: Re: [Bacula-users] How to properly escape Linux shell commands for ClientRunBeforeJob?
From: Frank Sweetser <fs AT WPI DOT EDU>
To: Ralf Brinkmann <ralf.brinkmann AT wemhoener DOT de>
Date: Mon, 16 Feb 2009 08:56:34 -0500
Ralf Brinkmann wrote:
> Foo schrieb:
> 
>> So I added in the job definition of the machine:
>>
>> ClientRunBeforeJob = "svnadmin --quiet dump /var/svnrepo
>>> /tmp/svnrepo_backup.svn_dump; gzip -9 /tmp/svnrepo_backup.svn_dump"
>> ClientRunAfterJob = "rm -f /tmp/svnrepo_backup.svn_dump.gz"
>>
>> This fails with:
>>
>>   ClientRunBeforeJob: svnadmin: invalid option character: 9
>>   ClientRunBeforeJob: Type 'svnadmin help' for usage.
>>   Error: Runscript: ClientRunBeforeJob returned non-zero status=1.
>> ERR=Child exited with code 1
> 
> (Client)RunBefore/AfterJob:
> sticking commands one after another on one line separated by semicolon
> seems not to work propperly.

That's because treating the semicolon as a command separator is a function of
the shell.  The problem isn't that you're not escaping the shell characters,
the problem is that there's no shell there to treat them as special characters
in the first place.  From the RunScript section of
http://bacula.org/en/rel-manual/Configuring_Director.html#SECTION001430000000000000000

--8<--
In addition, the command string is parsed then fed to the OS, which means that
the path will be searched to execute your specified command, but there is no
shell interpretation, as a consequence, if you invoke complicated commands or
want any shell features such as redirection or piping, you must call a shell
script and do it inside that script.
--8<--

-- 
Frank Sweetser fs at wpi.edu  |  For every problem, there is a solution that
WPI Senior Network Engineer   |  is simple, elegant, and wrong. - HL Mencken
    GPG fingerprint = 6174 1257 129E 0D21 D8D4  E8A3 8E39 29E3 E2E8 8CEC

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users