On Fri, 2021-01-29 at 12:41 +0100, Quentin Schulz wrote: > 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 <[email protected]> > > --- > > 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?
Whilst that would be nice, we already effectively use this all over. I'm not adverse to cleaning up all the quoting but I think its a separate topic. If you don't trust our metadata there are much bigger and easier ways to run commands... Cheers, Richard
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#147451): https://lists.openembedded.org/g/openembedded-core/message/147451 Mute This Topic: https://lists.openembedded.org/mt/80207407/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
