swift-get-nodes cli don't handle space in arguments

Bug #1791302 reported by Guillaume
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Invalid
Undecided
Guillaume

Bug Description

When you try to locate a container and his name contains a space whenever you url encode the space, swift-get-node will encode the '%' and you won't be able to locate the container.

Guillaume (vatlas)
Changed in swift:
assignee: nobody → Guillaume (vatlas)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (master)

Fix proposed to branch: master
Review: https://review.openstack.org/600789

Changed in swift:
status: New → In Progress
Revision history for this message
Guillaume (vatlas) wrote :

You can't put space directly as argument are positional.
If you try to url encode the space like that :

swift-get-nodes /etc/swift/container.ring.gz AUTH_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx truc%20de%20ouf

'%' character will be also encoded:
curl -g -I -XHEAD "http://xxx.xxx.xxx.xxx:xxxx/xxx/5778/AUTH_xxxxxxxxxxxxxxxxxxxxxxxxxxxx/truc%2520de%2520ouf"

Revision history for this message
Tim Burke (1-tim-z) wrote :

Does it work better if you quote the command line arg? Something like

    swift-get-nodes /etc/swift/container.ring.gz \
        AUTH_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 'truc de ouf'

Revision history for this message
Guillaume (vatlas) wrote :

quote with this arguments return 'invalid arguments' but if I remove the last one:

swift-get-nodes /etc/swift/container.ring.gz \
    AUTH_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 'truc de'

Account AUTH_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Container truc
Object de

Revision history for this message
Tim Burke (1-tim-z) wrote :

Well now I'm confused. Locally, I'm seeing http://paste.openstack.org/show/729764/ -- quoting the container name in my shell ensures that it gets treated as a singular argument, and swift-get-nodes takes care of URL-encoding when it prints out URLs.

I'm starting to grasp at straws here, but what shell are you using? What OS? If I try strace-ing it in bash on my Ubuntu 18.04 VM:

 $ strace -e trace=%process swift-get-nodes /etc/swift/container.ring.gz AUTH_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 'truc de ouf'
 execve("/usr/local/bin/swift-get-nodes", ["swift-get-nodes", "/etc/swift/container.ring.gz", "AUTH_xxxxxxxxxxxxxxxxxxxxxxxxxxx"..., "truc de ouf"], 0x7ffe7367e878 /* 25 vars */) = 0

Those execve args should translate directly to sys.argv when we actually get to Python-land...

Revision history for this message
Guillaume (vatlas) wrote :

Okay, so it's not in swift code ...

But I have the same args when I strace it :
execve("/usr/local/bin/swift-get-nodes", ["/usr/local/bin/swift-get-nodes", "/etc/swift/container.ring.gz", "AUTH_xxxxxxxxxxxxxxxxxxxxxxxxxxx"..., "truc de ouf"], [/* 19 vars */]) = 0

Guillaume (vatlas)
Changed in swift:
status: In Progress → Invalid
Revision history for this message
Guillaume (vatlas) wrote :

After better dig, I figure out the issue happen only on my environment and I have fixed it, thanks Time Burke for the help.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on swift (master)

Change abandoned by Guillaume (<email address hidden>) on branch: master
Review: https://review.openstack.org/600789
Reason: The bug was closed, and it was not related to swift code.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to swift (master)

Reviewed: https://review.opendev.org/724141
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=1dfa41dada30c139129cb2771b0d68c95fd84e32
Submitter: Zuul
Branch: master

commit 1dfa41dada30c139129cb2771b0d68c95fd84e32
Author: Tim Burke <email address hidden>
Date: Tue Apr 28 10:45:27 2020 -0700

    swift-get-nodes: Allow users to specify either quoted or unquoted paths

    Now that we can have null bytes in Swift paths, we need a way for
    operators to be able to locate such containers and objects. Our usual
    trick of making sure the name is properly quoted for the shell won't
    suffice; running something like

       swift-get-nodes /etc/swift/container.ring.gz $'AUTH_test/\0versions\0container'

    has the path get cut off after "AUTH_test/" because of how argv works.

    So, add a new option, --quoted, to let operators indicate that they
    already quoted the path.

    Drive-bys:

      * If account, container, or object are explicitly blank, treat them
        as though they were not provided. This provides better errors when
        account is explicitly blank, for example.
      * If account, container, or object are not provided or explicitly
        blank, skip printing them. This resolves abiguities about things
        like objects whose name is actually "None".
      * When displaying account, container, and object, quote them (since
        they may contain newlines or other control characters).

    Change-Id: I3d10e121b403de7533cc3671604bcbdecb02c795
    Related-Change: If912f71d8b0d03369680374e8233da85d8d38f85
    Closes-Bug: #1875734
    Closes-Bug: #1875735
    Closes-Bug: #1875736
    Related-Bug: #1791302

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to swift (feature/losf)

