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


Groups > comp.lang.python > #81607

Re: Quotation Ugliness

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'root': 0.05; 'defaults': 0.07; 'modifying': 0.07; 'perl,': 0.07; 'string': 0.09; 'executes': 0.09; 'machines.': 0.09; 'ruby,': 0.09; 'skip:/ 10': 0.09; 'used.': 0.09; 'whatever.': 0.09; 'will,': 0.09; '"quote"': 0.16; '-tkc': 0.16; 'bash,': 0.16; 'fails.': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'pairs': 0.16; 'sudo': 0.16; 'wrote:': 0.18; 'examples': 0.20; 'command': 0.22; '(in': 0.22; 'shell': 0.22; 'instance,': 0.24; 'parse': 0.24; 'password.': 0.24; 'question': 0.24; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'tim': 0.29; "doesn't": 0.30; 'characters': 0.30; 'along': 0.30; 'code': 0.31; 'chase': 0.31; 'directory,': 0.31; 'quotes': 0.31; 'remotely': 0.31; 'linux': 0.33; 'cases': 0.33; 'checking': 0.33; 'could': 0.34; 'but': 0.35; 'edge': 0.36; 'processed': 0.36; 'charset:us- ascii': 0.36; 'received:10': 0.37; 'remote': 0.38; 'problems': 0.38; 'machines': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'quote': 0.39; 'visual': 0.39; 'to:addr:python.org': 0.39; 'most': 0.60; 'matter': 0.61; 'first': 0.61; 'freebsd': 0.84; 'boxes,': 0.91
X-Sender-Id wwwh|x-authuser|tim@thechases.com
X-Sender-Id wwwh|x-authuser|tim@thechases.com
X-MC-Relay Neutral
X-MailChannels-SenderId wwwh|x-authuser|tim@thechases.com
X-MailChannels-Auth-Id wwwh
X-MC-Loop-Signature 1417015243880:1444174468
X-MC-Ingress-Time 1417015243880
Date Wed, 26 Nov 2014 09:23:11 -0600
From Tim Chase <python.list@tim.thechases.com>
To python-list@python.org
Subject Re: Quotation Ugliness
In-Reply-To <5475EAB3.7060503@tundraware.com>
References <grifkb-kpo1.ln1@ozzie.tundraware.com> <mailman.16304.1416966896.18130.python-list@python.org> <54756D5F.4040806@tundraware.com> <mailman.16320.1417007333.18130.python-list@python.org> <5475EAB3.7060503@tundraware.com>
X-Mailer Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-AuthUser tim@thechases.com
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.16348.1417027777.18130.python-list@python.org> (permalink)
Lines 58
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1417027777 news.xs4all.nl 2831 [2001:888:2000:d::a6]:58570
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81607

Show key headers only | View raw


On 2014-11-26 08:58, Tim Daneliuk wrote:
> On 11/26/2014 06:56 AM, Tim Chase wrote:
> > On 2014-11-26 00:04, Tim Daneliuk wrote:
> >> someprog.py uname && sudo cat /etc/sudoers
> >>
> >> vs.
> >>
> >> someprog.py uname && echo "sudo cat /etc/suoders"
> >>
> >>
> >> In the first instance, I need the sudo passoword, in the second I
> >> don't.
> >
> > This doesn't jibe with the pairs of quotes you sent and your
> > request for nesting.  In most popular shells, the majority of
> > your "quote" characters don't actually quote anything:
> >
> >    bash$ echo // hello
> >    // hello
> >    bash$ echo /* hello */
> >    [returns all the items in my root directory, the word "hello",
> >    along with all the sub-directories in the current directory]
> >    bash$ echo this#and#that
> >    this#and#that
> >    bash$ echo this # and #that
> >    this
> >
> > and has problems with things like
> >
> >    someprog.py uname && su""do cat /etc/sudoers
> >    someprog.py uname && s"ud"o cat /etc/sudoers
> >
> > which my shell will parse valid execution of sudo.
> 
> I am not writing in bash,  but in python.
> 
> The specific program in question I am modifying is one that takes a
> shell command and executes it remotely on many machines. 

