diff mbox series

[v3] elf: Don't remove the initial 'env' command

Message ID 20240209135807.2353939-1-hjl.tools@gmail.com
State New
Headers show
Series [v3] elf: Don't remove the initial 'env' command | expand

Commit Message

H.J. Lu Feb. 9, 2024, 1:58 p.m. UTC
tst-rtld-list-diagnostics.py is called by

"$(test-wrapper-env) $(objpfx)$(rtld-installed-name) --list-diagnostics"

and $(test-wrapper-env) is set to "$(test-wrapper) env".  When there is
a test wrapper, it is incorrect to use:

    # Remove the initial 'env' command.
    parse_diagnostics(opts.command.split()[1:])

to remove 'env' and there is no need to remove 'env'.  Don't remove 'env'
and pass shell=True to run.  This fixes [BZ #31357].
---
 elf/tst-rtld-list-diagnostics.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Florian Weimer Feb. 9, 2024, 2:45 p.m. UTC | #1
* H. J. Lu:

> tst-rtld-list-diagnostics.py is called by
>
> "$(test-wrapper-env) $(objpfx)$(rtld-installed-name) --list-diagnostics"
>
> and $(test-wrapper-env) is set to "$(test-wrapper) env".  When there is
> a test wrapper, it is incorrect to use:
>
>     # Remove the initial 'env' command.
>     parse_diagnostics(opts.command.split()[1:])
>
> to remove 'env' and there is no need to remove 'env'.  Don't remove 'env'
> and pass shell=True to run.  This fixes [BZ #31357].
> ---
>  elf/tst-rtld-list-diagnostics.py | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/elf/tst-rtld-list-diagnostics.py b/elf/tst-rtld-list-diagnostics.py
> index 9e70e74bf8..5e05ebc05c 100644
> --- a/elf/tst-rtld-list-diagnostics.py
> +++ b/elf/tst-rtld-list-diagnostics.py
> @@ -33,7 +33,8 @@ except:
>              self.stdout = stdout
>              self.stderr = stderr
>  
> -    def _run(*popenargs, input=None, timeout=None, check=False, **kwargs):
> +    def _run(*popenargs, input=None, timeout=None, check=False, shell=True,
> +             **kwargs):
>          assert(timeout is None)
>          with subprocess.Popen(*popenargs, **kwargs) as process:
>              try:

I think you need to change the subprocess.run call further down below.

> @@ -293,8 +294,7 @@ def main(argv):
>      if opts.manual:
>          check_consistency_with_manual(opts.manual)
>  
> -    # Remove the initial 'env' command.
> -    parse_diagnostics(opts.command.split()[1:])
> +    parse_diagnostics(opts.command.split()[:])

I would expect

  +    parse_diagnostics(opts.command)

here because we pass the whole thing to the shell as a string.

Thanks,
Florian
diff mbox series

Patch

diff --git a/elf/tst-rtld-list-diagnostics.py b/elf/tst-rtld-list-diagnostics.py
index 9e70e74bf8..5e05ebc05c 100644
--- a/elf/tst-rtld-list-diagnostics.py
+++ b/elf/tst-rtld-list-diagnostics.py
@@ -33,7 +33,8 @@  except:
             self.stdout = stdout
             self.stderr = stderr
 
-    def _run(*popenargs, input=None, timeout=None, check=False, **kwargs):
+    def _run(*popenargs, input=None, timeout=None, check=False, shell=True,
+             **kwargs):
         assert(timeout is None)
         with subprocess.Popen(*popenargs, **kwargs) as process:
             try:
@@ -293,8 +294,7 @@  def main(argv):
     if opts.manual:
         check_consistency_with_manual(opts.manual)
 
-    # Remove the initial 'env' command.
-    parse_diagnostics(opts.command.split()[1:])
+    parse_diagnostics(opts.command.split()[:])
 
     if errors:
         sys.exit(1)