Re: [pve-devel] run_command and shellquote

2014-11-04 Thread Dietmar Maurer
 sub run_command {
 my ($cmd, %param) = @_;
 
 my $old_umask;
 my $cmdstr;
 
 if (!ref($cmd)) {
 $cmdstr = $cmd;
 if ($cmd =~ m/|/) {
 # see 'man bash' for option pipefail
 $cmd = [ '/bin/bash', '-c', set -o pipefail  $cmd ];
 } else {
 $cmd = [ $cmd ];
 }
 } else {
 $cmdstr = cmd2string($cmd);

This $cmdstr is only used for logging!

___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


Re: [pve-devel] run_command and shellquote

2014-11-04 Thread Michael Rasmussen
On Tue, 4 Nov 2014 17:39:56 +
Dietmar Maurer diet...@proxmox.com wrote:

 
 This $cmdstr is only used for logging!
 
See now. A failing command got me confused when the error message
contained quotes.

-- 
Hilsen/Regards
Michael Rasmussen

Get my public GnuPG keys:
michael at rasmussen dot cc
http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xD3C9A00E
mir at datanom dot net
http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xE501F51C
mir at miras dot org
http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xE3E80917
--
/usr/games/fortune -es says:
Kitchen activity is highlighted.  Butter up a friend.


pgpd5kVeG4S_e.pgp
Description: OpenPGP digital signature
___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


Re: [pve-devel] run_command and shellquote

2014-11-03 Thread Michael Rasmussen
On Mon, 3 Nov 2014 05:00:59 +
Dietmar Maurer diet...@proxmox.com wrote:

 
 Why does shell quoting make the command fail? I thought shell quoting should 
 not have any effect on
 how the command receives parameters?
 
This is the particular code:
my @ssh_opts = ('-o', 'BatchMode=yes');
my @ssh_cmd = ('/usr/bin/ssh', @ssh_opts);


my @params = ('set', refreservation=$size, $path);
my $target = 'root@' . $scfg-{portal};
my $cmd = [@ssh_cmd, '-i', $id_rsa_path/$scfg-{portal}_id_rsa,
$target, 'zfs', @params];

-- 
Hilsen/Regards
Michael Rasmussen

Get my public GnuPG keys:
michael at rasmussen dot cc
http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xD3C9A00E
mir at datanom dot net
http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xE501F51C
mir at miras dot org
http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xE3E80917
--
/usr/games/fortune -es says:
My weight is perfect for my height -- which varies.


pgp3j4PYqtfkK.pgp
Description: OpenPGP digital signature
___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


Re: [pve-devel] run_command and shellquote

2014-11-03 Thread Dietmar Maurer
  Why does shell quoting make the command fail? I thought shell quoting should
 not have any effect on
  how the command receives parameters?
 
 This is the particular code:
 my @ssh_opts = ('-o', 'BatchMode=yes');
 my @ssh_cmd = ('/usr/bin/ssh', @ssh_opts);
 
 
 my @params = ('set', refreservation=$size, $path);
 my $target = 'root@' . $scfg-{portal};
 my $cmd = [@ssh_cmd, '-i', $id_rsa_path/$scfg-{portal}_id_rsa,
 $target, 'zfs', @params];

Beside, we do not quote anything. The $cmd array is directly passed top open3():

$pid = open3($writer, $reader, $error, @$cmd) || die $!;

So I cannot reproduce what you talk about.

___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


[pve-devel] run_command and shellquote

2014-11-02 Thread Michael Rasmussen
Hi Dietmar,

A command needs to be run like this:
/usr/bin/ssh -o 'BatchMode=yes'
-i /etc/pve/priv/zfs/192.168.3.145_id_rsa root@192.168.3.145 zfs set
refreservation=4g tank/vm-100-disk-1

but due to run_command applies shellquote which will apply quotes to
the param refreservation=4g because of '=' to the command the command
ends up like this:
/usr/bin/ssh -o 'BatchMode=yes'
-i /etc/pve/priv/zfs/192.168.3.145_id_rsa root@192.168.3.145 zfs set
'refreservation=4g' tank/vm-100-disk-1

which causes it to fail.

Any way to prevent shellquote to apply qoutes to refreservation=4g ?

-- 
Hilsen/Regards
Michael Rasmussen

Get my public GnuPG keys:
michael at rasmussen dot cc
http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xD3C9A00E
mir at datanom dot net
http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xE501F51C
mir at miras dot org
http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xE3E80917
--
/usr/games/fortune -es says:
What is a magician but a practising theorist?
-- Obi-Wan Kenobi


pgpJElRTXWNfT.pgp
Description: OpenPGP digital signature
___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


Re: [pve-devel] run_command and shellquote

2014-11-02 Thread Dietmar Maurer
 but due to run_command applies shellquote which will apply quotes to the
 param refreservation=4g because of '=' to the command the command ends up
 like this:
 /usr/bin/ssh -o 'BatchMode=yes'
 -i /etc/pve/priv/zfs/192.168.3.145_id_rsa root@192.168.3.145 zfs set
 'refreservation=4g' tank/vm-100-disk-1
 
 which causes it to fail.
 
 Any way to prevent shellquote to apply qoutes to refreservation=4g ?

Why does shell quoting make the command fail? I thought shell quoting should 
not have any effect on
how the command receives parameters?

___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel