comparison src/director/director-connection.c @ 22640:cf23a90cd2ca

director: Use t_strsplit_tabescaped_inplace() for director connection input
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sat, 04 Nov 2017 01:48:41 +0200
parents 0281041d5067
children 6e235143e177
comparison
equal deleted inserted replaced
22639:da6cf4b7caf4 22640:cf23a90cd2ca
122 struct timeout *to_disconnect, *to_ping, *to_pong; 122 struct timeout *to_disconnect, *to_ping, *to_pong;
123 123
124 struct director_user_iter *user_iter; 124 struct director_user_iter *user_iter;
125 125
126 /* set during command execution */ 126 /* set during command execution */
127 const char *cur_cmd, *cur_line; 127 const char *cur_cmd, *const *cur_args;
128 128
129 unsigned int in:1; 129 unsigned int in:1;
130 unsigned int connected:1; 130 unsigned int connected:1;
131 unsigned int version_received:1; 131 unsigned int version_received:1;
132 unsigned int me_received:1; 132 unsigned int me_received:1;
156 { 156 {
157 va_list args; 157 va_list args;
158 158
159 va_start(args, fmt); 159 va_start(args, fmt);
160 i_error("director(%s): Command %s: %s (input: %s)", conn->name, 160 i_error("director(%s): Command %s: %s (input: %s)", conn->name,
161 conn->cur_cmd, t_strdup_vprintf(fmt, args), conn->cur_line); 161 conn->cur_cmd, t_strdup_vprintf(fmt, args),
162 t_strarray_join(conn->cur_args, "\t"));
162 va_end(args); 163 va_end(args);
163 164
164 if (conn->host != NULL) 165 if (conn->host != NULL)
165 conn->host->last_protocol_failure = ioloop_time; 166 conn->host->last_protocol_failure = ioloop_time;
166 } 167 }
1791 return FALSE; 1792 return FALSE;
1792 } 1793 }
1793 1794
1794 static bool 1795 static bool
1795 director_connection_handle_line(struct director_connection *conn, 1796 director_connection_handle_line(struct director_connection *conn,
1796 const char *line) 1797 char *line)
1797 { 1798 {
1798 const char *cmd, *const *args; 1799 const char *cmd, *const *args;
1799 bool ret; 1800 bool ret;
1800 1801
1801 dir_debug("input: %s: %s", conn->name, line); 1802 dir_debug("input: %s: %s", conn->name, line);
1802 1803
1803 args = t_strsplit_tabescaped(line); 1804 args = t_strsplit_tabescaped_inplace(line);
1804 cmd = args[0]; args++; 1805 cmd = args[0];
1805 if (cmd == NULL) { 1806 if (cmd == NULL) {
1806 director_cmd_error(conn, "Received empty line"); 1807 director_cmd_error(conn, "Received empty line");
1807 return FALSE; 1808 return FALSE;
1808 } 1809 }
1809 1810
1810 conn->cur_cmd = cmd; 1811 conn->cur_cmd = cmd;
1811 conn->cur_line = line; 1812 conn->cur_args = args;
1812 ret = director_connection_handle_cmd(conn, cmd, args); 1813 ret = director_connection_handle_cmd(conn, cmd, args+1);
1813 conn->cur_cmd = NULL; 1814 conn->cur_cmd = NULL;
1814 conn->cur_line = NULL; 1815 conn->cur_args = NULL;
1815 return ret; 1816 return ret;
1816 } 1817 }
1817 1818
1818 static void 1819 static void
1819 director_connection_log_disconnect(struct director_connection *conn, int err, 1820 director_connection_log_disconnect(struct director_connection *conn, int err,