Bug 1450325

Summary: document URI format for -a parameters of tools
Product: Red Hat Enterprise Linux 7 Reporter: YongkuiGuo <yoguo>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4CC: ptoscano, yoguo
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libguestfs-1.36.6-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 09:15:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1472272    
Bug Blocks:    

Description YongkuiGuo 2017-05-12 09:19:46 UTC
Description of problem:

  If the secret for remote image contains a character '/',The virt-inspector command could not parse the URL.  After asked rjone's help,
he suggested replacing the ‘/‘ with ’%2f‘ as a temporary solution.


Version-Release number of selected component (if applicable):
libguestfs-1.36.3-3.el7.x86_64

How reproducible:
100%


Steps:

1.
#virt-inspector --format=raw -v -x  -a  rbd://libvirt:AQAnRRBZpEOYJhAA/rJEZap2KJAqOOAshIMJPg==.144.70:6789/libvirt-pool/rbd-sr.img
virt-inspector: --add: could not parse URI 'rbd://libvirt:AQAnRRBZpEOYJhAA/rJEZap2KJAqOOAshIMJPg==.144.70:6789/libvirt-pool/rbd-sr.img'
libguestfs: trace: close
libguestfs: closing guestfs handle 0x7f194ca4c750 (state 0)

2.
#virt-inspector --format=raw -a  rbd://libvirt:AQAnRRBZpEOYJhAA%2frJEZap2KJAqOOAshIMJPg==.144.70:6789/libvirt-pool/rbd-sr.img

This command is executed successfully.


Expected results:
virt-inspector should parse the secret which contains '/' of remote image.

Additional info:

Comment 2 Richard W.M. Jones 2017-05-12 09:27:30 UTC
Probably sufficient to have a docs fix.  "/" has magical properties
in URLs and must be quoted, but when/how to quote it isn't obvious.

Comment 3 Pino Toscano 2017-05-12 09:32:14 UTC
The URI follows the format of RFC 3986 [1] for URLs.

In particular, the userinfo part (i.e. user + password) is defined as following (see §3.2.1 in the RFC):

      userinfo    = *( unreserved / pct-encoded / sub-delims / ":" )

and the components are:

      unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
      pct-encoded = "%" HEXDIG HEXDIG
      sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
                  / "*" / "+" / "," / ";" / "="

So "/" is not allowed directly as character neither for the user name nor for the password, and thus it must be percent-encoded (see §2.1).

[1] https://tools.ietf.org/html/rfc3986

Hence this is not a bug, since "/" must be represented as "%2f" in both user name and password.

Comment 4 Pino Toscano 2017-08-30 14:19:53 UTC
Just sent a small documentation patch, since it's basically all that we can do:
https://www.redhat.com/archives/libguestfs/2017-August/msg00143.html

Comment 5 Pino Toscano 2017-08-31 07:54:59 UTC
Fixed upstream with
https://github.com/libguestfs/libguestfs/commit/5f43b30a6f469b5feab2ffeb3147f7310f1ba47f
which is in libguestfs >= 1.37.22.

Comment 7 YongkuiGuo 2017-10-10 02:55:37 UTC
Verified with package:
libguestfs-1.36.6-2.el7.x86_64

Steps:

1. #man guestfish
-------------------------------------------------------------------

...
Note that the URIs follow the syntax of RFC 3986: in particular, there are restrictions on the allowed characters for the various components of the URI.  Characters such as ":", "@", and "/" must be percent-encoded:

 $ guestfish -a rbd://user:pass%40word[:port]/pool/disk

In this case, the password is "pass@word".
...

-------------------------------------------------------------------

Some datailed info has been added to man page. So verified this bug.

Comment 10 errata-xmlrpc 2018-04-10 09:15:08 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:0677