mit-kdb: support MIT Kerberos 1.16 KDB API changes
authorAlexander Bokovoy <ab@samba.org>
Tue, 24 Oct 2017 09:01:39 +0000 (12:01 +0300)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 19 Jan 2018 00:36:22 +0000 (01:36 +0100)
MIT Kerberos 1.16 adds ability to audit local and remote addresses
during AS_REQ processing. As result, audit_as_req callback signature
was changed to include the addresses and KDB API version was increased.

Change mit-kdb code to properly expose audit_as_req signature KDC
expects in 1.16 version. Also update #ifdefs to account for the new
KDB API version.

This commit does not add actual audit of the local and remote IP
addresses, it only makes it possible to compile against MIT Kerberos
1.16.

Signed-off-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Jan 19 01:36:22 CET 2018 on sn-devel-144

source4/kdc/mit-kdb/kdb_samba.h
source4/kdc/mit-kdb/kdb_samba_policies.c
source4/kdc/mit-kdb/kdb_samba_principals.c

index abca2c166ae42b0adf498d6d8847f5bfd6ed1b27..b9c571f26cbaafb3b010df8efda1b3aa850cf164 100644 (file)
@@ -78,7 +78,7 @@ krb5_error_code kdb_samba_db_put_principal(krb5_context context,
 krb5_error_code kdb_samba_db_delete_principal(krb5_context context,
                                              krb5_const_principal princ);
 
-#if KRB5_KDB_API_VERSION == 8
+#if KRB5_KDB_API_VERSION >= 8
 krb5_error_code kdb_samba_db_iterate(krb5_context context,
                                     char *match_entry,
                                     int (*func)(krb5_pointer, krb5_db_entry *),
@@ -148,12 +148,23 @@ krb5_error_code kdb_samba_db_check_allowed_to_delegate(krb5_context context,
                                                       const krb5_db_entry *server,
                                                       krb5_const_principal proxy);
 
+#if KRB5_KDB_API_VERSION >= 9
 void kdb_samba_db_audit_as_req(krb5_context kcontext,
                               krb5_kdc_req *request,
+                              const krb5_address *local_addr,
+                              const krb5_address *remote_addr,
                               krb5_db_entry *client,
                               krb5_db_entry *server,
                               krb5_timestamp authtime,
                               krb5_error_code error_code);
+#else
+void kdb_samba_db_audit_as_req(krb5_context kcontext,
+                              krb5_kdc_req *request,
+                              krb5_db_entry *client,
+                              krb5_db_entry *server,
+                              krb5_timestamp authtime,
+                              krb5_error_code error_code);
+#endif
 
 /* from kdb_samba_change_pwd.c */
 
index 81140abfd504f30e7ab2bc7b173428ee44ad71bd..de5813bde2f847a7a5613f115cc826ab3eaed676 100644 (file)
@@ -432,20 +432,10 @@ done:
        return code;
 }
 
-void kdb_samba_db_audit_as_req(krb5_context context,
-                              krb5_kdc_req *request,
-                              krb5_db_entry *client,
-                              krb5_db_entry *server,
-                              krb5_timestamp authtime,
-                              krb5_error_code error_code)
-{
-       struct mit_samba_context *mit_ctx;
-
-       mit_ctx = ks_get_context(context);
-       if (mit_ctx == NULL) {
-               return;
-       }
 
+static void samba_bad_password_count(krb5_db_entry *client,
+                                    krb5_error_code error_code)
+{
        switch (error_code) {
        case 0:
                mit_samba_zero_bad_password_count(client);
@@ -456,3 +446,29 @@ void kdb_samba_db_audit_as_req(krb5_context context,
                break;
        }
 }
+
+#if KRB5_KDB_API_VERSION >= 9
+void kdb_samba_db_audit_as_req(krb5_context context,
+                              krb5_kdc_req *request,
+                              const krb5_address *local_addr,
+                              const krb5_address *remote_addr,
+                              krb5_db_entry *client,
+                              krb5_db_entry *server,
+                              krb5_timestamp authtime,
+                              krb5_error_code error_code)
+{
+       samba_bad_password_count(client, error_code);
+
+       /* TODO: perform proper audit logging for addresses */
+}
+#else
+void kdb_samba_db_audit_as_req(krb5_context context,
+                              krb5_kdc_req *request,
+                              krb5_db_entry *client,
+                              krb5_db_entry *server,
+                              krb5_timestamp authtime,
+                              krb5_error_code error_code)
+{
+       samba_bad_password_count(client, error_code);
+}
+#endif
index 1dbb69b561d7ffbecbdb7ad54aa4bfeed1476a40..8b67436dc472dd5d97eddaa3638e78d75b3067ef 100644 (file)
@@ -308,7 +308,7 @@ krb5_error_code kdb_samba_db_delete_principal(krb5_context context,
        return KRB5_KDB_DB_INUSE;
 }
 
-#if KRB5_KDB_API_VERSION == 8
+#if KRB5_KDB_API_VERSION >= 8
 krb5_error_code kdb_samba_db_iterate(krb5_context context,
                                     char *match_entry,
                                     int (*func)(krb5_pointer, krb5_db_entry *),