Related fix proposed to branch: feature/losf
Review: https://review.opendev.org/735381

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to swift (feature/losf)
Download full text (20.6 KiB)

Reviewed: https://review.opendev.org/735381
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=481f126e6b59689599f438e5d27f7328f5b3e813
Submitter: Zuul
Branch: feature/losf

commit 51a587ed8dd5700b558ad26d70dcb7facc0f91e4
Author: Tim Burke <email address hidden>
Date: Tue Jun 16 11:34:01 2020 -0700

    Use ensure-pip role

    Hopefully this will fix the currently-broken probe test gate?

    Depends-On: https://review.opendev.org/#/c/736070/
    Change-Id: Ib652534b35236fdb6bcab131c7dc08a079bf72f6

commit 79811df34c84b416ce9f445926b31a23a32ea1a4
Author: Tim Burke <email address hidden>
Date: Fri Apr 10 22:02:57 2020 -0700

    Use ini_file to update timeout instead of crudini

    crudini seems to have trouble on py3 -- still not sure *why* it's using
    py3 for the losf job, though...

    Change-Id: Id98055994c8d59e561372417c9eb4aec969afc6a

commit e4586fdcde5267f39056bb1b5f413a411bb8e7a0
Author: Tim Burke <email address hidden>
Date: Tue Jun 9 10:50:07 2020 -0700

    memcached: Plumb logger into MemcacheRing

    This way proxies log memcached errors in the normal way instead of
    to the root logger (which eventually gets them out on STDERR).

    If no logger is provided, fall back to the root logger behavior.

    Change-Id: I2f7b3e7d5b976fab07c9a2d0a9b8c0bd9a840dfd

commit 1dfa41dada30c139129cb2771b0d68c95fd84e32
Author: Tim Burke <email address hidden>
Date: Tue Apr 28 10:45:27 2020 -0700

    swift-get-nodes: Allow users to specify either quoted or unquoted paths

    Now that we can have null bytes in Swift paths, we need a way for
    operators to be able to locate such containers and objects. Our usual
    trick of making sure the name is properly quoted for the shell won't
    suffice; running something like

       swift-get-nodes /etc/swift/container.ring.gz $'AUTH_test/\0versions\0container'

    has the path get cut off after "AUTH_test/" because of how argv works.

    So, add a new option, --quoted, to let operators indicate that they
    already quoted the path.

    Drive-bys:

      * If account, container, or object are explicitly blank, treat them
        as though they were not provided. This provides better errors when
        account is explicitly blank, for example.
      * If account, container, or object are not provided or explicitly
        blank, skip printing them. This resolves abiguities about things
        like objects whose name is actually "None".
      * When displaying account, container, and object, quote them (since
        they may contain newlines or other control characters).

    Change-Id: I3d10e121b403de7533cc3671604bcbdecb02c795
    Related-Change: If912f71d8b0d03369680374e8233da85d8d38f85
    Closes-Bug: #1875734
    Closes-Bug: #1875735
    Closes-Bug: #1875736
    Related-Bug: #1791302

commit 1b6c8f7fdf630458affe2778fc7be86df3ef1674
Author: Tim Burke <email address hidden>
Date: Fri Jun 5 16:36:32 2020 -0700

    Remove etag-quoter from 2.25.0 release notes

    This was released in 2.24.0, which already has a release note for it.

    Change-Id: I9837df281ec8baa19e8e4a7976f415e8add4a2da

commi...

tags: added: in-feature-losf
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.