963210
From 16c9dd3d2f8d74958495674f4906626a74ef8c12 Mon Sep 17 00:00:00 2001
963210
From: Robbie Harwood <rharwood@redhat.com>
963210
Date: Fri, 22 Apr 2016 10:03:07 -0400
963210
Subject: [PATCH] krb5-kvno-230379.patch
963210
963210
---
963210
 src/kadmin/ktutil/ktutil.c    | 5 +++--
963210
 src/lib/krb5/keytab/kt_file.c | 2 +-
963210
 2 files changed, 4 insertions(+), 3 deletions(-)
963210
963210
diff --git a/src/kadmin/ktutil/ktutil.c b/src/kadmin/ktutil/ktutil.c
963210
index ef16d37a5..64a6d6ab1 100644
963210
--- a/src/kadmin/ktutil/ktutil.c
963210
+++ b/src/kadmin/ktutil/ktutil.c
963210
@@ -140,7 +140,7 @@ void ktutil_add_entry(argc, argv)
963210
     char *princ = NULL;
963210
     char *enctype = NULL;
963210
     krb5_kvno kvno = 0;
963210
-    int use_pass = 0, use_key = 0, i;
963210
+    int use_pass = 0, use_key = 0, use_kvno = 0, i;
963210
 
963210
     for (i = 1; i < argc; i++) {
963210
         if ((strlen(argv[i]) == 2) && !strncmp(argv[i], "-p", 2)) {
963210
@@ -149,6 +149,7 @@ void ktutil_add_entry(argc, argv)
963210
         }
963210
         if ((strlen(argv[i]) == 2) && !strncmp(argv[i], "-k", 2)) {
963210
             kvno = (krb5_kvno) atoi(argv[++i]);
963210
+            use_kvno++;
963210
             continue;
963210
         }
963210
         if ((strlen(argv[i]) == 2) && !strncmp(argv[i], "-e", 2)) {
963210
@@ -165,7 +166,7 @@ void ktutil_add_entry(argc, argv)
963210
         }
963210
     }
963210
 
963210
-    if (argc != 8 || !(princ && kvno && enctype) || (use_pass+use_key != 1)) {
963210
+    if (argc != 8 || !(princ && use_kvno && enctype) || (use_pass+use_key != 1)) {
963210
         fprintf(stderr, _("usage: %s (-key | -password) -p principal "
963210
                           "-k kvno -e enctype\n"), argv[0]);
963210
         return;
963210
diff --git a/src/lib/krb5/keytab/kt_file.c b/src/lib/krb5/keytab/kt_file.c
963210
index 674d88bab..131549ffe 100644
963210
--- a/src/lib/krb5/keytab/kt_file.c
963210
+++ b/src/lib/krb5/keytab/kt_file.c
963210
@@ -377,7 +377,7 @@ krb5_ktfile_get_entry(krb5_context context, krb5_keytab id,
963210
              * Otherwise, remember that we were here so we can return the right
963210
              * error, and free the new.
963210
              */
963210
-            if (new_entry.vno == kvno) {
963210
+            if (new_entry.vno == kvno || new_entry.vno == IGNORE_VNO) {
963210
                 krb5_kt_free_entry(context, &cur_entry);
963210
                 cur_entry = new_entry;
963210
                 if (new_entry.vno == kvno)