1 /* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */ 2 3 #include "lib.h" 4 5 #include "smtp-server-private.h" 6 7 /* QUIT command */ 8 smtp_server_cmd_quit(struct smtp_server_cmd_ctx * cmd,const char * params)9void smtp_server_cmd_quit(struct smtp_server_cmd_ctx *cmd, 10 const char *params) 11 { 12 struct smtp_server_connection *conn = cmd->conn; 13 struct smtp_server_command *command = cmd->cmd; 14 const struct smtp_server_callbacks *callbacks = conn->callbacks; 15 int ret; 16 17 /* "QUIT" CRLF */ 18 if (*params != '\0') { 19 smtp_server_reply(cmd, 20 501, "5.5.4", "Invalid parameters"); 21 return; 22 } 23 24 smtp_server_connection_input_halt(conn); 25 26 smtp_server_command_ref(command); 27 if (callbacks != NULL && callbacks->conn_cmd_quit != NULL) { 28 /* specific implementation of QUIT command */ 29 if ((ret=callbacks->conn_cmd_quit(conn->context, cmd)) <= 0) { 30 i_assert(ret == 0 || 31 smtp_server_command_is_replied(command)); 32 /* command is waiting for external event or it failed */ 33 smtp_server_command_unref(&command); 34 return; 35 } 36 } 37 if (!smtp_server_command_is_replied(command)) { 38 /* set generic QUIT success reply if none is provided */ 39 smtp_server_reply_quit(cmd); 40 } 41 smtp_server_command_unref(&command); 42 } 43