[Bug 1060192] [NEW] needless shell=True in a subprocess.Popen call

David Black 1060192 at bugs.launchpad.net
Tue Oct 2 13:23:47 UTC 2012


Public bug reported:

Whilst there is no issue with the following use of subprocess.Popen with
shell=True today there is no reason to use it with shell=True in this
instance.


In softwareproperties/MirrorTest.py on line 29 (through to line 34) under the PingWorker the following code is found:

                   host = mirror.hostname

                    self.parent.report_action("Pinging %s..." % host)
                    commando = subprocess.Popen("ping -q -c 2 -W 1 -i 0.5 %s" % host,
                                                shell=True, stdout=subprocess.PIPE,
                                                stderr=subprocess.STDOUT).stdout


The code should be changed to something like the following:

                    commando = subprocess.Popen(["ping", "-q", "-c 2", "-W 1",  "-i 0.5", host]
                                                , stdout=subprocess.PIPE,
                                                stderr=subprocess.STDOUT).stdout

** Affects: software-properties (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to software-properties in Ubuntu.
https://bugs.launchpad.net/bugs/1060192

Title:
  needless shell=True in a subprocess.Popen call

Status in “software-properties” package in Ubuntu:
  New

Bug description:
  Whilst there is no issue with the following use of subprocess.Popen
  with shell=True today there is no reason to use it with shell=True in
  this instance.

  
  In softwareproperties/MirrorTest.py on line 29 (through to line 34) under the PingWorker the following code is found:

                     host = mirror.hostname

                      self.parent.report_action("Pinging %s..." % host)
                      commando = subprocess.Popen("ping -q -c 2 -W 1 -i 0.5 %s" % host,
                                                  shell=True, stdout=subprocess.PIPE,
                                                  stderr=subprocess.STDOUT).stdout

  
  The code should be changed to something like the following:

                      commando = subprocess.Popen(["ping", "-q", "-c 2", "-W 1",  "-i 0.5", host]
                                                  , stdout=subprocess.PIPE,
                                                  stderr=subprocess.STDOUT).stdout

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/software-properties/+bug/1060192/+subscriptions




More information about the foundations-bugs mailing list