BackupPC-users

Re: [BackupPC-users] Pre/PostUserCmd: More than one?

2013-09-18 02:31:18
Subject: Re: [BackupPC-users] Pre/PostUserCmd: More than one?
From: Craig Barratt <cbarratt AT users.sourceforge DOT net>
To: "General list for user discussion, questions and support" <backuppc-users AT lists.sourceforge DOT net>
Date: Tue, 17 Sep 2013 23:29:49 -0700
As people have noted, BackupPC uses exec() for shell commands, not system().  The main reason for that is security - it's easy to be sloppy with system() and create unintended vulnerabilities.

However, it is still easy to be explicit about how the arguments are grouped and passed to the command.  Instead of using quotes, which won't work, you can use a list instead of a simple string.

For example, to execute this command:

bash -c "touch /var/lock/backuppc/BackupPC; $sshPath -q -x -l root $host touch /var/lock/backuppc/BackupPC"'

you should be able to do this:

$Conf{DumpPreUserCmd} = ['bin/bash', '-c', 'touch /var/lock/backuppc/BackupPC; $sshPath -q -x -l root $host touch /var/lock/backuppc/BackupPC'];

This should run /bin/bash with the two arguments.

Craig

------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. 
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/