URL: https://github.com/SSSD/sssd/pull/722
Author: jhrozek
 Title: #722: KCM: Deleting a non-existent ccache should not yield an error
Action: opened

PR body:
"""
Resolves: https://pagure.io/SSSD/sssd/issue/3910

When the KCM destroy operation is called, it receives a name as an input.
If the name cannot be found, we would currently return KRB5_CC_NOTFOUND.
But other ccache types return KRB5_FCC_NOFILE in that case and e.g.
utilities like kdestroy special case KRB5_FCC_NOFILE to be non-fatal.
"""

To pull the PR as Git branch:
git remote add ghsssd https://github.com/SSSD/sssd
git fetch ghsssd pull/722/head:pr722
git checkout pr722
From 095ec3c62c199f299d005b766a042ef03c9d6702 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhro...@redhat.com>
Date: Thu, 20 Dec 2018 14:54:53 +0100
Subject: [PATCH] KCM: Deleting a non-existent ccache should not yield an error

Resolves:
https://pagure.io/SSSD/sssd/issue/3910

When the KCM destroy operation is called, it receives a name as an input. If
the name cannot be found, we would currently return KRB5_CC_NOTFOUND. But
other ccache types return KRB5_FCC_NOFILE in that case and e.g. utilities
like kdestroy special case KRB5_FCC_NOFILE to be non-fatal.
---
 src/responder/kcm/kcmsrv_ops.c        |  3 ++-
 src/tests/multihost/basic/test_kcm.py | 17 +++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/responder/kcm/kcmsrv_ops.c b/src/responder/kcm/kcmsrv_ops.c
index 1e229adc4..9352909f4 100644
--- a/src/responder/kcm/kcmsrv_ops.c
+++ b/src/responder/kcm/kcmsrv_ops.c
@@ -698,9 +698,10 @@ static void kcm_op_destroy_getbyname_done(struct tevent_req *subreq)
     ret = kcm_ccdb_uuid_by_name_recv(subreq, state, uuid);
     talloc_zfree(subreq);
     if (ret != EOK) {
-        DEBUG(SSSDBG_OP_FAILURE,
+        DEBUG(SSSDBG_MINOR_FAILURE,
               "Cannot get matching ccache [%d]: %s\n",
               ret, sss_strerror(ret));
+        ret = ERR_NO_MATCHING_CREDS;
         tevent_req_error(req, ret);
         return;
     }
diff --git a/src/tests/multihost/basic/test_kcm.py b/src/tests/multihost/basic/test_kcm.py
index 87e325bd7..7202dcb4a 100644
--- a/src/tests/multihost/basic/test_kcm.py
+++ b/src/tests/multihost/basic/test_kcm.py
@@ -122,3 +122,20 @@ def test_kcm_debug_level_set(self, multihost, enable_kcm):
 
         log_lines_debug = self._kcm_log_length(multihost)
         assert log_lines_debug > log_lines_pre + 100
+
+    def test_kdestroy_retval(self, multihost, enable_kcm):
+        """
+        Test that destroying an empty cache does not return a non-zero
+        return code.
+        """
+        ssh = SSHClient(multihost.master[0].sys_hostname,
+                        username='foo3', password='Secret123')
+
+        (_, _, exit_status) = ssh.execute_cmd('kdestroy')
+        assert exit_status == 0
+        # Run the command again in case there was something in the ccache
+        # previously
+        (_, _, exit_status) = ssh.execute_cmd('kdestroy')
+        assert exit_status == 0
+
+        ssh.close()
_______________________________________________
sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org
To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/sssd-devel@lists.fedorahosted.org

Reply via email to