summaryrefslogtreecommitdiff
path: root/client/smburi.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2013-04-30 16:31:46 +0200
committerOndrej Holy <oholy@redhat.com>2013-05-28 13:48:44 +0200
commitba7981734456b86787777c119821a17e7dbe5737 (patch)
treed6ca9fd40e5b4c76ca8f8c127dfbb0da5f3bde9b /client/smburi.c
parentb1c573b3400e1aa0f5a835edda2505abb6bcf313 (diff)
downloadgvfs-ba7981734456b86787777c119821a17e7dbe5737.tar.gz
smb: Add support for specifying custom port
Thanks to the work by Jeremy Allison we should be able to connect to a non-standard port through new enough Samba version. This patch adds a port argument to smburi parser and both smb and smb-browse backends. https://bugzilla.gnome.org/show_bug.cgi?id=698071
Diffstat (limited to 'client/smburi.c')
-rw-r--r--client/smburi.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/client/smburi.c b/client/smburi.c
index fc718713..23774db7 100644
--- a/client/smburi.c
+++ b/client/smburi.c
@@ -27,6 +27,8 @@
#include <gvfsurimapper.h>
#include <gvfsuriutils.h>
+#define DEFAULT_SMB_PORT 445
+
typedef struct _GVfsUriMapperSmb GVfsUriMapperSmb;
typedef struct _GVfsUriMapperSmbClass GVfsUriMapperSmbClass;
@@ -165,6 +167,14 @@ smb_from_uri (GVfsUriMapper *mapper,
info->path = g_strconcat ("/", p, NULL);
}
}
+
+ /* only set the port if it isn't the default port */
+ if (uri->port != -1 && uri->port != DEFAULT_SMB_PORT)
+ {
+ gchar *port = g_strdup_printf ("%d", uri->port);
+ g_vfs_uri_mount_info_set (info, "port", port);
+ g_free (port);
+ }
}
if (uri->userinfo)
@@ -208,7 +218,9 @@ smb_to_uri (GVfsUriMapper *mapper,
const char *share;
const char *user;
const char *domain;
+ const char *port = NULL;
char *s;
+ int port_num;
GDecodedUri *uri;
uri = g_new0 (GDecodedUri, 1);
@@ -216,7 +228,6 @@ smb_to_uri (GVfsUriMapper *mapper,
type = g_vfs_uri_mount_info_get (info, "type");
uri->scheme = g_strdup ("smb");
- uri->port = -1;
if (strcmp (type, "smb-network") == 0)
{
@@ -232,6 +243,7 @@ smb_to_uri (GVfsUriMapper *mapper,
uri->path = g_strconcat ("/._", info->path + 1, NULL);
else
uri->path = g_strdup ("/");
+ port = g_vfs_uri_mount_info_get (info, "port");
}
else if (strcmp (type, "smb-share") == 0)
{
@@ -251,8 +263,14 @@ smb_to_uri (GVfsUriMapper *mapper,
else
uri->userinfo = g_strdup (user);
}
+ port = g_vfs_uri_mount_info_get (info, "port");
}
+ if (port && (port_num = atoi (port)))
+ uri->port = port_num;
+ else
+ uri->port = -1;
+
s = g_vfs_encode_uri (uri, allow_utf8);
g_vfs_decoded_uri_free (uri);
return s;