From: Timo Sirainen Date: Thu, 3 Feb 2022 15:24:11 +0000 (+0100) Subject: lib-master: Add master_service_set_current_user() X-Git-Tag: 2.4.0~4420 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b7484dbc88a69999f5c8d0abc2c10d72267e0618;p=thirdparty%2Fdovecot%2Fcore.git lib-master: Add master_service_set_current_user() --- diff --git a/src/lib-master/master-service-private.h b/src/lib-master/master-service-private.h index 7844864b28..bf28ef7407 100644 --- a/src/lib-master/master-service-private.h +++ b/src/lib-master/master-service-private.h @@ -71,6 +71,8 @@ struct master_service { struct ssl_iostream_context *ssl_ctx; time_t ssl_params_last_refresh; + char *current_user; + struct stats_client *stats_client; struct master_service_haproxy_conn *haproxy_conns; struct event_filter *process_shutdown_filter; diff --git a/src/lib-master/master-service.c b/src/lib-master/master-service.c index abe9f81fa3..6a6bb5ebec 100644 --- a/src/lib-master/master-service.c +++ b/src/lib-master/master-service.c @@ -1227,6 +1227,7 @@ static void master_service_free(struct master_service *service) i_free(service->configured_name); i_free(service->name); i_free(service->config_path); + i_free(service->current_user); i_free(service); } @@ -1631,3 +1632,11 @@ void master_service_unset_process_shutdown_filter(struct master_service *service { event_filter_unref(&service->process_shutdown_filter); } + +void master_service_set_current_user(struct master_service *service, + const char *user) +{ + char *old_user = service->current_user; + service->current_user = i_strdup(user); + i_free(old_user); +} diff --git a/src/lib-master/master-service.h b/src/lib-master/master-service.h index 2ee69f9934..6a2e9b8071 100644 --- a/src/lib-master/master-service.h +++ b/src/lib-master/master-service.h @@ -279,4 +279,10 @@ void master_service_set_process_shutdown_filter(struct master_service *service, /* Unsets process shutdown filter, if it exists */ void master_service_unset_process_shutdown_filter(struct master_service *service); +/* Change the user being currently handled. Call with user=NULL once done. + This is used by SIGTERM handler to prevent doveadm kick from kicking wrong + users due to race conditions. */ +void master_service_set_current_user(struct master_service *service, + const char *user); + #endif