int main(int argc, char **argv) { krb5_error_code ret; setprogname(argv[0]); ret = krb5_init_context(&context); if (ret == KRB5_CONFIG_BADFORMAT) errx (1, "krb5_init_context failed to parse configuration file"); else if (ret) errx (1, "krb5_init_context failed: %d", ret); ret = krb5_kt_register(context, &hdb_kt_ops); if (ret) errx (1, "krb5_kt_register(HDB) failed: %d", ret); config = configure(context, argc, argv); #ifdef SIGPIPE #ifdef HAVE_SIGACTION { struct sigaction sa; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, NULL); } #else signal(SIGPIPE, SIG_IGN); #endif #endif /* SIGPIPE */ #ifdef SUPPORT_DETACH if (detach_from_console) daemon(0, 0); #endif #ifdef __APPLE__ if (sandbox_flag) { char *errorstring; ret = sandbox_init("kdc", SANDBOX_NAMED, &errorstring); if (ret) errx(1, "sandbox_init failed: %d: %s", ret, errorstring); } bonjour_announce(get_realms); #endif /* __APPLE__ */ pidfile(NULL); switch_environment(); setup_listeners(context, config, listen_on_ipc, listen_on_network); heim_sipc_signal_handler(SIGINT, terminated, "SIGINT"); heim_sipc_signal_handler(SIGTERM, terminated, "SIGTERM"); #ifdef SIGXCPU heim_sipc_signal_handler(SIGXCPU, terminated, "CPU time limit exceeded"); #endif heim_ipc_main(); krb5_free_context(context); return 0; }
int main(int argc, char **argv) { krb5_error_code ret; krb5_context context; krb5_kdc_configuration *config; setprogname(argv[0]); ret = krb5_init_context(&context); if (ret == KRB5_CONFIG_BADFORMAT) errx (1, "krb5_init_context failed to parse configuration file"); else if (ret) errx (1, "krb5_init_context failed: %d", ret); ret = krb5_kt_register(context, &hdb_kt_ops); if (ret) errx (1, "krb5_kt_register(HDB) failed: %d", ret); config = configure(context, argc, argv); #ifdef HAVE_SIGACTION { struct sigaction sa; sa.sa_flags = 0; sa.sa_handler = sigterm; sigemptyset(&sa.sa_mask); sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); #ifdef SIGXCPU sigaction(SIGXCPU, &sa, NULL); #endif sa.sa_handler = SIG_IGN; #ifdef SIGPIPE sigaction(SIGPIPE, &sa, NULL); #endif } #else signal(SIGINT, sigterm); signal(SIGTERM, sigterm); #ifdef SIGXCPU signal(SIGXCPU, sigterm); #endif #ifdef SIGPIPE signal(SIGPIPE, SIG_IGN); #endif #endif #ifdef SUPPORT_DETACH if (detach_from_console) daemon(0, 0); #endif #ifdef __APPLE__ bonjour_announce(context, config); #endif pidfile(NULL); switch_environment(); loop(context, config); krb5_free_context(context); return 0; }