Your message dated Thu, 12 Jun 2014 06:03:47 +0000
with message-id <[email protected]>
and subject line Bug#750544: fixed in autopkgtest 2.18
has caused the Debian Bug report #750544,
regarding broken shstring support
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
750544: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=750544
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: autopkgtest
Version: 2.17
Severity: normal

I'm implementing an ssh driver for autopkgtest and current support of shstring has several major issues:
- adt-run always calls auxverb command
- shell strings are not quoted properly

This patch is an attempt to fix them.

Thanks for considering it.

--
Jean-Baptiste Lallement
Canonical Services Ltd.
IRC: jibel
>From 89c328064fe30e7644402f9dc2d6b975d35050cb Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Lallement <[email protected]>
Date: Wed, 4 Jun 2014 12:07:12 +0200
Subject: [PATCH] Fixed shstring handling

* Merged print-auxverb-command and print-shstring-command into
  print-execute-command which return the right command string depending on
  downkind
* Drop perl script when command is an shstring. In this case auxverb and
* shstring are the same
* Added cmd_quote_shstring that returns a shell escaped version of a string if
  downkind is shstring
* Quote the script to run test with quote-shstring
---
 lib/VirtSubproc.py | 43 +++++++++++++++++++------------------------
 runner/adt-run     | 10 ++++++----
 2 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/lib/VirtSubproc.py b/lib/VirtSubproc.py
index b099879..7f2a858 100644
--- a/lib/VirtSubproc.py
+++ b/lib/VirtSubproc.py
@@ -34,6 +34,7 @@ import time
 import re
 import pipes
 import socket
+import shlex
 import shutil
 
 debuglevel = None
@@ -123,12 +124,12 @@ def cmd_close(c, ce):
     cleanup()
 
 
-def cmd_print_auxverb_command(c, ce):
-    return print_command('auxverb', c, ce)
-
-
-def cmd_print_shstring_command(c, ce):
-    return print_command('shstring', c, ce)
+def cmd_print_execute_command(c, ce):
+    global downkind
+    if downkind == 'shstring':
+        return print_command('shstring', c, ce)
+    else:
+        return print_command('auxverb', c, ce)
 
 
 def print_command(which, c, ce):
@@ -167,7 +168,7 @@ def execute_raw(what, instr, timeout, *popenargs, **popenargsk):
 
 
 def execute(cmd_string, cmd_list=[], downp=False, outp=False, timeout=0):
-    cmdl = cmd_string.split()
+    cmdl = shlex.split(cmd_string)
 
     if downp:
         perhaps_down = downs['auxverb']
@@ -267,16 +268,6 @@ def downtmp_remove():
     global downtmp
     execute('rm -rf --', [downtmp], downp=True)
 
-perl_quote_re = re.compile('[^-+=_.,;:() 0-9a-zA-Z]')
-
-
-def perl_quote_1chargroup(m):
-    return '\\x%02x' % ord(m.group(0))
-
-
-def perl_quote(s):
-    return '"' + perl_quote_re.sub(perl_quote_1chargroup, s) + '"'
-
 
 def opened1():
     global down, downkind, downs
@@ -286,13 +277,7 @@ def opened1():
                  'shstring': down + ['sh', '-c']}
     elif downkind == 'shstring':
         downs = {'shstring': down,
-                 'auxverb': ['perl', '-e', '''
-                @cmd=(''' + (','.join(map(perl_quote, down))) + ''');
-                s/'/'\\\\''/g foreach @ARGV;
-                push @cmd, "'$_'" foreach @ARGV;
-                my $argv0=$cmd[0];
-                exec $argv0 @cmd;
-                die "$argv0: $!"''']}
+                 'auxverb': down }
     debug("downs = %s" % str(downs))
 
 
@@ -649,6 +634,16 @@ def cmd_shell(c, ce):
         raise FailedCmd(['not supported by virt server'])
 
 
