]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: Handle -NOUSER replies from doveadm-server.
authorTimo Sirainen <tss@iki.fi>
Wed, 7 Mar 2012 09:29:42 +0000 (11:29 +0200)
committerTimo Sirainen <tss@iki.fi>
Wed, 7 Mar 2012 09:29:42 +0000 (11:29 +0200)
src/doveadm/doveadm-mail-server.c
src/doveadm/server-connection.c
src/doveadm/server-connection.h

index b44d859212622a972ac15fd1f148d011c7fc31a4..782e7acf6a1f62d0c8b830f15af3dcbac6f5a1f3 100644 (file)
@@ -83,14 +83,22 @@ static void doveadm_cmd_callback(enum server_cmd_reply reply, void *context)
        struct server_connection *conn = context;
        struct doveadm_server *server;
 
-       if (reply == SERVER_CMD_REPLY_INTERNAL_FAILURE) {
+       switch (reply) {
+       case SERVER_CMD_REPLY_INTERNAL_FAILURE:
                internal_failure = TRUE;
                master_service_stop(master_service);
                return;
-       }
-
-       if (reply != SERVER_CMD_REPLY_OK)
+       case SERVER_CMD_REPLY_UNKNOWN_USER:
+               i_error("No such user");
+               if (cmd_ctx->exit_code == 0)
+                       cmd_ctx->exit_code = EX_NOUSER;
+               break;
+       case SERVER_CMD_REPLY_FAIL:
                doveadm_mail_failed_error(cmd_ctx, MAIL_ERROR_TEMP);
+               break;
+       case SERVER_CMD_REPLY_OK:
+               break;
+       }
 
        server = server_connection_get_server(conn);
        if (array_count(&server->queue) > 0) {
index d0863df58f5ac3e592a2dc263a491a00ffc5402d..15deb245cb08e9bdb436cee4e697f6037aafb341 100644 (file)
@@ -197,6 +197,7 @@ static void server_connection_input(struct server_connection *conn)
        const unsigned char *data;
        size_t size;
        const char *line;
+       enum server_cmd_reply reply;
 
        if (!conn->handshaked) {
                if ((line = i_stream_read_next_line(conn->input)) == NULL) {
@@ -254,15 +255,18 @@ static void server_connection_input(struct server_connection *conn)
                if (conn->state != SERVER_REPLY_STATE_RET)
                        break;
                /* fall through */
-               data = i_stream_get_data(conn->input, &size);
        case SERVER_REPLY_STATE_RET:
-               if (size < 2)
+               line = i_stream_next_line(conn->input);
+               if (line == NULL)
                        return;
-               if (data[0] == '+' && data[1] == '\n')
+               if (line[0] == '+')
                        server_connection_callback(conn, SERVER_CMD_REPLY_OK);
-               else if (data[0] == '-' && data[1] == '\n')
-                       server_connection_callback(conn, SERVER_CMD_REPLY_FAIL);
-               else
+               else if (line[0] == '-') {
+                       reply = strcmp(line+1, "NOUSER") == 0 ?
+                               SERVER_CMD_REPLY_UNKNOWN_USER :
+                               SERVER_CMD_REPLY_FAIL;
+                       server_connection_callback(conn, reply);
+               } else
                        i_error("doveadm server sent broken input");
                /* we're finished, close the connection */
                server_connection_destroy(&conn);
index 4e00a367c34f5f49cb3f8eaad8ff6d621b36658e..9d36f6ac304a2b8ddcdcb478cb972750603dae86 100644 (file)
@@ -3,6 +3,7 @@
 
 enum server_cmd_reply {
        SERVER_CMD_REPLY_INTERNAL_FAILURE,
+       SERVER_CMD_REPLY_UNKNOWN_USER,
        SERVER_CMD_REPLY_FAIL,
        SERVER_CMD_REPLY_OK
 };