Commit 6c8bc39f authored by Ondrej Holy's avatar Ondrej Holy

smbbrowse: Force NT1 protocol version for workgroup support

"Windows Network" doesn't work with recent samba versions, because
"client max protocol" has been changed from NT1 to SMB3 recently.
NT1 is mandatory for workgroup support. Let's force NT1 using the
newly added smbc_setOptionProtocols API if available. But force this
only when neither hostname, nor IP address is used. This among others
prevents complete breakage if NT1 is disabled on server. Use GResolver
to implement this heuristic.
parent 62f1a8c6
Pipeline #31677 passed with stage
in 1 minute and 42 seconds
......@@ -45,6 +45,7 @@
#include "gvfskeyring.h"
#include "gmounttracker.h"
#include "gvfsbackendsmbprivate.h"
#include "gvfsutils.h"
#include <libsmbclient.h>
......@@ -847,6 +848,47 @@ do_mount (GVfsBackend *backend,
op_backend->server = g_strdup (op_backend->mounted_server);
/* Force NT1 protocol version if server can't be resolved (i.e. is not
* hostname, nor IP address). This is needed for workgroup support, because
* "client max protocol" has been changed from NT1 to SMB3 in recent samba
* versions.
if (op_backend->server != NULL)
GResolver *resolver;
GList *addresses;
GError *error = NULL;
gchar *server;
resolver = g_resolver_get_default ();
/* IPv6 server includes brackets in GMountSpec, GResolver doesn't */
if (gvfs_is_ipv6 (op_backend->server))
server = g_strndup (op_backend->server + 1, strlen (op_backend->server) - 2);
server = g_strdup (op_backend->server);
addresses = g_resolver_lookup_by_name (resolver, server, NULL, &error);
if (addresses == NULL)
if (error != NULL)
g_debug ("%s\n", error->message);
g_error_free (error);
g_debug ("Forcing NT1 protocol version\n");
smbc_setOptionProtocols (smb_context, "NT1", "NT1");
g_resolver_free_addresses (addresses);
g_object_unref (resolver);
g_free (server);
icon = NULL;
symbolic_icon = NULL;
if (op_backend->server == NULL)
......@@ -387,6 +387,8 @@ config_h.set10('HAVE_LIBUSB', enable_libusb)
enable_samba = get_option('smb')
if enable_samba
smbclient_dep = dependency('smbclient')
config_h.set('HAVE_SMBC_SETOPTIONPROTOCOLS', cc.has_function('smbc_setOptionProtocols', dependencies: smbclient_dep))
# *** Check for libarchive ***
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment