]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master: Add master_service_set_current_user()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 3 Feb 2022 15:24:11 +0000 (16:24 +0100)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Sun, 13 Feb 2022 10:23:26 +0000 (10:23 +0000)
src/lib-master/master-service-private.h
src/lib-master/master-service.c
src/lib-master/master-service.h

index 7844864b2850515b2be5c4b21ae19577a37518cf..bf28ef740796f36a73a7591e0558e0c09af88c2b 100644 (file)
@@ -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;
index abe9f81fa3bc688625b537fa9d36e05938696056..6a6bb5ebec99bf9c8dac2790e1e7f1702b14da37 100644 (file)
@@ -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);
+}
index 2ee69f9934662371e66add4057fdcbe9403bd45c..6a2e9b807100565d81944645be8cc19b9d813cd1 100644 (file)
@@ -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