diff options
author | Ondrej Holy <oholy@redhat.com> | 2016-11-15 10:27:39 +0100 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2016-11-16 11:45:30 +0100 |
commit | 6145c93ecf2554304577589262de341324a093de (patch) | |
tree | 699820092fb0e933fdb4435ae8d56f7287f1d9ce | |
parent | 2b710831b79a7e1be315904ca09e92fd7b6f4410 (diff) | |
download | gvfs-6145c93ecf2554304577589262de341324a093de.tar.gz |
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
-rw-r--r-- | daemon/gvfsbackendsmb.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c index cc23629c..a477669c 100644 --- a/daemon/gvfsbackendsmb.c +++ b/daemon/gvfsbackendsmb.c @@ -479,7 +479,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, '/'); |