+def cmd_quote_shstring(c, ce):
+    """ Return a shell escaped version of c if downkind is shstring
+    """
+    global downkind
+    if downkind == 'shstring':
+        return [urllib.quote(pipes.quote(c[1]))]
+    else:
+        return [ce[1]]
+
+
 def command():
     sys.stdout.flush()
     while True:
diff --git a/runner/adt-run b/runner/adt-run
index d6f24c8..c3c71e9 100755
--- a/runner/adt-run
+++ b/runner/adt-run
@@ -903,7 +903,7 @@ class Testbed:
 
         Return exit code.
         '''
-        auxverb = map(urllib.unquote, self.commandr('print-auxverb-command')[0].split(','))
+        cmde = map(urllib.unquote, self.commandr('print-execute-command')[0].split(','))
         timeout = timeouts[kind]
 
         env = list(xenv)  # copy
@@ -917,7 +917,7 @@ class Testbed:
 
         VirtSubproc.timeout_start(timeout)
         try:
-            proc = subprocess.Popen(auxverb + cmdl)
+            proc = subprocess.Popen(cmde + cmdl)
             proc.communicate()
             VirtSubproc.timeout_stop()
         except VirtSubproc.Timeout:
@@ -1352,6 +1352,7 @@ class Test:
         testbed.prepare(dn, 'needs-recommends' in self.restriction_names)
 
     def run(self, tree):
+        global testbed
         # record installed package versions
         if opts.output_dir:
             pkglist = TempTestbedPath(testbed, self.what + '-packages.all', autoclean=False)
@@ -1400,12 +1401,13 @@ class Test:
                      %(t)s 2> >(tee %(e)s >&2) > >(tee %(o)s)
                   ''' % {'t': tb_test_path, 'o': so.tb, 'e': se.tb}
 
+        quoted = testbed.commandr('quote-shstring', [script])[0]
         if 'needs-root' not in self.restriction_names and opts.user is not None:
             if 'root-on-testbed' not in testbed.caps:
                 bomb('cannot change to user %s without root-on-testbed' % opts.user)
-            test_argv = ['su', '-s', '/bin/bash', opts.user, '-c', script]
+            test_argv = ['su', '-s', '/bin/bash', opts.user, '-c', quoted]
         else:
-            test_argv = ['bash', '-c', script]
+            test_argv = ['bash', '-c', quoted]
 
         # run test script
         self._debug('[-----------------------', True)
-- 
2.0.0


--- End Message ---
--- Begin Message ---
Source: autopkgtest
Source-Version: 2.18

