More robust kadm5 server handle init and cleanup
This commit is contained in:
		| @@ -230,13 +230,16 @@ _kadm5_s_init_context(kadm5_server_context **ctx, | ||||
| 		      krb5_context context) | ||||
| { | ||||
|     kadm5_ret_t ret = 0; | ||||
|     *ctx = malloc(sizeof(**ctx)); | ||||
|  | ||||
|     *ctx = calloc(1, sizeof(**ctx)); | ||||
|     if (*ctx == NULL) | ||||
| 	return ENOMEM; | ||||
|     memset(*ctx, 0, sizeof(**ctx)); | ||||
|     (*ctx)->log_context.socket_fd = rk_INVALID_SOCKET; | ||||
|  | ||||
|     set_funcs(*ctx); | ||||
|     (*ctx)->context = context; | ||||
|     krb5_add_et_list (context, initialize_kadm5_error_table_r); | ||||
|  | ||||
| #define is_set(M) (params && params->mask & KADM5_CONFIG_ ## M) | ||||
|     if (is_set(REALM)) { | ||||
| 	(*ctx)->config.realm = strdup(params->realm); | ||||
|   | ||||
| @@ -56,6 +56,7 @@ static void | ||||
| destroy_kadm5_log_context (kadm5_log_context *c) | ||||
| { | ||||
|     free(c->log_file); | ||||
|     if (c->socket_fd != rk_INVALID_SOCKET) | ||||
|         rk_closesocket(c->socket_fd); | ||||
| #ifdef NO_UNIX_SOCKETS | ||||
|     if (c->socket_info) { | ||||
| @@ -72,10 +73,11 @@ destroy_kadm5_log_context (kadm5_log_context *c) | ||||
| kadm5_ret_t | ||||
| kadm5_s_destroy(void *server_handle) | ||||
| { | ||||
|     kadm5_ret_t ret; | ||||
|     kadm5_ret_t ret = 0; | ||||
|     kadm5_server_context *context = server_handle; | ||||
|     krb5_context kcontext = context->context; | ||||
|  | ||||
|     if (context->db != NULL) | ||||
|         ret = context->db->hdb_destroy(kcontext, context->db); | ||||
|     destroy_kadm5_log_context(&context->log_context); | ||||
|     destroy_config(&context->config); | ||||
| @@ -83,5 +85,6 @@ kadm5_s_destroy(void *server_handle) | ||||
|     if (context->my_context) | ||||
| 	krb5_free_context(kcontext); | ||||
|     free(context); | ||||
|  | ||||
|     return ret; | ||||
| } | ||||
|   | ||||
| @@ -93,6 +93,7 @@ kadm5_s_init_with_context(krb5_context context, | ||||
| 					ctx->log_context.socket_info->ai_protocol); | ||||
| #endif | ||||
|  | ||||
|     if (ctx->log_context.socket_fd != rk_INVALID_SOCKET) | ||||
|         socket_set_nonblocking(ctx->log_context.socket_fd, 1); | ||||
|  | ||||
|     ret = krb5_parse_name(ctx->context, client_name, &ctx->caller); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Viktor Dukhovni
					Viktor Dukhovni