]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-auth-client: auth-master - Move auth_master_cache_flush()
authorStephan Bosch <stephan.bosch@open-xchange.com>
Sun, 19 Apr 2020 16:51:01 +0000 (18:51 +0200)
committerStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 27 Aug 2025 11:34:57 +0000 (13:34 +0200)
src/lib-auth-client/auth-master.c
src/lib-auth-client/auth-master.h

index effc6259cc13906ee16b24141234adfcb97ca3a1..cadd294eb820638767ed4982d24c4a4308832fff 100644 (file)
@@ -723,66 +723,6 @@ int auth_master_pass_lookup(struct auth_master_connection *conn,
        return ctx.return_value;
 }
 
-struct auth_master_cache_ctx {
-       struct auth_master_connection *conn;
-       unsigned int count;
-       bool failed;
-};
-
-static bool
-auth_cache_flush_reply_callback(const char *cmd, const char *const *args,
-                               void *context)
-{
-       struct auth_master_cache_ctx *ctx = context;
-
-       if (strcmp(cmd, "OK") != 0)
-               ctx->failed = TRUE;
-       else if (args[0] == NULL || str_to_uint(args[0], &ctx->count) < 0)
-               ctx->failed = TRUE;
-
-       io_loop_stop(ctx->conn->ioloop);
-       return TRUE;
-}
-
-int auth_master_cache_flush(struct auth_master_connection *conn,
-                           const char *const *users, unsigned int *count_r)
-{
-       struct auth_master_cache_ctx ctx;
-       string_t *str;
-
-       i_zero(&ctx);
-       ctx.conn = conn;
-
-       conn->reply_callback = auth_cache_flush_reply_callback;
-       conn->reply_context = &ctx;
-
-       str = t_str_new(128);
-       str_printfa(str, "CACHE-FLUSH\t%u", auth_master_next_request_id(conn));
-       if (users != NULL) {
-               for (; *users != NULL; users++) {
-                       str_append_c(str, '\t');
-                       str_append_tabescaped(str, *users);
-               }
-       }
-       str_append_c(str, '\n');
-
-       auth_master_event_create(conn, "auth cache flush: ");
-
-       e_debug(conn->event, "Started cache flush");
-
-       (void)auth_master_run_cmd(conn, str_c(str));
-
-       if (ctx.failed)
-               e_debug(conn->event, "Cache flush failed");
-       else
-               e_debug(conn->event, "Finished cache flush");
-       auth_master_event_finish(conn);
-
-       conn->reply_context = NULL;
-       *count_r = ctx.count;
-       return ctx.failed ? -1 : 0;
-}
-
 struct auth_master_user_list_ctx {
        struct auth_master_connection *conn;
        string_t *username;
@@ -937,3 +877,63 @@ int auth_master_user_list_deinit(struct auth_master_user_list_ctx **_ctx)
        i_free(ctx);
        return ret;
 }
+
+struct auth_master_cache_ctx {
+       struct auth_master_connection *conn;
+       unsigned int count;
+       bool failed;
+};
+
+static bool
+auth_cache_flush_reply_callback(const char *cmd, const char *const *args,
+                               void *context)
+{
+       struct auth_master_cache_ctx *ctx = context;
+
+       if (strcmp(cmd, "OK") != 0)
+               ctx->failed = TRUE;
+       else if (args[0] == NULL || str_to_uint(args[0], &ctx->count) < 0)
+               ctx->failed = TRUE;
+
+       io_loop_stop(ctx->conn->ioloop);
+       return TRUE;
+}
+
+int auth_master_cache_flush(struct auth_master_connection *conn,
+                           const char *const *users, unsigned int *count_r)
+{
+       struct auth_master_cache_ctx ctx;
+       string_t *str;
+
+       i_zero(&ctx);
+       ctx.conn = conn;
+
+       conn->reply_callback = auth_cache_flush_reply_callback;
+       conn->reply_context = &ctx;
+
+       str = t_str_new(128);
+       str_printfa(str, "CACHE-FLUSH\t%u", auth_master_next_request_id(conn));
+       if (users != NULL) {
+               for (; *users != NULL; users++) {
+                       str_append_c(str, '\t');
+                       str_append_tabescaped(str, *users);
+               }
+       }
+       str_append_c(str, '\n');
+
+       auth_master_event_create(conn, "auth cache flush: ");
+
+       e_debug(conn->event, "Started cache flush");
+
+       (void)auth_master_run_cmd(conn, str_c(str));
+
+       if (ctx.failed)
+               e_debug(conn->event, "Cache flush failed");
+       else
+               e_debug(conn->event, "Finished cache flush");
+       auth_master_event_finish(conn);
+
+       conn->reply_context = NULL;
+       *count_r = ctx.count;
+       return ctx.failed ? -1 : 0;
+}
index f34d4b37eda791eefad932536ff4e00c22a30789..5a3cc1519d3179e350f39493892a3187e9f1b44c 100644 (file)
@@ -55,10 +55,6 @@ int auth_master_user_lookup(struct auth_master_connection *conn,
 int auth_master_pass_lookup(struct auth_master_connection *conn,
                            const char *user, const struct auth_user_info *info,
                            pool_t pool, const char *const **fields_r);
-/* Flush authentication cache for everyone (users=NULL) or only for specified
-   users. Returns number of users flushed from cache. */
-int auth_master_cache_flush(struct auth_master_connection *conn,
-                           const char *const *users, unsigned int *count_r);
 
 /* Parse userdb extra fields into auth_user_reply structure. */
 int auth_user_fields_parse(const char *const *fields, pool_t pool,
@@ -77,4 +73,10 @@ int auth_master_user_list_deinit(struct auth_master_user_list_ctx **ctx);
 
 /* INTERNAL: */
 void auth_user_info_export(string_t *str, const struct auth_user_info *info);
+
+/* Flush authentication cache for everyone (users=NULL) or only for specified
+   users. Returns number of users flushed from cache. */
+int auth_master_cache_flush(struct auth_master_connection *conn,
+                           const char *const *users, unsigned int *count_r);
+
 #endif