Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #77395

Re: subprocess module usage

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <earl.lapus@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'output': 0.05; 'detect': 0.07; 'any)': 0.09; 'appropriate.': 0.09; 'arguments': 0.09; 'executed': 0.09; 'subject:module': 0.09; 'wrong,': 0.09; 'cc:addr :python-list': 0.11; 'command.': 0.16; 'subject:usage': 0.16; 'weird': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'command': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; 'fairly': 0.24; 'mon,': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'on,': 0.29; 'words': 0.29; 'errors': 0.30; 'returned': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'invoke': 0.31; 'sep': 0.31; 'this.': 0.32; 'open': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'executing': 0.36; "i'll": 0.36; 'should': 0.36; 'so,': 0.37; 'clear': 0.37; 'being': 0.38; 'pm,': 0.38; 'sure': 0.39; 'commands': 0.60; "you're": 0.61; "you'll": 0.62; 'to:addr:gmail.com': 0.65; 'yourself': 0.78; 'glad': 0.83; 'low': 0.83; 'malicious': 0.84; 'earl': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=x6e14TJUusGSDJWVZcaUYQGU3txrc8AJ0e3zRDx7498=; b=KJ/iDcQoj70+jU7hEdiZxbFpZf+ic4QU/qpGYkrbSjPCxhXSt7c/XuC6O47uUrRXpl KAR/uVdGia2l1YSCwVK1RB6WdXwsVvuYXXGk/IRj3wC8chixYajgUZgmIAOCsO3QpWWt 6wzewBH+L+uEnqPjBUoBUx+VpFdQAmt0/0s6aNmealLhxLQszuQg41wZcEfnMIam4iI8 yfJQg5wg+7nIatW7BLqOK/d96pN5EkCxVq4pp8NZU4pYKUrcF900+v7p0hgKUEdBvaZ7 y0JNs+ST4g4sysQjI/3jlKnrRGviRGYmBFyYke50vj+RL4y0IHtA5NWP5J1FmGZLO8xx 4uGw==
MIME-Version 1.0
X-Received by 10.180.80.225 with SMTP id u1mr19032705wix.69.1409553195617; Sun, 31 Aug 2014 23:33:15 -0700 (PDT)
In-Reply-To <CAPTjJmroWHW6TRj_TG5Dy8hUtQs5ALEZv+ygdz4hHTH43oKK1A@mail.gmail.com>
References <CAPrJNb4_m-1sqwzUcqnHR6jTFo-Tp=a1hLgTvXrujXW5sAUkpg@mail.gmail.com> <CAPTjJmrq-azU3CvKi9FqxXNYALJu_cF-WtjTcB4YDnTectyCCA@mail.gmail.com> <CAPrJNb7Ur9sTqhWoxMWzTFCBJkLrm--rW8aq_aK36w9meYDG-A@mail.gmail.com> <CAPTjJmroWHW6TRj_TG5Dy8hUtQs5ALEZv+ygdz4hHTH43oKK1A@mail.gmail.com>
Date Mon, 1 Sep 2014 14:33:15 +0800
Subject Re: subprocess module usage
From Earl Lapus <earl.lapus@gmail.com>
To Chris Angelico <rosuav@gmail.com>
Content-Type text/plain; charset=UTF-8
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.13684.1409553202.18130.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1409553202 news.xs4all.nl 2879 [2001:888:2000:d::a6]:58178
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77395

Show key headers only | View raw


On Mon, Sep 1, 2014 at 1:39 PM, Chris Angelico <rosuav@gmail.com> wrote:
>
> Glad it's working! But please, don't just take my word for it and make
> a black-box change to your code. When you invoke subprocesses, be sure
> you understand what's going on, and when shell=True is appropriate and
> when shell=False is appropriate. The docs should be fairly clear on
> this. If you get this sort of thing wrong, you'll get weird errors
> like this (if you're lucky), or open yourself up to shell injection
> vulnerabilities (if you're not).
>

The command and arguments that will be passed to check_output will not
depend on user input. So, the chances of malicious commands from being
executed would be low (right?).
What I'm really after is just to execute a specific command and 1)
retrieve it's output (if any) 2) detect any error returned while
executing the command. Anyway, I'll take your advise and review the
documentation again.

Cheers,
Earl

-- 
There are seven words in this sentence.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: subprocess module usage Earl Lapus <earl.lapus@gmail.com> - 2014-09-01 14:33 +0800

csiph-web