← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 685115] Re: Incorrect use of subprocess module

 

Hello Michael,

You're right, thanks for the analysis and the proposed patch! 
This has been fixed in trunk in revision 3075 - odo@xxxxxxxxxxx-20101207170551-o19ab06g1h2x3ygz from ~xrg (author of the original Popen patch)

I am assigning to maintenance team as well for backport to 5.0, as the
original patch had been applied there as well.

** Changed in: openobject-server
   Importance: Undecided => Medium

** Changed in: openobject-server
       Status: New => Fix Released

** Changed in: openobject-server
    Milestone: None => 6.0-rc2

** Changed in: openobject-server
     Assignee: (unassigned) => OpenERP's Framework R&D (openerp-dev-framework)

** Also affects: openobject-server/5.0
   Importance: Undecided
       Status: New

** Changed in: openobject-server/5.0
   Importance: Undecided => Medium

** Changed in: openobject-server/5.0
       Status: New => Confirmed

** Changed in: openobject-server/5.0
    Milestone: None => 5.0.16

** Changed in: openobject-server/5.0
     Assignee: (unassigned) => Jay (OpenERP) (jvo-openerp)

** Tags added: maintenance

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/685115

Title:
  Incorrect use of subprocess module

Status in OpenObject Server:
  Fix Released
Status in OpenObject Server 5.0 series:
  Confirmed

Bug description:
  I'm using OpenERP 5.0.15

In tools/misc.py: exec_pg_command_pipe() and exec_command_pipe() in the arguments to the subprocess.Popen() function the command name is supplied as the executable parameter and shell=True.  This is wrong.  If shell=True, then executable has to be the path to the shell, as explained in the following paragraph from http://docs.python.org/library/subprocess.html :

The executable argument specifies the program to execute. It is very seldom needed: Usually, the program to execute is defined by the args argument. If shell=True, the executable argument specifies which shell to use. On Unix, the default shell is /bin/sh.

The above two functions have been working up to now only by accident.  The subprocess module will spawn the /bin/sh shell and try to execute the first element in the argument list tuple.  The first element is the command name (without the full path), but since the command is usually in the shell's path it will succeed.  However if , for example, the pg_* commands were not in the shell's path (for example in /usr/lib/pgsql/bin) then it would fail.

Patch is attached.





References