]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix kadmin addprinc -randkey -kvno 1001/head
authorGreg Hudson <ghudson@mit.edu>
Sun, 17 Nov 2019 00:54:51 +0000 (19:54 -0500)
committerGreg Hudson <ghudson@mit.edu>
Tue, 19 Nov 2019 21:11:47 +0000 (16:11 -0500)
Commit f07bca9fc94a5cf2e3c0f58226c7973a4b86b7a9 made addprinc -randkey
use a single RPC request, but the server-side handling always creates
the random keys with kvno 1.  If a kvno is specified in the RPC
request, set the kvno of the key data after creating it.  Reported by
Andreas Ladanyi.

ticket: 8848
tags: pullup
target_version: 1.17-next
target_version: 1.16-next

src/lib/kadm5/srv/svr_principal.c

index ba6459a4011a9e1dd9163c9ede3755eecfa3bb38..6ee262e899408ae7ad90e18baa56bdc5b319c784 100644 (file)
@@ -302,7 +302,7 @@ kadm5_create_principal_3(void *server_handle,
     kadm5_server_handle_t handle = server_handle;
     krb5_keyblock               *act_mkey;
     krb5_kvno                   act_kvno;
-    int                         new_n_ks_tuple = 0;
+    int                         new_n_ks_tuple = 0, i;
     krb5_key_salt_tuple         *new_ks_tuple = NULL;
 
     CHECK_HANDLE(server_handle);
@@ -468,6 +468,10 @@ kadm5_create_principal_3(void *server_handle,
         /* Null password means create with random key (new in 1.8). */
         ret = krb5_dbe_crk(handle->context, &master_keyblock,
                            new_ks_tuple, new_n_ks_tuple, FALSE, kdb);
+        if (mask & KADM5_KVNO) {
+            for (i = 0; i < kdb->n_key_data; i++)
+                kdb->key_data[i].key_data_kvno = entry->kvno;
+        }
     }
     if (ret)
         goto cleanup;