While my examples used bash, it doesn't matter whether your local
code is Python, Perl, Ruby, Lua, or Visual Basic:  you have to parse
the string like it's the shell on those remote machines that parses
for whether sudo is used.  This could be bash, zsh, tcsh, sh, pdksh,
dash, or whatever.  The particular shell doesn't matter (in the
abstract). What matters is that you are checking whether a command
that will be processed by one of these remote shells will need a
password.  To do that, you need to parse the string as that
particular shell would.  Usually, on Linux boxes, this is bash, while
on FreeBSD defaults to tcsh, and OpenBSD defaults to pdksh.

Unless you successfully parse it like your target shell will, you
will have edge cases where the quoting fails.

-tkc



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


Thread

Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-25 18:18 -0600
  Re: Quotation Ugliness Tim Chase <python.list@tim.thechases.com> - 2014-11-25 18:40 -0600
    Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-25 19:18 -0600
      Re: Quotation Ugliness Chris Angelico <rosuav@gmail.com> - 2014-11-26 12:32 +1100
        Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 00:00 -0600
        Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 00:00 -0600
    Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-25 19:18 -0600
  Re: Quotation Ugliness Chris Angelico <rosuav@gmail.com> - 2014-11-26 11:44 +1100
    Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-25 19:20 -0600
    Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-25 19:20 -0600
      Re: Quotation Ugliness Tim Chase <python.list@tim.thechases.com> - 2014-11-25 19:44 -0600
        Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 00:01 -0600
        Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 00:01 -0600
  Re: Quotation Ugliness Ben Finney <ben+python@benfinney.id.au> - 2014-11-26 12:54 +1100
    Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 00:04 -0600
    Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 00:04 -0600
      Using a password with ‘sudo’ (was: Quotation Ugliness) Ben Finney <ben+python@benfinney.id.au> - 2014-11-26 18:02 +1100
      Re: Quotation Ugliness Chris Angelico <rosuav@gmail.com> - 2014-11-26 18:10 +1100
        Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 08:59 -0600
        Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 08:59 -0600
      Re: Quotation Ugliness Tim Chase <python.list@tim.thechases.com> - 2014-11-26 06:56 -0600
        Re: Quotation Ugliness Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-11-26 15:45 +0200
          Re: Quotation Ugliness Chris Angelico <rosuav@gmail.com> - 2014-11-27 01:37 +1100
          Re: Quotation Ugliness Tim Chase <python.list@tim.thechases.com> - 2014-11-26 08:26 -0600
          Re: Quotation Ugliness Chris Angelico <rosuav@gmail.com> - 2014-11-27 02:07 +1100
          Re: Quotation Ugliness Chris Angelico <rosuav@gmail.com> - 2014-11-27 02:09 +1100
            Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 09:36 -0600
            Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 09:36 -0600
              Re: Quotation Ugliness Chris Angelico <rosuav@gmail.com> - 2014-11-27 02:48 +1100
                Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 09:55 -0600
                Re: Quotation Ugliness random832@fastmail.us - 2014-11-26 11:00 -0500
                Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 10:02 -0600
                Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 10:02 -0600
                Re: Quotation Ugliness Chris Angelico <rosuav@gmail.com> - 2014-11-27 03:13 +1100
                Re: Quotation Ugliness random832@fastmail.us - 2014-11-26 11:16 -0500
                Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 10:54 -0600
                Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 10:54 -0600
                Re: Quotation Ugliness alister <alister.nospam.ware@ntlworld.com> - 2014-11-26 16:45 +0000
                Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 10:54 -0600
                Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 09:55 -0600
              Re: Quotation Ugliness random832@fastmail.us - 2014-11-26 10:53 -0500
        Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 08:58 -0600
        Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 08:58 -0600
          Re: Quotation Ugliness Chris Angelico <rosuav@gmail.com> - 2014-11-27 02:06 +1100
          Re: Quotation Ugliness Tim Chase <python.list@tim.thechases.com> - 2014-11-26 09:23 -0600
          Re: Quotation Ugliness Ben Finney <ben+python@benfinney.id.au> - 2014-11-27 07:24 +1100
      Re: Quotation Ugliness random832@fastmail.us - 2014-11-26 09:12 -0500
        Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 09:02 -0600
        Re: Quotation Ugliness Tim Daneliuk <tundra@tundraware.com> - 2014-11-26 09:02 -0600
          Re: Quotation Ugliness random832@fastmail.us - 2014-11-26 10:16 -0500

csiph-web