From f99a48e982375e9ff5e98f36f1038cefd182e03c Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Thu, 26 Oct 2023 17:20:22 +0800
Subject: [PATCH] Ignore EINVAL for kerberos/ccache login

---
 daemon/gvfsbackendsmb.c       | 10 ++++++++--
 daemon/gvfsbackendsmbbrowse.c |  8 +++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c
index b8319c6..67c4570 100644
--- a/daemon/gvfsbackendsmb.c
+++ b/daemon/gvfsbackendsmb.c
@@ -502,8 +502,14 @@ do_mount (GVfsBackend *backend,
 
       if (res == 0)
         break;
-
-      if (op_backend->mount_cancelled || (errsv != EACCES && errsv != EPERM))
+     
+      if (errsv == EINVAL && op_backend->mount_try <= 1 && op_backend->user == NULL)
+        {
+          /* EINVAL is "expected" when kerberos/ccache is misconfigured, see:
+           * https://gitlab.gnome.org/GNOME/gvfs/-/issues/611
+           */
+        }
+      else if (op_backend->mount_cancelled || (errsv != EACCES && errsv != EPERM))
         {
           g_debug ("do_mount - (errno != EPERM && errno != EACCES), cancelled = %d, breaking\n", op_backend->mount_cancelled);
           break;
diff --git a/daemon/gvfsbackendsmbbrowse.c b/daemon/gvfsbackendsmbbrowse.c
index 3b11883..b3bb7b2 100644
--- a/daemon/gvfsbackendsmbbrowse.c
+++ b/daemon/gvfsbackendsmbbrowse.c
@@ -957,7 +957,13 @@ do_mount (GVfsBackend *backend,
              uri, op_backend->mount_try, dir, op_backend->mount_cancelled,
              errsv, g_strerror (errsv));
 
-      if (dir == NULL && 
+      if (errsv == EINVAL && op_backend->mount_try == 0 && op_backend->user == NULL)
+        {
+          /* EINVAL is "expected" when kerberos is misconfigured, see:
+           * https://gitlab.gnome.org/GNOME/gvfs/-/issues/611
+           */
+        }
+      else if (dir == NULL && 
           (op_backend->mount_cancelled || (errsv != EPERM && errsv != EACCES)))
         {
           g_debug ("do_mount - (errno != EPERM && errno != EACCES), cancelled = %d, breaking\n", op_backend->mount_cancelled);
-- 
2.33.0

