]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-auth: auth-master - Pass struct auth_master_lookup_ctx to parse_reply() rather...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Fri, 4 Jan 2019 16:39:37 +0000 (17:39 +0100)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Tue, 22 Jan 2019 22:30:49 +0000 (23:30 +0100)
src/lib-auth/auth-master.c

index 216a271b8373586688c53c120c141ea12e837eb1..a373d141d5a5ad02d15ca23d697ddf7026d3e329 100644 (file)
@@ -207,20 +207,24 @@ auth_master_handshake_line(struct connection *_conn, const char *line)
        return 0;
 }
 
-static int parse_reply(const char *cmd, const char *const *args,
-                      const char *expected_reply, const char *user, bool debug)
+static int
+parse_reply(struct auth_master_lookup_ctx *ctx, const char *cmd,
+           const char *const *args)
 {
-       if (strcmp(cmd, expected_reply) == 0)
+       struct auth_master_connection *conn = ctx->conn;
+       bool debug = (conn->flags & AUTH_MASTER_FLAG_DEBUG) != 0;
+
+       if (strcmp(cmd, ctx->expected_reply) == 0)
                return 1;
        if (strcmp(cmd, "NOTFOUND") == 0)
                return 0;
        if (strcmp(cmd, "FAIL") == 0) {
                if (*args == NULL) {
                        i_error("user %s: Auth %s lookup failed",
-                               user, expected_reply);
+                               ctx->user, ctx->expected_reply);
                } else if (debug) {
                        i_debug("user %s: Auth %s lookup returned temporary failure: %s",
-                               user, expected_reply, *args);
+                               ctx->user, ctx->expected_reply, *args);
                }
                return -2;
        }
@@ -270,8 +274,7 @@ static bool auth_lookup_reply_callback(const char *cmd, const char *const *args,
 
        io_loop_stop(ctx->conn->ioloop);
 
-       ctx->return_value =
-               parse_reply(cmd, args, ctx->expected_reply, ctx->user, debug);
+       ctx->return_value = parse_reply(ctx, cmd, args);
 
        len = str_array_length(args);
        if (ctx->return_value >= 0) {