Aron,
Thanks for letting me know. Sorry my patch didn't do much. It addressed our 
problem in Katello and I was told spacewalk was having a very similar issue, 
but it sounds like it was much deeper than I was looking. I apologize for 
sending a bogus patch.

regards,

Adam Price

----- Original Message -----
From: "Aron Parsons" <a...@redhat.com>
To: "Jan Pazdziora" <jpazdzi...@redhat.com>, adpr...@redhat.com
Cc: spacewalk-devel@redhat.com
Sent: Monday, June 6, 2011 10:12:08 AM
Subject: Re: [Spacewalk-devel] NOW WITH ATTACHMENTS - patch for accidentally 
grabbing '--help' in shell arguments

Adam,
Thanks for the bug report and patch.  The problem ran deeper than what your 
patch addressed, so I had to fix it another way.

Jan,
The root cause was bin/spacecmd ignoring quoted arguments when handling single 
commands passed in via the command-line; the behavior was correct when commands 
were entered in the interactive shell.  This problem was fixed with commit 
cdcd595b135b72d0f05e89458d160fc76f870b51.  I also improved the handling of 
quoted arguments better in shell.py:precmd().

aron@localhost ~/tech/code/spacecmd $ spacecmd -s satellite -- 
softwarechannel_create -n 'test123 --help' -l 'test123 --help' -a x86_64
INFO: Connected to https://satellite/rpc/api as admin
ERROR: redstone.xmlrpc.XmlRpcFault: Channel label must begin with a letter and 
may contain only lowercase letters, hyphens ('-'), periods ('.'), underscores 
('_'), and numerals.

aron@localhost ~/tech/code/spacecmd $ spacecmd -s satellite -- 
softwarechannel_create -n 'test123 --help' -l 'test123 --help' -a x86_64 --help
INFO: Connected to https://satellite/rpc/api as admin
['softwarechannel_create', '-n', 'test123 --help', '-l', 'test123 --help', 
'-a', 'x86_64', '--help']
softwarechannel_create: Create a software channel
usage: softwarechannel_create [options]

options:
  -n NAME
  -l LABEL
  -p PARENT_CHANNEL
  -a ARCHITECTURE ['ia32', 'ia64', 'x86_64', 'ppc',
                  'i386-sun-solaris', 'sparc-sun-solaris']

The fixes are in spacecmd-1.5.2-1.

/aron

----- Original Message -----
From: Jan Pazdziora <jpazdzi...@redhat.com>
To: spacewalk-devel@redhat.com, apars...@redhat.com
Sent: Mon, 06 Jun 2011 03:11:27 -0400 (EDT)
Subject: Re: [Spacewalk-devel] NOW WITH ATTACHMENTS - patch for accidentally 
grabbing '--help' in shell arguments

On Fri, Jun 03, 2011 at 03:26:37PM -0400, Adam Price wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=710554
> 
> 
> I have attached for review a patch to fix this issue.

[...]

> diff --git a/spacecmd/src/lib/shell.py b/spacecmd/src/lib/shell.py
> index c95655b..df437e8 100644
> --- a/spacecmd/src/lib/shell.py
> +++ b/spacecmd/src/lib/shell.py
> @@ -126,8 +126,10 @@ class SpacewalkShell(Cmd):
>              args = ''
>  
>          # print the help message if the user passes '--help'
> -        if re.search('--help', line):
> -            return 'help %s' % command
> +        line_parts = line.split("\"")
> +        for i in range(0, len(line_parts), 2):
> +            if re.search('--help', line):
> +                return 'help %s' % command

I don't believe the patch is a proper fix.

The bugzilla does not include the exact reproducer, so let's start
with

        $ spacecmd -s 'localhost' -- softwarechannel_create -n 'test123--help' 
-l 'test123--help' -a 'x86_64'

The split line.split("\"") seems to be bogus -- we already have the
line split to parts via

        parts = line.split()
        
and there are no doublequotes in the data to split on anyway.

Of course, there seems to be a more general problem of parsing the
commands:

        $ spacecmd -s 'localhost' -- softwarechannel_create -n 'test123 --help' 
-l 'test123--help' -a 'x86_64'

(not the space in the -n option) gets split by the

        ['softwarechannel_create', '-n', 'test123', '--help', '-l', 
'test123--help', '-a', 'x86_64']

-- so even if they were passed in as proper command line arguments
from the shell to spacecmd, they were probably merged into one line
without proper quoting.

Aron, how are things supposed to work there?

-- 
Jan Pazdziora
Principal Software Engineer, Satellite Engineering, Red Hat

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to