]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fail from gss_acquire_cred if we have no keytab
authorGreg Hudson <ghudson@mit.edu>
Mon, 4 Jun 2012 00:46:30 +0000 (20:46 -0400)
committerGreg Hudson <ghudson@mit.edu>
Mon, 4 Jun 2012 00:46:30 +0000 (20:46 -0400)
If a caller tries to acquire krb5 acceptor creds with no desired name
and we have no keytab keys, fail from gss_acquire_cred instead of
deferring until gss_accept_sec_context.

ticket: 7159 (new)

src/lib/gssapi/krb5/acquire_cred.c
src/tests/gssapi/t_gssapi.py

index c08e0597f4f8a5be71c0a826f3305ffe8f64c6af..2bbee5fd82865c0bd2f3d3ea662a6851ddd5e8ce 100644 (file)
@@ -227,6 +227,7 @@ acquire_accept_cred(krb5_context context,
     }
 
     if (desired_name != NULL) {
+        /* Make sure we keys matching the desired name in the keytab. */
         code = check_keytab(context, kt, desired_name);
         if (code) {
             krb5_kt_close(context, kt);
@@ -254,6 +255,13 @@ acquire_accept_cred(krb5_context context,
             *minor_status = code;
             return GSS_S_FAILURE;
         }
+    } else {
+        /* Make sure we have a keytab with keys in it. */
+        code = krb5_kt_have_content(context, kt);
+        if (code) {
+            *minor_status = code;
+            return GSS_S_FAILURE;
+        }
     }
 
     cred->keytab = kt;
index 3ace215db85e982e7b325a294af622531c56f447..18123b392ce4f31714485ac3b5f83eb58268324d 100644 (file)
@@ -78,6 +78,13 @@ output = realm.run_as_client(['./t_imp_cred', 'service2/dwight'],
 if 'Wrong principal in request' not in output:
     fail('Expected error message not seen in t_imp_cred output')
 
+# Verify that we can't acquire acceptor creds without a keytab.
+os.remove(realm.keytab)
+output = realm.run_as_client(['./t_accname', 'abc'], expected_code=1)
+if ('gss_acquire_cred: Keytab' not in output or
+    'nonexistent or empty' not in output):
+    fail('Expected error message not seen for nonexistent keytab')
+
 realm.stop()
 
 # Re-run the last acceptor name test with ignore_acceptor_hostname set