We believe that the bug you reported is fixed in the latest version of
autopkgtest, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Martin Pitt <[email protected]> (supplier of updated autopkgtest package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Thu, 12 Jun 2014 07:48:58 +0200
Source: autopkgtest
Binary: autopkgtest
Architecture: source all
Version: 2.18
Distribution: unstable
Urgency: medium
Maintainer: Autopkgtest team <[email protected]>
Changed-By: Martin Pitt <[email protected]>
Description:
 autopkgtest - automatic as-installed testing for Debian packages
Closes: 508660 680122 750544
Changes:
 autopkgtest (2.18) unstable; urgency=medium
 .
   Improvements:
   * adt-run: When running from git, show the current SHA and commit summary of
     HEAD.
 .
   Bug fixes:
   * tests: Fix race in cleaning up ChrootRunner mounts.
   * adt-run: If apt-get update fails on publishing built binaries, retry after
     15 seconds.
   * VirtSubproc.cleanup(): Avoid recursion if something in hook_cleanup()
     bombs.
   * Fix --shell to also work with --output-dir. (LP: #1317078)
 .
   Code cleanup:
   * VirtSubproc: Document and cleanup execute*() functions.
   * Some test robustifications, to avoid making too many assumptions about
     debug output.
   * adt-run: Eliminate usage of testbed "execute" command, which is too
     complicated and limiting. Use "print-execute-command" directly instead.
   * Drop "execute" command.
   * adt-run: Unify Testbed.command() and commandr() methods and make them
     stricter.
   * Add prefixes to all temporary directories.
   * Remove autopkgtest-xenlvm. It has been orphaned since ~ 2008, few to no
     current users, and no maintainer. (Closes: #508660, #680122)
   * Simplify build system.
   * Drop concept of "shstring". All runners must provide an auxverb now,
     possibly with a wrapper and quoting by themselves if their implementation
     can only deal with shell commands. This avoids having to tell apart these
     two cases in adt-run, clarifies the documentation, and greatly simplifies
     the code. (Closes: #750544)
   * qemu: Use low-level IO in runcmd.  This avoids all the Python overhead and
     buffering and is less prone to bytes vs. string issues.
   * qemu: Fix text vs. binary confusion in reading and copying /etc/timezone.
   * schroot: Call schroot command with -q, to avoid stderr spew if the schroot
     has "message-verbosity=verbose".
   * Port to Python 3.
Checksums-Sha1:
 2438b2a9687c797216f77d4cd945a1a921a1a3f3 1703 autopkgtest_2.18.dsc
 b441bab1853f6c265fb3d4941e301fdfac546f93 98206 autopkgtest_2.18.tar.gz
 e26af15b0fbdf13ce6b4ce2ef18e6d487e911a36 84348 autopkgtest_2.18_all.deb
Checksums-Sha256:
 11813563031912bfdbe4735d7b41308857b0c0ad61b98c0a6301af67c2050b30 1703 
autopkgtest_2.18.dsc
 3375047e836399c1be4318fe5cd084f9a096a7ea6049934bbcbdafae834ff8c3 98206 
autopkgtest_2.18.tar.gz
 bf7e73abb2e140997a31576ae06301ca192c082c29d6106d79b90ab8a5f14e4b 84348 
autopkgtest_2.18_all.deb
Files:
 19a78d38b581ed2c56d2d0d930bb8275 84348 devel optional autopkgtest_2.18_all.deb
 eeea055157907b5183566a84ecf6e4e6 1703 devel optional autopkgtest_2.18.dsc
 44fb73fd079c4481d7e9ccaf578504e6 98206 devel optional autopkgtest_2.18.tar.gz

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJTmT+mAAoJENFO8V2v4RNHm34QALjkUmfLD0dGMBFRHX8FvKml
IF1I5BFrPbo/BFgnldvTV2WhPCEjB86HKn5iglh8bojlvMNZfBEjqxzPGuNy1kXC
6Jd+wWRNDvnmeHyuH9ml3Nb1Ob5NUR/ASwqR8Zp/qZMxblZ0Hb88N6zpxiqv07+X
8WZEWyfvew50+iqVYxygo999mDl5aassZCPda5vGL4V3QvOJ72gRs4rfIbIhbD8f
RaS62u9grVveNh938ezN3jzGXhTO1zylKs3S5u+JU5k/C9nUSpw2pM8m2n+5DI/r
C1CzqcFPqoWpLAxcp0LlVw9tL5QSkntJICXYUU/s3lKLvVmSzBTsqOm/hugxsxOs
dB3R6EuHGiW9Do1ihmSDcFcwQBUtzzrjQFv8IXjcbFb/vHbw/NOJCzuQTmapMWU+
7z/tiaDzZX1W5+uaP96WZvpEpvwRRRSTZKAbe8sIQg32Aow8DeHkTTEK6WXSYb0u
Z0KL1XqNIXx1MRXyd+y1FvlZTNZvMrlBNJT3Lb+mq+Esc8l25RE7PgsmCPTPL/46
fWC+Ejj2yZsg3wG3Mxztpk9lZiqeCsspCYBPWg915IHY5lSh1zkXjZQc8vMIYQd6
+FAtIGwRJjWno1uIQBeZYh3+YdUOeOlCKR8y2HcJ8mhz4XBZ7vsXc8GLxHu35hZC
wuQIvHuWde2r/ffBFCXI
=G/jj
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to