6b6d0f
From 747c7f6ea6c8b6a7ccd008bb47996ba7eb169bcc Mon Sep 17 00:00:00 2001
6b6d0f
From: Ondrej Holy <oholy@redhat.com>
6b6d0f
Date: Mon, 11 Apr 2022 10:54:04 +0200
6b6d0f
Subject: [PATCH] smb: Ignore EINVAL for kerberos/ccache login
6b6d0f
6b6d0f
With samba 4.16.0, mount operation fails with the "Invalid Argument" error
6b6d0f
when kerberos/ccache is misconfigured. Ignore this error, so user get a chance
6b6d0f
to login using the password...
6b6d0f
6b6d0f
Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/611
6b6d0f
---
6b6d0f
 daemon/gvfsbackendsmb.c       |  8 +++++++-
6b6d0f
 daemon/gvfsbackendsmbbrowse.c | 10 ++++++++--
6b6d0f
 2 files changed, 15 insertions(+), 3 deletions(-)
6b6d0f
6b6d0f
diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c
6b6d0f
index 33d1a209..776b67bc 100644
6b6d0f
--- a/daemon/gvfsbackendsmb.c
6b6d0f
+++ b/daemon/gvfsbackendsmb.c
6b6d0f
@@ -513,7 +513,13 @@ do_mount (GVfsBackend *backend,
6b6d0f
       if (res == 0)
6b6d0f
         break;
6b6d0f
 
6b6d0f
-      if (op_backend->mount_cancelled || (errsv != EACCES && errsv != EPERM))
6b6d0f
+      if (errsv == EINVAL && op_backend->mount_try <= 1 && op_backend->user == NULL)
6b6d0f
+        {
6b6d0f
+          /* EINVAL is "expected" when kerberos/ccache is misconfigured, see:
6b6d0f
+           * https://gitlab.gnome.org/GNOME/gvfs/-/issues/611
6b6d0f
+           */
6b6d0f
+        }
6b6d0f
+      else if (op_backend->mount_cancelled || (errsv != EACCES && errsv != EPERM))
6b6d0f
         {
6b6d0f
           g_debug ("do_mount - (errno != EPERM && errno != EACCES), cancelled = %d, breaking\n", op_backend->mount_cancelled);
6b6d0f
           break;
6b6d0f
diff --git a/daemon/gvfsbackendsmbbrowse.c b/daemon/gvfsbackendsmbbrowse.c
6b6d0f
index 57bae9db..7e8facfb 100644
6b6d0f
--- a/daemon/gvfsbackendsmbbrowse.c
6b6d0f
+++ b/daemon/gvfsbackendsmbbrowse.c
6b6d0f
@@ -967,8 +967,14 @@ do_mount (GVfsBackend *backend,
6b6d0f
              uri, op_backend->mount_try, dir, op_backend->mount_cancelled,
6b6d0f
              errsv, g_strerror (errsv));
6b6d0f
 
6b6d0f
-      if (dir == NULL && 
6b6d0f
-          (op_backend->mount_cancelled || (errsv != EPERM && errsv != EACCES)))
6b6d0f
+      if (errsv == EINVAL && op_backend->mount_try == 0 && op_backend->user == NULL)
6b6d0f
+        {
6b6d0f
+          /* EINVAL is "expected" when kerberos is misconfigured, see:
6b6d0f
+           * https://gitlab.gnome.org/GNOME/gvfs/-/issues/611
6b6d0f
+           */
6b6d0f
+        }
6b6d0f
+      else if (dir == NULL &&
6b6d0f
+               (op_backend->mount_cancelled || (errsv != EPERM && errsv != EACCES)))
6b6d0f
         {
6b6d0f
           g_debug ("do_mount - (errno != EPERM && errno != EACCES), cancelled = %d, breaking\n", op_backend->mount_cancelled);
6b6d0f
 	  break;
6b6d0f
-- 
6b6d0f
2.35.1
6b6d0f