diff -r -u8 a/daemon/gvfsbackendnetwork.c b/daemon/gvfsbackendnetwork.c --- a/daemon/gvfsbackendnetwork.c 2020-03-27 05:29:57.942425500 -0700 +++ b/daemon/gvfsbackendnetwork.c 2023-01-03 02:10:14.988067543 -0800 @@ -884,19 +884,25 @@ g_mutex_init (&network_backend->smb_mount_lock); supported_vfs = g_vfs_get_supported_uri_schemes (g_vfs_get_default ()); network_backend->have_smb = FALSE; network_backend->have_dnssd = FALSE; for (i=0; supported_vfs[i]!=NULL; i++) { + /* wmaddox 2023.01.02 + * SMB-style discovery not supported in an SMB2+ only environment, and is causing problems when mounting workgroups. + * Note that the "windows network" will not appear in "Files" and other gvfs clients, but it would necessarily be empty + * anyhow, because SMB1 (NT1) support is needed in order to browse a workgroup. + */ +#if 0 if (strcmp(supported_vfs[i], "smb") == 0) - network_backend->have_smb = TRUE; - + network_backend->have_smb = TRUE; +#endif if (strcmp(supported_vfs[i], "dns-sd") == 0) network_backend->have_dnssd = TRUE; } if (network_backend->have_smb) { network_backend->smb_settings = g_settings_new ("org.gnome.system.smb"); diff -r -u8 a/daemon/gvfsbackendsmbbrowse.c b/daemon/gvfsbackendsmbbrowse.c --- a/daemon/gvfsbackendsmbbrowse.c 2020-03-27 05:29:58.151427700 -0700 +++ b/daemon/gvfsbackendsmbbrowse.c 2023-01-03 02:08:12.434814584 -0800 @@ -843,23 +843,36 @@ /* Convert DEFAULT_WORKGROUP_NAME to real domain */ if (op_backend->mounted_server != NULL && g_ascii_strcasecmp (op_backend->mounted_server, DEFAULT_WORKGROUP_NAME) == 0) op_backend->server = g_strdup (smbc_getWorkgroup (smb_context)); else op_backend->server = g_strdup (op_backend->mounted_server); -#ifdef HAVE_SMBC_SETOPTIONPROTOCOLS - /* 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. - */ + /* wmaddox 2023.01.02 + * If we cannot resolve the server as a domain name or an IP address, fail early. + * If we continue to the call to smbc_opendir() below, that code will attempt to resolve + * such names as a Windows workgroup. For reasons I do not understand, this can result + * in this daemon becoming unresponsive and attempts to browse servers fail henceforth + * until the daemon is killed, even when the name is resolvable via DNS. It is not clear + * why this happens for smb://workgroup/ but not for another unresolvable server name of + * similar form such as smb:/foobar/. It does not appear that 'workgroup' is hardcoded, + * and indeed Windows workgroups may be created with other names. + * + * Our intent here is to disable browsing of workgroups entirely, as workgroups are a + * concept that no longer exists in an SMB2+ only world. Note that there is a posibility + * that a server name may resolve in the code below, but fail to do so later in smbc_opendir() + * and cause the invocation of the problematic workgroup resolution code -- At least I have + * not examined the logic there carefully enough to rule this out. I believe this is + * mostly mitigated by a separate change to the gvfsbackendnetwork.c to avoid attempting + * workgroup discovery. We expect the early failure below to apply only when explicitly + * attempting to browse a workgroup by name. + */ if (op_backend->server != NULL) { GResolver *resolver; GList *addresses; GError *error = NULL; gchar *server; resolver = g_resolver_get_default (); @@ -873,26 +886,41 @@ 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); } - +#if 1 /* WHM */ + g_vfs_job_failed (G_VFS_JOB (job), + G_IO_ERROR, G_IO_ERROR_FAILED, + /* translators: We tried to mount a windows (samba) share, but failed */ + _("Failed to retrieve share list from server: cannot resolve address (NOTE: workgroups are not supported.)")); + g_resolver_free_addresses (addresses); + g_object_unref (resolver); + g_free (server); + return; +#else +#ifdef HAVE_SMBC_SETOPTIONPROTOCOLS + /* 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. + */ g_debug ("Forcing NT1 protocol version\n"); smbc_setOptionProtocols (smb_context, "NT1", "NT1"); +#endif + g_resolver_free_addresses (addresses); + g_object_unref (resolver); + g_free (server); +#endif } - - g_resolver_free_addresses (addresses); - g_object_unref (resolver); - g_free (server); } -#endif icon = NULL; symbolic_icon = NULL; if (op_backend->server == NULL) { display_name = g_strdup (_("Windows Network")); browse_mount_spec = g_mount_spec_new ("smb-network"); icon = "network-workgroup";