Re: [PATCH v3] Fix URI alias prefix matching

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 01, 2011 at 05:49:06PM +0800, Wen Ruo Lv wrote:
> 
> with /etc/libvirt/libvirt.conf below:
> uri_aliases = [
>   "hail=qemu:///system",
>   "sleet=qemu+ssh://root 9 115 122 57/system",
>   "sam=qemu+unix:///system?socket=/var/run/libvirt/libvirt-sock",
> ]
> Neither "virsh -c hailly" nor "hai" should result in matching "hail=qemu:///system"
> 
> Fix URI alias prefix matching when connecting
> 
> Signed-off-by: Wen Ruo Lv <lvroyce@xxxxxxxxxxxxxxxxxx>
> ---
>  src/libvirt.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/src/libvirt.c b/src/libvirt.c
> index e9d1a29..6f8a76f 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -990,6 +990,8 @@ static int
>  virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias, char **uri)
>  {
>      virConfValuePtr entry;
> +    size_t alias_len;
> +
>      if (value->type != VIR_CONF_LIST) {
>          virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
>                          _("Expected a list for 'uri_aliases' config parameter"));
> @@ -997,6 +999,7 @@ virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias, char *
>      }
>  
>      entry = value->list;
> +    alias_len = strlen(alias);
>      while (entry) {
>          char *offset;
>          size_t safe;
> @@ -1022,7 +1025,8 @@ virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias, char *
>              return -1;
>          }
>  
> -        if (STREQLEN(entry->str, alias, offset-entry->str)) {
> +        if (alias_len == (offset - entry->str) &&
> +	    STREQLEN(entry->str, alias, alias_len)) {
>              VIR_DEBUG("Resolved alias '%s' to '%s'",
>                        alias, offset+1);
>              if (!(*uri = strdup(offset+1))) {

ACK


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]