As far as I understand subprocess.getstatusoutput is actually doing the
same and also we're using "sh -c" in that command anyway. There is one case
where "PATCHFILE="%s" is passed at the beginning of "cmd" variable so we
would need to modify this file to stop doing that and pass it through env
argument.

Best regards,
Tomasz Dziendzielski

pt., 29 sty 2021 o 12:41 Quentin Schulz <quentin.sch...@streamunlimited.com>
napisaƂ(a):

> Hi Tomasz,
>
> On Fri, Jan 29, 2021 at 12:38:08PM +0100, Tomasz Dziendzielski wrote:
> > If a function returns any stderr it will be passed to extractPatches and
> > used as path to patch.
> >
> > For example subprocess command output can be:
> > | sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
> > | /tmp/oepatchhuqle8fj/0001-foo.patch
> > | /tmp/oepatchhuqle8fj/0002-bar.patch
> >
> > that will result in:
> > | FileNotFoundError: [Errno 2] No such file or directory: 'sh:'
> >
> > To fix this I separated output, made the function return stdout and
> > print stderr only in case of command error.
> >
> > Signed-off-by: Tomasz Dziendzielski <tomasz.dziendziel...@gmail.com>
> > ---
> >  meta/lib/oe/patch.py | 14 +++++++++-----
> >  1 file changed, 9 insertions(+), 5 deletions(-)
> >
> > diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
> > index 40755fbb03..8ad70f53f1 100644
> > --- a/meta/lib/oe/patch.py
> > +++ b/meta/lib/oe/patch.py
> > @@ -38,15 +38,19 @@ def runcmd(args, dir = None):
> >          args = [ pipes.quote(str(arg)) for arg in args ]
> >          cmd = " ".join(args)
> >          # print("cmd: %s" % cmd)
> > -        (exitstatus, output) = subprocess.getstatusoutput(cmd)
> > +        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
> stderr=subprocess.PIPE, shell=True)
>
> I'd rather avoid having shell=True passed to Popen, read
> https://docs.python.org/3/library/subprocess.html#security-considerations
>
> Can't we just use args directly instead of cmd in Popen to avoid using
> shell=True?
>
> Cheers,
> Quentin
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#147450): 
https://lists.openembedded.org/g/openembedded-core/message/147450
Mute This Topic: https://lists.openembedded.org/mt/80207407/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to