]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix KDC worker process argument parsing
authorGreg Hudson <ghudson@mit.edu>
Wed, 18 Jun 2014 16:58:39 +0000 (12:58 -0400)
committerTom Yu <tlyu@mit.edu>
Mon, 21 Jul 2014 22:20:22 +0000 (18:20 -0400)
To create worker processes, the KDC shuts down realms, forks off the
worker processes, then reinitializes realms in each child.
Reinitializing realms requires making a second pass over the
command-line arguments.  To do this with getopt, optind must be
reinitialized to 1 for each pass; otherwise, no options will be seen
the second time around.

(cherry picked from commit 1776fd19120d230115527febbd22979eb64ee1ff)

ticket: 7945
version_fixed: 1.12.2
status: resolved

src/kdc/main.c

index a7ffe635d97ce9412b78045434fa1f816caac049..a7d4b597f606b91f75e8146f1302aeadd7fe7e50 100644 (file)
@@ -665,9 +665,11 @@ initialize_realms(krb5_context kcontext, int argc, char **argv)
     }
 
     /*
-     * Loop through the option list.  Each time we encounter a realm name,
-     * use the previously scanned options to fill in for defaults.
+     * Loop through the option list.  Each time we encounter a realm name, use
+     * the previously scanned options to fill in for defaults.  We do this
+     * twice if worker processes are used, so we must initialize optind.
      */
+    optind = 1;
     while ((c = getopt(argc, argv, "x:r:d:mM:k:R:e:P:p:s:nw:4:T:X3")) != -1) {
         switch(c) {
         case 'x':