kdc: add --testing option for leak testing

The kdc nowadays forks and restarts worker children.  This is nice, but
for leak checking in tests on OS X with leak(1) we really need the
worker to be the one process.
This commit is contained in:
Nicolas Williams
2016-12-06 16:40:51 -06:00
parent 87b234e154
commit 5f2e4fb368
3 changed files with 100 additions and 90 deletions

View File

@@ -52,6 +52,7 @@ static char *max_request_str; /* `max_request' as a string */
static int disable_des = -1; static int disable_des = -1;
static int builtin_hdb_flag; static int builtin_hdb_flag;
int testing_flag;
static int help_flag; static int help_flag;
static int version_flag; static int version_flag;
@@ -120,6 +121,7 @@ static struct getargs args[] = {
{ "chroot", 0, arg_string, &chroot_string, { "chroot", 0, arg_string, &chroot_string,
"chroot directory to run in", NULL "chroot directory to run in", NULL
}, },
{ "testing", 0, arg_flag, &testing_flag, NULL, NULL },
{ "help", 'h', arg_flag, &help_flag, NULL, NULL }, { "help", 'h', arg_flag, &help_flag, NULL, NULL },
{ "version", 'v', arg_flag, &version_flag, NULL, NULL } { "version", 'v', arg_flag, &version_flag, NULL, NULL }
}; };

View File

@@ -1153,6 +1153,7 @@ start_kdc(krb5_context context,
tv1.tv_usec = 0; tv1.tv_usec = 0;
#ifdef HAVE_FORK #ifdef HAVE_FORK
if (!testing_flag) {
/* Note that we might never execute the body of this loop */ /* Note that we might never execute the body of this loop */
while (exit_flag == 0) { while (exit_flag == 0) {
@@ -1195,7 +1196,8 @@ start_kdc(krb5_context context,
break; break;
} }
} }
kdc_log(context, config, 0, "KDC worker process started: %d", pid); kdc_log(context, config, 0, "KDC worker process started: %d",
pid);
num_kdcs++; num_kdcs++;
gettimeofday(&tv1, NULL); gettimeofday(&tv1, NULL);
break; break;
@@ -1252,10 +1254,14 @@ start_kdc(krb5_context context,
end: end:
kdc_log(context, config, 0, "KDC master process exiting", pid); kdc_log(context, config, 0, "KDC master process exiting", pid);
free(pids); free(pids);
} else {
loop(context, config, d, ndescr, -1);
kdc_log(context, config, 0, "KDC exiting", pid);
}
#else #else
loop(context, config, d, ndescr, -1); loop(context, config, d, ndescr, -1);
kdc_log(context, config, 0, "KDC exiting", pid); kdc_log(context, config, 0, "KDC exiting", pid);
#endif #endif
free (d); free(d);
} }

View File

@@ -103,6 +103,8 @@ extern int detach_from_console;
extern int daemon_child; extern int daemon_child;
extern int do_bonjour; extern int do_bonjour;
extern int testing_flag;
extern const struct units _kdc_digestunits[]; extern const struct units _kdc_digestunits[];
#define KDC_LOG_FILE "kdc.log" #define KDC_LOG_FILE "kdc.log"