]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libnet keytab: implement cleaning of old entries in libnet_keytab_add().
authorMichael Adam <obnox@samba.org>
Thu, 31 Jul 2008 22:07:40 +0000 (00:07 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 1 Aug 2008 14:07:59 +0000 (16:07 +0200)
Triggered by the flag clean_old_entries from the libnet_keytab_contex
(unused yet...).

Michael

source/libnet/libnet_keytab.c

index 87d83fc46e73523291145af193b0e3c1e5bbea28..23eedafe2b7286ed1f62abfa87638a594c565b0e 100644 (file)
@@ -265,6 +265,28 @@ krb5_error_code libnet_keytab_add(struct libnet_keytab_context *ctx)
        krb5_error_code ret = 0;
        uint32_t i;
 
+
+       if (ctx->clean_old_entries) {
+               DEBUG(0, ("cleaning old entries...\n"));
+               for (i=0; i < ctx->count; i++) {
+                       struct libnet_keytab_entry *entry = &ctx->entries[i];
+
+                       ret = libnet_keytab_remove_entries(ctx->context,
+                                                          ctx->keytab,
+                                                          entry->principal,
+                                                          0,
+                                                          entry->enctype,
+                                                          true);
+                       if (ret) {
+                               DEBUG(1,("libnet_keytab_add: Failed to remove "
+                                        "old entries for %s (enctype %u): %s\n",
+                                        entry->principal, entry->enctype,
+                                        error_message(ret)));
+                               return ret;
+                       }
+               }
+       }
+
        for (i=0; i<ctx->count; i++) {
 
                struct libnet_keytab_entry *entry = &ctx->entries[i];