remote runner: better escape commands, don't consume errors
ClosedPublic

Authored by kparal on Aug 26 2015, 11:56 AM.

Details

Summary

If cd fails, the whole command should fail. Better escape taskdir
path.

properly escape arguments when using paramiko

Tested with

runtask -i 'aa;touch /tmp/hacked;echo ' -t koji_build ../task-rpmlint/rpmlint.yml --libvirt --debug
Test Plan

manually ran a test, works

Diff Detail

Repository
rLTRN libtaskotron
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kparal retitled this revision from to remote runner: better escape commands, don't consume errors.Aug 26 2015, 11:56 AM
kparal updated this object.
kparal edited the test plan for this revision. (Show Details)
kparal added reviewers: lbrabec, jskladan.

taskdir is not getting escaped, if you really, really wanted to escape it, use subprocess.list2cmdline instead of ' ' .join().

But at least half of your patch does what you wanted, so...

Macro freddie: don't stop me now from acking the patch

jskladan accepted this revision.Aug 27 2015, 7:48 AM
This revision is now accepted and ready to land.Aug 27 2015, 7:48 AM
lbrabec requested changes to this revision.Aug 27 2015, 7:53 AM

pipes.quote(str) should do the trick

This revision now requires changes to proceed.Aug 27 2015, 7:53 AM

taskdir is not getting escaped, if you really, really wanted to escape it, use subprocess.list2cmdline instead of ' ' .join().

But at least half of your patch does what you wanted, so...

Haha, you're at least half right, subprocess.list2cmdline seems to be used for MS shell escaping ;-)

Thanks, though!

kparal updated this revision to Diff 1400.Aug 27 2015, 8:30 AM
kparal updated this object.
  • properly escape arguments when using paramiko

    Tested with ` runtask -i 'aa;touch /tmp/hacked;echo ' -t koji_build ../task-rpmlint/rpmlint.yml --libvirt --debug `
lbrabec accepted this revision.Aug 27 2015, 8:32 AM

LGTM

This revision is now accepted and ready to land.Aug 27 2015, 8:32 AM
In D536#10087, @kparal wrote:

Haha, you're at least half right, subprocess.list2cmdline seems to be used for MS shell escaping ;-)

You kids, and your cheapo-UNIX-clones...

This revision was automatically updated to reflect the committed changes.