Mercurial > dovecot > core-2.2
comparison src/config/config-connection.c @ 9793:d7ccdbb58a03 HEAD
config: If master module requests configuration, reread it before replying.
If new configuration is invalid, send an ERROR reply back.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 14 Aug 2009 18:13:35 -0400 |
parents | 04cade277134 |
children | e95135898a3c |
comparison
equal
deleted
inserted
replaced
9792:0287c38ba6bf | 9793:d7ccdbb58a03 |
---|---|
5 #include "istream.h" | 5 #include "istream.h" |
6 #include "ostream.h" | 6 #include "ostream.h" |
7 #include "settings-parser.h" | 7 #include "settings-parser.h" |
8 #include "master-service.h" | 8 #include "master-service.h" |
9 #include "config-request.h" | 9 #include "config-request.h" |
10 #include "config-parser.h" | |
10 #include "config-connection.h" | 11 #include "config-connection.h" |
11 | 12 |
12 #include <stdlib.h> | 13 #include <stdlib.h> |
13 #include <unistd.h> | 14 #include <unistd.h> |
14 | 15 |
59 } | 60 } |
60 o_stream_send_str(output, value); | 61 o_stream_send_str(output, value); |
61 o_stream_send_str(output, "\n"); | 62 o_stream_send_str(output, "\n"); |
62 } | 63 } |
63 | 64 |
64 static void config_connection_request(struct config_connection *conn, | 65 static int config_connection_request(struct config_connection *conn, |
65 const char *const *args) | 66 const char *const *args) |
66 { | 67 { |
67 struct config_filter filter; | 68 struct config_filter filter; |
68 const char *module = ""; | 69 const char *path, *error, *module = ""; |
69 | 70 |
70 /* [<args>] */ | 71 /* [<args>] */ |
71 memset(&filter, 0, sizeof(filter)); | 72 memset(&filter, 0, sizeof(filter)); |
72 for (; *args != NULL; args++) { | 73 for (; *args != NULL; args++) { |
73 if (strncmp(*args, "service=", 8) == 0) | 74 if (strncmp(*args, "service=", 8) == 0) |
87 32 : 128; | 88 32 : 128; |
88 } | 89 } |
89 } | 90 } |
90 } | 91 } |
91 | 92 |
93 if (strcmp(module, "master") == 0) { | |
94 /* master reads configuration only when reloading settings */ | |
95 path = master_service_get_config_path(master_service); | |
96 if (config_parse_file(path, TRUE, &error) < 0) { | |
97 o_stream_send_str(conn->output, | |
98 t_strconcat("ERROR ", error, "\n", NULL)); | |
99 config_connection_destroy(conn); | |
100 return -1; | |
101 } | |
102 } | |
103 | |
92 o_stream_cork(conn->output); | 104 o_stream_cork(conn->output); |
93 config_request_handle(&filter, module, 0, config_request_output, | 105 config_request_handle(&filter, module, 0, config_request_output, |
94 conn->output); | 106 conn->output); |
95 o_stream_send_str(conn->output, "\n"); | 107 o_stream_send_str(conn->output, "\n"); |
96 o_stream_uncork(conn->output); | 108 o_stream_uncork(conn->output); |
109 return 0; | |
97 } | 110 } |
98 | 111 |
99 static void config_connection_input(void *context) | 112 static void config_connection_input(void *context) |
100 { | 113 { |
101 struct config_connection *conn = context; | 114 struct config_connection *conn = context; |
128 } | 141 } |
129 | 142 |
130 while ((args = config_connection_next_line(conn)) != NULL) { | 143 while ((args = config_connection_next_line(conn)) != NULL) { |
131 if (args[0] == NULL) | 144 if (args[0] == NULL) |
132 continue; | 145 continue; |
133 if (strcmp(args[0], "REQ") == 0) | 146 if (strcmp(args[0], "REQ") == 0) { |
134 config_connection_request(conn, args + 1); | 147 if (config_connection_request(conn, args + 1) < 0) |
148 break; | |
149 } | |
135 } | 150 } |
136 } | 151 } |
137 | 152 |
138 struct config_connection *config_connection_create(int fd) | 153 struct config_connection *config_connection_create(int fd) |
139 { | 154 { |