[gvfs] smb: Fix IPv6 uri handling



commit eadddde1a35f60595193e0d373e99e8cafb45090
Author: Ondrej Holy <oholy redhat com>
Date:   Tue Nov 15 10:27:39 2016 +0100

    smb: Fix IPv6 uri handling
    
    IPv6 server includes brackets in GMountSpec, smbclient doesn't. Remove
    the brackets from the uri before usage in smbclient functions.
    
    The IPv6 uris can be consequently used in the following format (port
    isn't mandatory), e.g.:
    gvfs-mount smb://[::1]:139/
    
    https://bugzilla.gnome.org/show_bug.cgi?id=604116

 daemon/gvfsbackendsmb.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c
index 12fbd38..7fbdbaa 100644
--- a/daemon/gvfsbackendsmb.c
+++ b/daemon/gvfsbackendsmb.c
@@ -360,7 +360,16 @@ create_smb_uri_string (const char *server,
   GString *uri;
 
   uri = g_string_new ("smb://");
-  g_string_append_encoded (uri, server, NULL);
+
+  /* IPv6 server includes brackets in GMountSpec, smbclient doesn't */
+  if (server[0] == '[')
+    {
+      g_string_append_encoded (uri, server + 1, NULL);
+      g_string_truncate (uri, uri->len - 3);
+    }
+  else
+    g_string_append_encoded (uri, server, NULL);
+
   if (port != -1)
     g_string_append_printf (uri, ":%d", port);
   g_string_append_c (uri, '/');


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