[gvfs] smb: More verbosity for easier debugging
- From: Tomas Bzatek <tbzatek src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] smb: More verbosity for easier debugging
- Date: Fri, 8 Feb 2013 15:43:06 +0000 (UTC)
commit 5ca4ebdac6bc5c6d87802ae527bb7880d81e823c
Author: Tomas Bzatek <tbzatek redhat com>
Date: Fri Feb 8 16:35:27 2013 +0100
smb: More verbosity for easier debugging
This adds more debugging output for both smb and smb-browse backends
and also brings more verbosity for user-visible error messages.
Changes made to be able to debug weird samba issues remotely:
https://bugzilla.gnome.org/show_bug.cgi?id=691863
daemon/gvfsbackendsmb.c | 50 +++++++++++++++++++++++++++++++++++-----
daemon/gvfsbackendsmbbrowse.c | 38 ++++++++++++++++++++++++------
2 files changed, 73 insertions(+), 15 deletions(-)
---
diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c
index 00daf16..b967b88 100644
--- a/daemon/gvfsbackendsmb.c
+++ b/daemon/gvfsbackendsmb.c
@@ -53,6 +53,15 @@
#include <libsmbclient.h>
#include "libsmb-compat.h"
+
+#define PRINT_DEBUG
+
+#ifdef PRINT_DEBUG
+#define DEBUG(msg...) g_print("### SMB: " msg)
+#else
+#define DEBUG(...)
+#endif
+
struct _GVfsBackendSmb
{
GVfsBackend parent_instance;
@@ -130,6 +139,8 @@ g_vfs_backend_smb_init (GVfsBackendSmb *backend)
g_free (workgroup);
g_object_unref (settings);
+
+ DEBUG ("g_vfs_backend_smb_init: default workgroup = '%s'\n", backend->default_workgroup ? backend->default_workgroup : "NULL");
}
/**
@@ -180,6 +191,7 @@ auth_callback (SMBCCTX *context,
/* Don't prompt for credentials, let smbclient finish the mount loop */
strncpy (username_out, "ABORT", unmaxlen);
strncpy (password_out, "", pwmaxlen);
+ DEBUG ("auth_callback - mount_cancelled\n");
return;
}
@@ -202,11 +214,14 @@ auth_callback (SMBCCTX *context,
{
/* Try again if kerberos login + anonymous fallback fails */
backend->mount_try_again = TRUE;
+ DEBUG ("auth_callback - anonymous pass\n");
}
else
{
gboolean in_keyring = FALSE;
+ DEBUG ("auth_callback - normal pass\n");
+
if (!backend->password_in_keyring)
{
in_keyring = g_vfs_keyring_lookup_password (backend->user,
@@ -220,6 +235,11 @@ auth_callback (SMBCCTX *context,
&ask_domain,
&ask_password);
backend->password_in_keyring = in_keyring;
+
+ if (in_keyring)
+ DEBUG ("auth_callback - reusing keyring credentials: user = '%s', domain = '%s'\n",
+ ask_user ? ask_user : "NULL",
+ ask_domain ? ask_domain : "NULL");
}
if (!in_keyring)
@@ -234,6 +254,8 @@ auth_callback (SMBCCTX *context,
if (backend->user == NULL)
flags |= G_ASK_PASSWORD_NEED_USERNAME;
+ DEBUG ("auth_callback - asking for password...\n");
+
/* translators: First %s is a share name, second is a server name */
message = g_strdup_printf (_("Password required for share %s on %s"),
share_name, server_name);
@@ -279,6 +301,8 @@ auth_callback (SMBCCTX *context,
backend->last_user = g_strdup (username_out);
backend->last_domain = g_strdup (domain_out);
backend->last_password = g_strdup (password_out);
+ DEBUG ("auth_callback - out: last_user = '%s', last_domain = '%s'\n",
+ backend->last_user, backend->last_domain);
}
/* Add a server to the cache system
@@ -573,7 +597,7 @@ do_mount (GVfsBackend *backend,
it would be tough to actually say if it was an authentication failure
or the particular path problem. */
uri = create_smb_uri (op_backend->server, op_backend->share, op_backend->path);
-
+ DEBUG ("do_mount - URI = %s\n", uri);
/* Samba mount loop */
op_backend->mount_source = mount_source;
@@ -585,12 +609,23 @@ do_mount (GVfsBackend *backend,
op_backend->mount_try_again = FALSE;
op_backend->mount_cancelled = FALSE;
+ DEBUG ("do_mount - try #%d \n", op_backend->mount_try);
+
smbc_stat = smbc_getFunctionStat (smb_context);
res = smbc_stat (smb_context, uri, &st);
-
- if (res == 0 || op_backend->mount_cancelled ||
- (errno != EACCES && errno != EPERM))
- break;
+
+ DEBUG ("do_mount - [%s; %d] res = %d, cancelled = %d, errno = [%d] '%s' \n",
+ uri, op_backend->mount_try, res, op_backend->mount_cancelled,
+ errno, g_strerror (errno));
+
+ if (res == 0)
+ break;
+
+ if (op_backend->mount_cancelled || (errno != EACCES && errno != EPERM))
+ {
+ DEBUG ("do_mount - (errno != EPERM && errno != EACCES), cancelled = %d, breaking\n", op_backend->mount_cancelled);
+ break;
+ }
/* The first round is Kerberos-only. Only if this fails do we enable
* NTLMSSP fallback (turning off anonymous fallback, which we've
@@ -598,6 +633,7 @@ do_mount (GVfsBackend *backend,
*/
if (op_backend->mount_try == 0)
{
+ DEBUG ("do_mount - after anon, enabling NTLMSSP fallback\n");
smbc_setOptionFallbackAfterKerberos (op_backend->smb_context, 1);
smbc_setOptionNoAutoAnonymousLogin (op_backend->smb_context, 1);
}
@@ -611,7 +647,6 @@ do_mount (GVfsBackend *backend,
if (res != 0)
{
- /* TODO: Error from errno? */
op_backend->mount_source = NULL;
if (op_backend->mount_cancelled)
@@ -622,12 +657,13 @@ do_mount (GVfsBackend *backend,
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 mount Windows share"));
+ _("Failed to mount Windows share: %s"), g_strerror (errno));
return;
}
/* Mount was successful */
+ DEBUG ("do_mount - login successful\n");
g_vfs_backend_set_default_location (backend, op_backend->path);
g_vfs_keyring_save_password (op_backend->last_user,
diff --git a/daemon/gvfsbackendsmbbrowse.c b/daemon/gvfsbackendsmbbrowse.c
index 46bbc94..a0a87ad 100644
--- a/daemon/gvfsbackendsmbbrowse.c
+++ b/daemon/gvfsbackendsmbbrowse.c
@@ -354,6 +354,11 @@ auth_callback (SMBCCTX *context,
&ask_domain,
&ask_password);
backend->password_in_keyring = in_keyring;
+
+ if (in_keyring)
+ DEBUG ("auth_callback - reusing keyring credentials: user = '%s', domain = '%s'\n",
+ ask_user ? ask_user : "NULL",
+ ask_domain ? ask_domain : "NULL");
}
if (!in_keyring)
@@ -443,6 +448,13 @@ add_cached_server (SMBCCTX *context, SMBCSRV *new,
cached_server->domain = g_strdup (domain);
cached_server->username = g_strdup (username);
+ DEBUG ("adding cached server '%s'\\'%s', user '%s';'%s' with data %p\n",
+ server_name ? server_name : "NULL",
+ share_name ? share_name : "(no share)",
+ domain ? domain : "(no domain)",
+ username ? username : "NULL",
+ new);
+
if (server_cache == NULL)
server_cache = g_hash_table_new_full (cached_server_hash, cached_server_equal,
(GDestroyNotify)cached_server_free, NULL);
@@ -474,6 +486,7 @@ remove_cached_server (SMBCCTX * context, SMBCSRV * server)
if (server_cache)
{
+ DEBUG ("removing cached servers with data %p\n", server);
num = g_hash_table_foreach_remove (server_cache, remove_cb, server);
if (num != 0)
return 0;
@@ -503,11 +516,19 @@ get_cached_server (SMBCCTX * context,
(char *)domain,
(char *)username
};
+ SMBCSRV *ret = NULL;
+
+ DEBUG ("looking up cached server '%s'\\'%s', user '%s';'%s'\n",
+ server_name ? server_name : "NULL",
+ share_name ? share_name : "(no share)",
+ domain ? domain : "(no domain)",
+ username ? username : "NULL");
if (server_cache)
- return g_hash_table_lookup (server_cache, &key);
- else
- return NULL;
+ ret = g_hash_table_lookup (server_cache, &key);
+
+ DEBUG (" returning %p\n", ret);
+ return ret;
}
/* Try to remove all servers from the cache system and disconnect
@@ -520,6 +541,8 @@ get_cached_server (SMBCCTX * context,
static int
purge_cached (SMBCCTX * context)
{
+ DEBUG ("purging server cache\n");
+
if (server_cache)
g_hash_table_remove_all (server_cache);
@@ -826,7 +849,7 @@ do_mount (GVfsBackend *backend,
{
g_vfs_job_failed (G_VFS_JOB (job),
G_IO_ERROR, G_IO_ERROR_FAILED,
- "Failed to allocate smb context");
+ _("Internal Error (%s)"), "Failed to allocate smb context");
return;
}
@@ -873,7 +896,7 @@ do_mount (GVfsBackend *backend,
{
g_vfs_job_failed (G_VFS_JOB (job),
G_IO_ERROR, G_IO_ERROR_FAILED,
- "Failed to initialize smb context");
+ _("Internal Error (%s)"), "Failed to initialize smb context");
smbc_free_context (smb_context, FALSE);
return;
}
@@ -955,7 +978,7 @@ do_mount (GVfsBackend *backend,
if (dir == NULL &&
(op_backend->mount_cancelled || (errno != EPERM && errno != EACCES)))
{
- DEBUG ("do_mount - (errno != EPERM && errno != EACCES), breaking\n");
+ DEBUG ("do_mount - (errno != EPERM && errno != EACCES), cancelled = %d, breaking\n", op_backend->mount_cancelled);
break;
}
@@ -998,11 +1021,10 @@ do_mount (GVfsBackend *backend,
G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED,
_("Password dialog cancelled"));
else
- /* TODO: Error from errno? */
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"));
+ _("Failed to retrieve share list from server: %s"), g_strerror (errno));
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]