diff options
Diffstat (limited to 'src/transport/plugin_transport_smtp.c')
-rw-r--r-- | src/transport/plugin_transport_smtp.c | 642 |
1 files changed, 318 insertions, 324 deletions
diff --git a/src/transport/plugin_transport_smtp.c b/src/transport/plugin_transport_smtp.c index 1c61f07d7..d7b87e7b1 100644 --- a/src/transport/plugin_transport_smtp.c +++ b/src/transport/plugin_transport_smtp.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file transport/plugin_transport_smtp.c | 22 | * @file transport/plugin_transport_smtp.c |
@@ -53,9 +53,7 @@ | |||
53 | /** | 53 | /** |
54 | * Host-Address in a SMTP network. | 54 | * Host-Address in a SMTP network. |
55 | */ | 55 | */ |
56 | typedef struct | 56 | typedef struct { |
57 | { | ||
58 | |||
59 | /** | 57 | /** |
60 | * Filter line that every sender must include in the E-mails such | 58 | * Filter line that every sender must include in the E-mails such |
61 | * that the receiver can effectively filter out the GNUnet traffic | 59 | * that the receiver can effectively filter out the GNUnet traffic |
@@ -69,7 +67,6 @@ typedef struct | |||
69 | * of a multiple of 8 bytes long. | 67 | * of a multiple of 8 bytes long. |
70 | */ | 68 | */ |
71 | char senderAddress[0]; | 69 | char senderAddress[0]; |
72 | |||
73 | } EmailAddress; | 70 | } EmailAddress; |
74 | 71 | ||
75 | GNUNET_NETWORK_STRUCT_BEGIN | 72 | GNUNET_NETWORK_STRUCT_BEGIN |
@@ -78,15 +75,13 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
78 | * Encapsulation of a GNUnet message in the SMTP mail body (before | 75 | * Encapsulation of a GNUnet message in the SMTP mail body (before |
79 | * base64 encoding). | 76 | * base64 encoding). |
80 | */ | 77 | */ |
81 | typedef struct | 78 | typedef struct { |
82 | { | ||
83 | GNUNET_MessageHeader header; | 79 | GNUNET_MessageHeader header; |
84 | 80 | ||
85 | /** | 81 | /** |
86 | * What is the identity of the sender (GNUNET_hash of public key) | 82 | * What is the identity of the sender (GNUNET_hash of public key) |
87 | */ | 83 | */ |
88 | GNUNET_PeerIdentity sender; | 84 | GNUNET_PeerIdentity sender; |
89 | |||
90 | } SMTPMessage; | 85 | } SMTPMessage; |
91 | GNUNET_NETWORK_STRUCT_END | 86 | GNUNET_NETWORK_STRUCT_END |
92 | 87 | ||
@@ -148,13 +143,13 @@ static GNUNET_CronTime last_transmission; | |||
148 | 143 | ||
149 | /* ********************* the real stuff ******************* */ | 144 | /* ********************* the real stuff ******************* */ |
150 | 145 | ||
151 | #define strAUTOncmp(a,b) strncmp(a,b,strlen(b)) | 146 | #define strAUTOncmp(a, b) strncmp(a, b, strlen(b)) |
152 | 147 | ||
153 | /** | 148 | /** |
154 | * Listen to the pipe, decode messages and send to core. | 149 | * Listen to the pipe, decode messages and send to core. |
155 | */ | 150 | */ |
156 | static void * | 151 | static void * |
157 | listenAndDistribute (void *unused) | 152 | listenAndDistribute(void *unused) |
158 | { | 153 | { |
159 | char *line; | 154 | char *line; |
160 | unsigned int linesize; | 155 | unsigned int linesize; |
@@ -168,92 +163,92 @@ listenAndDistribute (void *unused) | |||
168 | unsigned int pos; | 163 | unsigned int pos; |
169 | 164 | ||
170 | linesize = ((GNUNET_MAX_BUFFER_SIZE * 4 / 3) + 8) * (MAX_CHAR_PER_LINE + 2) / MAX_CHAR_PER_LINE; /* maximum size of a line supported */ | 165 | linesize = ((GNUNET_MAX_BUFFER_SIZE * 4 / 3) + 8) * (MAX_CHAR_PER_LINE + 2) / MAX_CHAR_PER_LINE; /* maximum size of a line supported */ |
171 | line = GNUNET_malloc (linesize + 2); /* 2 bytes for off-by-one errors, just to be safe... */ | 166 | line = GNUNET_malloc(linesize + 2); /* 2 bytes for off-by-one errors, just to be safe... */ |
172 | 167 | ||
173 | #define READLINE(l,limit) \ | 168 | #define READLINE(l, limit) \ |
174 | do { retl = fgets(l, (limit), fdes); \ | 169 | do { retl = fgets(l, (limit), fdes); \ |
175 | if ( (retl == NULL) || (smtp_shutdown == GNUNET_YES)) {\ | 170 | if ((retl == NULL) || (smtp_shutdown == GNUNET_YES)) { \ |
176 | goto END; \ | 171 | goto END; \ |
177 | }\ | 172 | } \ |
178 | if (core_api->load_monitor != NULL) \ | 173 | if (core_api->load_monitor != NULL) \ |
179 | GNUNET_network_monitor_notify_transmission(core_api->load_monitor, GNUNET_ND_DOWNLOAD, strlen(retl)); \ | 174 | GNUNET_network_monitor_notify_transmission (core_api->load_monitor, GNUNET_ND_DOWNLOAD, strlen(retl)); \ |
180 | } while (0) | 175 | } while (0) |
181 | 176 | ||
182 | 177 | ||
183 | while (smtp_shutdown == GNUNET_NO) | 178 | while (smtp_shutdown == GNUNET_NO) |
184 | { | ||
185 | fd = OPEN (pipename, O_RDONLY | O_ASYNC); | ||
186 | if (fd == -1) | ||
187 | { | 179 | { |
188 | if (smtp_shutdown == GNUNET_NO) | 180 | fd = OPEN(pipename, O_RDONLY | O_ASYNC); |
189 | GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS); | 181 | if (fd == -1) |
190 | continue; | 182 | { |
191 | } | 183 | if (smtp_shutdown == GNUNET_NO) |
192 | fdes = fdopen (fd, "r"); | 184 | GNUNET_thread_sleep(5 * GNUNET_CRON_SECONDS); |
193 | while (smtp_shutdown == GNUNET_NO) | 185 | continue; |
194 | { | 186 | } |
195 | /* skip until end of header */ | 187 | fdes = fdopen(fd, "r"); |
196 | do | 188 | while (smtp_shutdown == GNUNET_NO) |
197 | { | 189 | { |
198 | READLINE (line, linesize); | 190 | /* skip until end of header */ |
199 | } | 191 | do |
200 | while ((line[0] != '\r') && (line[0] != '\n')); /* expect newline */ | 192 | { |
201 | READLINE (line, linesize); /* read base64 encoded message; decode, process */ | 193 | READLINE(line, linesize); |
202 | pos = 0; | 194 | } |
203 | while (1) | 195 | while ((line[0] != '\r') && (line[0] != '\n')); /* expect newline */ |
204 | { | 196 | READLINE(line, linesize); /* read base64 encoded message; decode, process */ |
205 | pos = strlen (line) - 1; /* ignore new line */ | 197 | pos = 0; |
206 | READLINE (&line[pos], linesize - pos); /* read base64 encoded message; decode, process */ | 198 | while (1) |
207 | if ((line[pos] == '\r') || (line[pos] == '\n')) | 199 | { |
208 | break; /* empty line => end of message! */ | 200 | pos = strlen(line) - 1; /* ignore new line */ |
209 | } | 201 | READLINE(&line[pos], linesize - pos); /* read base64 encoded message; decode, process */ |
210 | size = GNUNET_STRINGS_base64_decode (line, pos, &out); | 202 | if ((line[pos] == '\r') || (line[pos] == '\n')) |
211 | if (size < sizeof (SMTPMessage)) | 203 | break; /* empty line => end of message! */ |
212 | { | 204 | } |
213 | GNUNET_GE_BREAK (ectx, 0); | 205 | size = GNUNET_STRINGS_base64_decode(line, pos, &out); |
214 | GNUNET_free (out); | 206 | if (size < sizeof(SMTPMessage)) |
215 | goto END; | 207 | { |
216 | } | 208 | GNUNET_GE_BREAK(ectx, 0); |
217 | 209 | GNUNET_free(out); | |
218 | mp = (SMTPMessage *) &out[size - sizeof (SMTPMessage)]; | 210 | goto END; |
219 | if (ntohs (mp->header.size) != size) | 211 | } |
220 | { | 212 | |
221 | GNUNET_GE_LOG (ectx, | 213 | mp = (SMTPMessage *)&out[size - sizeof(SMTPMessage)]; |
222 | GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER, | 214 | if (ntohs(mp->header.size) != size) |
223 | _("Received malformed message via %s. Ignored.\n"), | 215 | { |
224 | "SMTP"); | 216 | GNUNET_GE_LOG(ectx, |
217 | GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER, | ||
218 | _("Received malformed message via %s. Ignored.\n"), | ||
219 | "SMTP"); | ||
225 | #if DEBUG_SMTP | 220 | #if DEBUG_SMTP |
226 | GNUNET_GE_LOG (ectx, | 221 | GNUNET_GE_LOG(ectx, |
227 | GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER, | 222 | GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER, |
228 | "Size returned by base64=%d, in the msg=%d.\n", size, | 223 | "Size returned by base64=%d, in the msg=%d.\n", size, |
229 | ntohl (mp->size)); | 224 | ntohl(mp->size)); |
230 | #endif | 225 | #endif |
231 | GNUNET_free (out); | 226 | GNUNET_free(out); |
232 | goto END; | 227 | goto END; |
233 | } | 228 | } |
234 | if (stats != NULL) | 229 | if (stats != NULL) |
235 | stats->change (stat_bytesReceived, size); | 230 | stats->change(stat_bytesReceived, size); |
236 | coreMP = GNUNET_new (GNUNET_TransportPacket); | 231 | coreMP = GNUNET_new(GNUNET_TransportPacket); |
237 | coreMP->msg = out; | 232 | coreMP->msg = out; |
238 | coreMP->size = size - sizeof (SMTPMessage); | 233 | coreMP->size = size - sizeof(SMTPMessage); |
239 | coreMP->tsession = NULL; | 234 | coreMP->tsession = NULL; |
240 | coreMP->sender = mp->sender; | 235 | coreMP->sender = mp->sender; |
241 | #if DEBUG_SMTP | 236 | #if DEBUG_SMTP |
242 | GNUNET_GE_LOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER, | 237 | GNUNET_GE_LOG(ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER, |
243 | "SMTP message passed to the core.\n"); | 238 | "SMTP message passed to the core.\n"); |
244 | #endif | 239 | #endif |
245 | 240 | ||
246 | core_api->receive (coreMP); | 241 | core_api->receive(coreMP); |
247 | } | 242 | } |
248 | END: | 243 | END: |
249 | #if DEBUG_SMTP | 244 | #if DEBUG_SMTP |
250 | GNUNET_GE_LOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER, | 245 | GNUNET_GE_LOG(ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER, |
251 | "SMTP message processed.\n"); | 246 | "SMTP message processed.\n"); |
252 | #endif | 247 | #endif |
253 | if (fdes != NULL) | 248 | if (fdes != NULL) |
254 | fclose (fdes); | 249 | fclose(fdes); |
255 | } | 250 | } |
256 | GNUNET_free (line); | 251 | GNUNET_free(line); |
257 | return NULL; | 252 | return NULL; |
258 | } | 253 | } |
259 | 254 | ||
@@ -269,20 +264,20 @@ END: | |||
269 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 264 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
270 | */ | 265 | */ |
271 | static int | 266 | static int |
272 | api_verify_hello (const GNUNET_MessageHello * hello) | 267 | api_verify_hello(const GNUNET_MessageHello * hello) |
273 | { | 268 | { |
274 | const EmailAddress *maddr; | 269 | const EmailAddress *maddr; |
275 | 270 | ||
276 | maddr = (const EmailAddress *) &hello[1]; | 271 | maddr = (const EmailAddress *)&hello[1]; |
277 | if ((ntohs (hello->header.size) != | 272 | if ((ntohs(hello->header.size) != |
278 | sizeof (GNUNET_MessageHello) + ntohs (hello->senderAddressSize)) || | 273 | sizeof(GNUNET_MessageHello) + ntohs(hello->senderAddressSize)) || |
279 | (maddr->senderAddress | 274 | (maddr->senderAddress |
280 | [ntohs (hello->senderAddressSize) - 1 - FILTER_STRING_SIZE] != '\0')) | 275 | [ntohs(hello->senderAddressSize) - 1 - FILTER_STRING_SIZE] != '\0')) |
281 | { | 276 | { |
282 | GNUNET_GE_BREAK (ectx, 0); | 277 | GNUNET_GE_BREAK(ectx, 0); |
283 | return GNUNET_SYSERR; /* obviously invalid */ | 278 | return GNUNET_SYSERR; /* obviously invalid */ |
284 | } | 279 | } |
285 | if (NULL == strstr (maddr->filter, ": ")) | 280 | if (NULL == strstr(maddr->filter, ": ")) |
286 | return GNUNET_SYSERR; | 281 | return GNUNET_SYSERR; |
287 | return GNUNET_OK; | 282 | return GNUNET_OK; |
288 | } | 283 | } |
@@ -295,65 +290,64 @@ api_verify_hello (const GNUNET_MessageHello * hello) | |||
295 | * @return hello on success, NULL on error | 290 | * @return hello on success, NULL on error |
296 | */ | 291 | */ |
297 | static GNUNET_MessageHello * | 292 | static GNUNET_MessageHello * |
298 | api_create_hello () | 293 | api_create_hello() |
299 | { | 294 | { |
300 | GNUNET_MessageHello *msg; | 295 | GNUNET_MessageHello *msg; |
301 | char *filter; | 296 | char *filter; |
302 | EmailAddress *haddr; | 297 | EmailAddress *haddr; |
303 | int i; | 298 | int i; |
304 | 299 | ||
305 | GNUNET_GC_get_configuration_value_string (core_api->cfg, "SMTP", "FILTER", | 300 | GNUNET_GC_get_configuration_value_string(core_api->cfg, "SMTP", "FILTER", |
306 | "X-mailer: GNUnet", &filter); | 301 | "X-mailer: GNUnet", &filter); |
307 | if (NULL == strstr (filter, ": ")) | 302 | if (NULL == strstr(filter, ": ")) |
308 | { | 303 | { |
309 | GNUNET_GE_LOG (ectx, GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER, | 304 | GNUNET_GE_LOG(ectx, GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER, |
310 | _("SMTP filter string to invalid, lacks ': '\n")); | 305 | _("SMTP filter string to invalid, lacks ': '\n")); |
311 | GNUNET_free (filter); | 306 | GNUNET_free(filter); |
312 | return NULL; | 307 | return NULL; |
313 | } | 308 | } |
314 | 309 | ||
315 | if (strlen (filter) > FILTER_STRING_SIZE) | 310 | if (strlen(filter) > FILTER_STRING_SIZE) |
316 | { | 311 | { |
317 | filter[FILTER_STRING_SIZE] = '\0'; | 312 | filter[FILTER_STRING_SIZE] = '\0'; |
318 | GNUNET_GE_LOG (ectx, GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER, | 313 | GNUNET_GE_LOG(ectx, GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER, |
319 | _("SMTP filter string to long, capped to `%s'\n"), filter); | 314 | _("SMTP filter string to long, capped to `%s'\n"), filter); |
320 | } | 315 | } |
321 | i = (strlen (email) + 8) & (~7); /* make multiple of 8 */ | 316 | i = (strlen(email) + 8) & (~7); /* make multiple of 8 */ |
322 | msg = | 317 | msg = |
323 | GNUNET_malloc (sizeof (GNUNET_MessageHello) + sizeof (EmailAddress) + i); | 318 | GNUNET_malloc(sizeof(GNUNET_MessageHello) + sizeof(EmailAddress) + i); |
324 | memset (msg, 0, sizeof (GNUNET_MessageHello) + sizeof (EmailAddress) + i); | 319 | memset(msg, 0, sizeof(GNUNET_MessageHello) + sizeof(EmailAddress) + i); |
325 | haddr = (EmailAddress *) &msg[1]; | 320 | haddr = (EmailAddress *)&msg[1]; |
326 | memset (&haddr->filter[0], 0, FILTER_STRING_SIZE); | 321 | memset(&haddr->filter[0], 0, FILTER_STRING_SIZE); |
327 | strcpy (&haddr->filter[0], filter); | 322 | strcpy(&haddr->filter[0], filter); |
328 | GNUNET_memcpy (&haddr->senderAddress[0], email, strlen (email) + 1); | 323 | GNUNET_memcpy(&haddr->senderAddress[0], email, strlen(email) + 1); |
329 | msg->senderAddressSize = htons (strlen (email) + 1 + sizeof (EmailAddress)); | 324 | msg->senderAddressSize = htons(strlen(email) + 1 + sizeof(EmailAddress)); |
330 | msg->protocol = htons (GNUNET_TRANSPORT_PROTOCOL_NUMBER_SMTP); | 325 | msg->protocol = htons(GNUNET_TRANSPORT_PROTOCOL_NUMBER_SMTP); |
331 | msg->MTU = htonl (smtpAPI.mtu); | 326 | msg->MTU = htonl(smtpAPI.mtu); |
332 | msg->header.size = htons (GNUNET_sizeof_hello (msg)); | 327 | msg->header.size = htons(GNUNET_sizeof_hello(msg)); |
333 | if (api_verify_hello (msg) == GNUNET_SYSERR) | 328 | if (api_verify_hello(msg) == GNUNET_SYSERR) |
334 | GNUNET_GE_ASSERT (ectx, 0); | 329 | GNUNET_GE_ASSERT(ectx, 0); |
335 | GNUNET_free (filter); | 330 | GNUNET_free(filter); |
336 | return msg; | 331 | return msg; |
337 | } | 332 | } |
338 | 333 | ||
339 | struct GetMessageClosure | 334 | struct GetMessageClosure { |
340 | { | ||
341 | unsigned int esize; | 335 | unsigned int esize; |
342 | unsigned int pos; | 336 | unsigned int pos; |
343 | char *ebody; | 337 | char *ebody; |
344 | }; | 338 | }; |
345 | 339 | ||
346 | static const char * | 340 | static const char * |
347 | get_message (void **buf, int *len, void *cls) | 341 | get_message(void **buf, int *len, void *cls) |
348 | { | 342 | { |
349 | struct GetMessageClosure *gmc = cls; | 343 | struct GetMessageClosure *gmc = cls; |
350 | 344 | ||
351 | *buf = NULL; | 345 | *buf = NULL; |
352 | if (len == NULL) | 346 | if (len == NULL) |
353 | { | 347 | { |
354 | gmc->pos = 0; | 348 | gmc->pos = 0; |
355 | return NULL; | 349 | return NULL; |
356 | } | 350 | } |
357 | if (gmc->pos == gmc->esize) | 351 | if (gmc->pos == gmc->esize) |
358 | return NULL; /* done */ | 352 | return NULL; /* done */ |
359 | *len = gmc->esize; | 353 | *len = gmc->esize; |
@@ -371,8 +365,8 @@ get_message (void **buf, int *len, void *cls) | |||
371 | * @return GNUNET_SYSERR on error, GNUNET_OK on success | 365 | * @return GNUNET_SYSERR on error, GNUNET_OK on success |
372 | */ | 366 | */ |
373 | static int | 367 | static int |
374 | api_send (GNUNET_TSession * tsession, const void *msg, const unsigned int size, | 368 | api_send(GNUNET_TSession * tsession, const void *msg, const unsigned int size, |
375 | int important) | 369 | int important) |
376 | { | 370 | { |
377 | const GNUNET_MessageHello *hello; | 371 | const GNUNET_MessageHello *hello; |
378 | const EmailAddress *haddr; | 372 | const EmailAddress *haddr; |
@@ -392,139 +386,139 @@ api_send (GNUNET_TSession * tsession, const void *msg, const unsigned int size, | |||
392 | if (smtp_shutdown == GNUNET_YES) | 386 | if (smtp_shutdown == GNUNET_YES) |
393 | return GNUNET_SYSERR; | 387 | return GNUNET_SYSERR; |
394 | if ((size == 0) || (size > smtpAPI.mtu)) | 388 | if ((size == 0) || (size > smtpAPI.mtu)) |
395 | { | 389 | { |
396 | GNUNET_GE_BREAK (ectx, 0); | 390 | GNUNET_GE_BREAK(ectx, 0); |
397 | return GNUNET_SYSERR; | 391 | return GNUNET_SYSERR; |
398 | } | 392 | } |
399 | now = GNUNET_get_time (); | 393 | now = GNUNET_get_time(); |
400 | if ((important != GNUNET_YES) && | 394 | if ((important != GNUNET_YES) && |
401 | ((now - last_transmission) * rate_limit) < GNUNET_CRON_HOURS) | 395 | ((now - last_transmission) * rate_limit) < GNUNET_CRON_HOURS) |
402 | return GNUNET_NO; /* rate too high */ | 396 | return GNUNET_NO; /* rate too high */ |
403 | last_transmission = now; | 397 | last_transmission = now; |
404 | 398 | ||
405 | hello = (const GNUNET_MessageHello *) tsession->internal; | 399 | hello = (const GNUNET_MessageHello *)tsession->internal; |
406 | if (hello == NULL) | 400 | if (hello == NULL) |
407 | return GNUNET_SYSERR; | 401 | return GNUNET_SYSERR; |
408 | GNUNET_mutex_lock (lock); | 402 | GNUNET_mutex_lock(lock); |
409 | session = smtp_create_session (); | 403 | session = smtp_create_session(); |
410 | if (session == NULL) | 404 | if (session == NULL) |
411 | { | 405 | { |
412 | GNUNET_GE_LOG (ectx, | 406 | GNUNET_GE_LOG(ectx, |
413 | GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER | | 407 | GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER | |
414 | GNUNET_GE_IMMEDIATE, _("SMTP: `%s' failed: %s.\n"), | 408 | GNUNET_GE_IMMEDIATE, _("SMTP: `%s' failed: %s.\n"), |
415 | "smtp_create_session", smtp_strerror (smtp_errno (), ebuf, | 409 | "smtp_create_session", smtp_strerror(smtp_errno(), ebuf, |
416 | EBUF_LEN)); | 410 | EBUF_LEN)); |
417 | GNUNET_mutex_unlock (lock); | 411 | GNUNET_mutex_unlock(lock); |
418 | return GNUNET_SYSERR; | 412 | return GNUNET_SYSERR; |
419 | } | 413 | } |
420 | if (0 == smtp_set_server (session, smtp_server_name)) | 414 | if (0 == smtp_set_server(session, smtp_server_name)) |
421 | { | 415 | { |
422 | GNUNET_GE_LOG (ectx, | 416 | GNUNET_GE_LOG(ectx, |
423 | GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER | | 417 | GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER | |
424 | GNUNET_GE_IMMEDIATE, _("SMTP: `%s' failed: %s.\n"), | 418 | GNUNET_GE_IMMEDIATE, _("SMTP: `%s' failed: %s.\n"), |
425 | "smtp_set_server", smtp_strerror (smtp_errno (), ebuf, | 419 | "smtp_set_server", smtp_strerror(smtp_errno(), ebuf, |
426 | EBUF_LEN)); | 420 | EBUF_LEN)); |
427 | smtp_destroy_session (session); | 421 | smtp_destroy_session(session); |
428 | GNUNET_mutex_unlock (lock); | 422 | GNUNET_mutex_unlock(lock); |
429 | return GNUNET_SYSERR; | 423 | return GNUNET_SYSERR; |
430 | } | 424 | } |
431 | haddr = (const EmailAddress *) &hello[1]; | 425 | haddr = (const EmailAddress *)&hello[1]; |
432 | message = smtp_add_message (session); | 426 | message = smtp_add_message(session); |
433 | if (message == NULL) | 427 | if (message == NULL) |
434 | { | 428 | { |
435 | GNUNET_GE_LOG (ectx, | 429 | GNUNET_GE_LOG(ectx, |
436 | GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | | 430 | GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | |
437 | GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), | 431 | GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), |
438 | "smtp_add_message", smtp_strerror (smtp_errno (), ebuf, | 432 | "smtp_add_message", smtp_strerror(smtp_errno(), ebuf, |
439 | EBUF_LEN)); | 433 | EBUF_LEN)); |
440 | smtp_destroy_session (session); | 434 | smtp_destroy_session(session); |
441 | GNUNET_mutex_unlock (lock); | 435 | GNUNET_mutex_unlock(lock); |
442 | return GNUNET_SYSERR; | 436 | return GNUNET_SYSERR; |
443 | } | 437 | } |
444 | smtp_set_header (message, "To", NULL, haddr->senderAddress); | 438 | smtp_set_header(message, "To", NULL, haddr->senderAddress); |
445 | smtp_set_header (message, "From", NULL, email); | 439 | smtp_set_header(message, "From", NULL, email); |
446 | 440 | ||
447 | filter = GNUNET_strdup (haddr->filter); | 441 | filter = GNUNET_strdup(haddr->filter); |
448 | fvalue = strstr (filter, ": "); | 442 | fvalue = strstr(filter, ": "); |
449 | GNUNET_GE_ASSERT (NULL, NULL != fvalue); | 443 | GNUNET_GE_ASSERT(NULL, NULL != fvalue); |
450 | fvalue[0] = '\0'; | 444 | fvalue[0] = '\0'; |
451 | fvalue += 2; | 445 | fvalue += 2; |
452 | if (0 == smtp_set_header (message, filter, fvalue)) | 446 | if (0 == smtp_set_header(message, filter, fvalue)) |
453 | { | 447 | { |
454 | GNUNET_GE_LOG (ectx, | 448 | GNUNET_GE_LOG(ectx, |
455 | GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | | 449 | GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | |
456 | GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), | 450 | GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), |
457 | "smtp_set_header", smtp_strerror (smtp_errno (), ebuf, | 451 | "smtp_set_header", smtp_strerror(smtp_errno(), ebuf, |
458 | EBUF_LEN)); | 452 | EBUF_LEN)); |
459 | smtp_destroy_session (session); | 453 | smtp_destroy_session(session); |
460 | GNUNET_mutex_unlock (lock); | 454 | GNUNET_mutex_unlock(lock); |
461 | GNUNET_free (filter); | 455 | GNUNET_free(filter); |
462 | return GNUNET_SYSERR; | 456 | return GNUNET_SYSERR; |
463 | } | 457 | } |
464 | GNUNET_free (filter); | 458 | GNUNET_free(filter); |
465 | m = GNUNET_malloc (size + sizeof (SMTPMessage)); | 459 | m = GNUNET_malloc(size + sizeof(SMTPMessage)); |
466 | GNUNET_memcpy (m, msg, size); | 460 | GNUNET_memcpy(m, msg, size); |
467 | mp = (SMTPMessage *) &m[size]; | 461 | mp = (SMTPMessage *)&m[size]; |
468 | mp->header.size = htons (size + sizeof (SMTPMessage)); | 462 | mp->header.size = htons(size + sizeof(SMTPMessage)); |
469 | mp->header.type = htons (0); | 463 | mp->header.type = htons(0); |
470 | mp->sender = *core_api->my_identity; | 464 | mp->sender = *core_api->my_identity; |
471 | gm_cls.ebody = NULL; | 465 | gm_cls.ebody = NULL; |
472 | gm_cls.pos = 0; | 466 | gm_cls.pos = 0; |
473 | gm_cls.esize = GNUNET_STRINGS_base64_encode (m, size + sizeof (SMTPMessage), &gm_cls.ebody); | 467 | gm_cls.esize = GNUNET_STRINGS_base64_encode(m, size + sizeof(SMTPMessage), &gm_cls.ebody); |
474 | GNUNET_free (m); | 468 | GNUNET_free(m); |
475 | if (0 == smtp_size_set_estimate (message, gm_cls.esize)) | 469 | if (0 == smtp_size_set_estimate(message, gm_cls.esize)) |
476 | { | 470 | { |
477 | GNUNET_GE_LOG (ectx, | 471 | GNUNET_GE_LOG(ectx, |
478 | GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | | 472 | GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | |
479 | GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), | 473 | GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), |
480 | "smtp_size_set_estimate", smtp_strerror (smtp_errno (), ebuf, | 474 | "smtp_size_set_estimate", smtp_strerror(smtp_errno(), ebuf, |
481 | EBUF_LEN)); | 475 | EBUF_LEN)); |
482 | } | 476 | } |
483 | if (0 == smtp_set_messagecb (message, &get_message, &gm_cls)) | 477 | if (0 == smtp_set_messagecb(message, &get_message, &gm_cls)) |
484 | { | 478 | { |
485 | GNUNET_GE_LOG (ectx, | 479 | GNUNET_GE_LOG(ectx, |
486 | GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | | 480 | GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | |
487 | GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), | 481 | GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), |
488 | "smtp_set_messagecb", smtp_strerror (smtp_errno (), ebuf, | 482 | "smtp_set_messagecb", smtp_strerror(smtp_errno(), ebuf, |
489 | EBUF_LEN)); | 483 | EBUF_LEN)); |
490 | smtp_destroy_session (session); | 484 | smtp_destroy_session(session); |
491 | GNUNET_mutex_unlock (lock); | 485 | GNUNET_mutex_unlock(lock); |
492 | GNUNET_free (gm_cls.ebody); | 486 | GNUNET_free(gm_cls.ebody); |
493 | return GNUNET_SYSERR; | 487 | return GNUNET_SYSERR; |
494 | } | 488 | } |
495 | recipient = smtp_add_recipient (message, haddr->senderAddress); | 489 | recipient = smtp_add_recipient(message, haddr->senderAddress); |
496 | if (recipient == NULL) | 490 | if (recipient == NULL) |
497 | { | 491 | { |
498 | GNUNET_GE_LOG (ectx, | 492 | GNUNET_GE_LOG(ectx, |
499 | GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | | 493 | GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | |
500 | GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), | 494 | GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), |
501 | "smtp_add_recipient", smtp_strerror (smtp_errno (), ebuf, | 495 | "smtp_add_recipient", smtp_strerror(smtp_errno(), ebuf, |
502 | EBUF_LEN)); | 496 | EBUF_LEN)); |
503 | smtp_destroy_session (session); | 497 | smtp_destroy_session(session); |
504 | GNUNET_mutex_unlock (lock); | 498 | GNUNET_mutex_unlock(lock); |
505 | return GNUNET_SYSERR; | 499 | return GNUNET_SYSERR; |
506 | } | 500 | } |
507 | if (0 == smtp_start_session (session)) | 501 | if (0 == smtp_start_session(session)) |
508 | { | 502 | { |
509 | GNUNET_GE_LOG (ectx, | 503 | GNUNET_GE_LOG(ectx, |
510 | GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | | 504 | GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | |
511 | GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), | 505 | GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), |
512 | "smtp_start_session", smtp_strerror (smtp_errno (), ebuf, | 506 | "smtp_start_session", smtp_strerror(smtp_errno(), ebuf, |
513 | EBUF_LEN)); | 507 | EBUF_LEN)); |
514 | smtp_destroy_session (session); | 508 | smtp_destroy_session(session); |
515 | GNUNET_mutex_unlock (lock); | 509 | GNUNET_mutex_unlock(lock); |
516 | GNUNET_free (gm_cls.ebody); | 510 | GNUNET_free(gm_cls.ebody); |
517 | return GNUNET_SYSERR; | 511 | return GNUNET_SYSERR; |
518 | } | 512 | } |
519 | if (stats != NULL) | 513 | if (stats != NULL) |
520 | stats->change (stat_bytesSent, size); | 514 | stats->change(stat_bytesSent, size); |
521 | if (core_api->load_monitor != NULL) | 515 | if (core_api->load_monitor != NULL) |
522 | GNUNET_network_monitor_notify_transmission (core_api->load_monitor, | 516 | GNUNET_network_monitor_notify_transmission(core_api->load_monitor, |
523 | GNUNET_ND_UPLOAD, gm_cls.esize); | 517 | GNUNET_ND_UPLOAD, gm_cls.esize); |
524 | smtp_message_reset_status (message); /* this is needed to plug a 28-byte/message memory leak in libesmtp */ | 518 | smtp_message_reset_status(message); /* this is needed to plug a 28-byte/message memory leak in libesmtp */ |
525 | smtp_destroy_session (session); | 519 | smtp_destroy_session(session); |
526 | GNUNET_mutex_unlock (lock); | 520 | GNUNET_mutex_unlock(lock); |
527 | GNUNET_free (gm_cls.ebody); | 521 | GNUNET_free(gm_cls.ebody); |
528 | return GNUNET_OK; | 522 | return GNUNET_OK; |
529 | } | 523 | } |
530 | 524 | ||
@@ -536,15 +530,15 @@ api_send (GNUNET_TSession * tsession, const void *msg, const unsigned int size, | |||
536 | * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed | 530 | * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed |
537 | */ | 531 | */ |
538 | static int | 532 | static int |
539 | api_connect (const GNUNET_MessageHello * hello, GNUNET_TSession ** tsessionPtr, | 533 | api_connect(const GNUNET_MessageHello * hello, GNUNET_TSession ** tsessionPtr, |
540 | int may_reuse) | 534 | int may_reuse) |
541 | { | 535 | { |
542 | GNUNET_TSession *tsession; | 536 | GNUNET_TSession *tsession; |
543 | 537 | ||
544 | tsession = GNUNET_new (GNUNET_TSession); | 538 | tsession = GNUNET_new(GNUNET_TSession); |
545 | tsession->internal = GNUNET_malloc (GNUNET_sizeof_hello (hello)); | 539 | tsession->internal = GNUNET_malloc(GNUNET_sizeof_hello(hello)); |
546 | tsession->peer = hello->senderIdentity; | 540 | tsession->peer = hello->senderIdentity; |
547 | GNUNET_memcpy (tsession->internal, hello, GNUNET_sizeof_hello (hello)); | 541 | GNUNET_memcpy(tsession->internal, hello, GNUNET_sizeof_hello(hello)); |
548 | tsession->ttype = smtpAPI.protocol_number; | 542 | tsession->ttype = smtpAPI.protocol_number; |
549 | (*tsessionPtr) = tsession; | 543 | (*tsessionPtr) = tsession; |
550 | return GNUNET_OK; | 544 | return GNUNET_OK; |
@@ -557,14 +551,14 @@ api_connect (const GNUNET_MessageHello * hello, GNUNET_TSession ** tsessionPtr, | |||
557 | * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed | 551 | * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed |
558 | */ | 552 | */ |
559 | static int | 553 | static int |
560 | api_disconnect (GNUNET_TSession * tsession) | 554 | api_disconnect(GNUNET_TSession * tsession) |
561 | { | 555 | { |
562 | if (tsession != NULL) | 556 | if (tsession != NULL) |
563 | { | 557 | { |
564 | if (tsession->internal != NULL) | 558 | if (tsession->internal != NULL) |
565 | GNUNET_free (tsession->internal); | 559 | GNUNET_free(tsession->internal); |
566 | GNUNET_free (tsession); | 560 | GNUNET_free(tsession); |
567 | } | 561 | } |
568 | return GNUNET_OK; | 562 | return GNUNET_OK; |
569 | } | 563 | } |
570 | 564 | ||
@@ -573,18 +567,18 @@ api_disconnect (GNUNET_TSession * tsession) | |||
573 | * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed | 567 | * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed |
574 | */ | 568 | */ |
575 | static int | 569 | static int |
576 | api_start_transport_server () | 570 | api_start_transport_server() |
577 | { | 571 | { |
578 | smtp_shutdown = GNUNET_NO; | 572 | smtp_shutdown = GNUNET_NO; |
579 | /* initialize SMTP network */ | 573 | /* initialize SMTP network */ |
580 | dispatchThread = GNUNET_thread_create (&listenAndDistribute, NULL, 1024 * 4); | 574 | dispatchThread = GNUNET_thread_create(&listenAndDistribute, NULL, 1024 * 4); |
581 | if (dispatchThread == NULL) | 575 | if (dispatchThread == NULL) |
582 | { | 576 | { |
583 | GNUNET_GE_DIE_STRERROR (ectx, | 577 | GNUNET_GE_DIE_STRERROR(ectx, |
584 | GNUNET_GE_ADMIN | GNUNET_GE_BULK | GNUNET_GE_FATAL, | 578 | GNUNET_GE_ADMIN | GNUNET_GE_BULK | GNUNET_GE_FATAL, |
585 | "pthread_create"); | 579 | "pthread_create"); |
586 | return GNUNET_SYSERR; | 580 | return GNUNET_SYSERR; |
587 | } | 581 | } |
588 | return GNUNET_OK; | 582 | return GNUNET_OK; |
589 | } | 583 | } |
590 | 584 | ||
@@ -593,13 +587,13 @@ api_start_transport_server () | |||
593 | * restarted later! | 587 | * restarted later! |
594 | */ | 588 | */ |
595 | static int | 589 | static int |
596 | api_stop_transport_server () | 590 | api_stop_transport_server() |
597 | { | 591 | { |
598 | void *unused; | 592 | void *unused; |
599 | 593 | ||
600 | smtp_shutdown = GNUNET_YES; | 594 | smtp_shutdown = GNUNET_YES; |
601 | GNUNET_thread_stop_sleep (dispatchThread); | 595 | GNUNET_thread_stop_sleep(dispatchThread); |
602 | GNUNET_thread_join (dispatchThread, &unused); | 596 | GNUNET_thread_join(dispatchThread, &unused); |
603 | return GNUNET_OK; | 597 | return GNUNET_OK; |
604 | } | 598 | } |
605 | 599 | ||
@@ -607,8 +601,8 @@ api_stop_transport_server () | |||
607 | * Convert SMTP hello to an IP address (always fails). | 601 | * Convert SMTP hello to an IP address (always fails). |
608 | */ | 602 | */ |
609 | static int | 603 | static int |
610 | api_hello_to_address (const GNUNET_MessageHello * hello, void **sa, | 604 | api_hello_to_address(const GNUNET_MessageHello * hello, void **sa, |
611 | unsigned int *sa_len) | 605 | unsigned int *sa_len) |
612 | { | 606 | { |
613 | return GNUNET_SYSERR; | 607 | return GNUNET_SYSERR; |
614 | } | 608 | } |
@@ -617,7 +611,7 @@ api_hello_to_address (const GNUNET_MessageHello * hello, void **sa, | |||
617 | * Always fails. | 611 | * Always fails. |
618 | */ | 612 | */ |
619 | static int | 613 | static int |
620 | api_associate (GNUNET_TSession * tsession) | 614 | api_associate(GNUNET_TSession * tsession) |
621 | { | 615 | { |
622 | return GNUNET_SYSERR; /* SMTP connections can never be associated */ | 616 | return GNUNET_SYSERR; /* SMTP connections can never be associated */ |
623 | } | 617 | } |
@@ -627,8 +621,8 @@ api_associate (GNUNET_TSession * tsession) | |||
627 | * frequency limits to SMTP in the future!). | 621 | * frequency limits to SMTP in the future!). |
628 | */ | 622 | */ |
629 | static int | 623 | static int |
630 | api_test_would_try (GNUNET_TSession * tsession, unsigned int size, | 624 | api_test_would_try(GNUNET_TSession * tsession, unsigned int size, |
631 | int important) | 625 | int important) |
632 | { | 626 | { |
633 | return GNUNET_OK; /* we always try... */ | 627 | return GNUNET_OK; /* we always try... */ |
634 | } | 628 | } |
@@ -638,64 +632,64 @@ api_test_would_try (GNUNET_TSession * tsession, unsigned int size, | |||
638 | * returns the smtp transport API. | 632 | * returns the smtp transport API. |
639 | */ | 633 | */ |
640 | GNUNET_TransportAPI * | 634 | GNUNET_TransportAPI * |
641 | inittransport_smtp (struct GNUNET_CoreAPIForTransport * core) | 635 | inittransport_smtp(struct GNUNET_CoreAPIForTransport * core) |
642 | { | 636 | { |
643 | unsigned long long mtu; | 637 | unsigned long long mtu; |
644 | struct sigaction sa; | 638 | struct sigaction sa; |
645 | 639 | ||
646 | core_api = core; | 640 | core_api = core; |
647 | ectx = core->ectx; | 641 | ectx = core->ectx; |
648 | if (!GNUNET_GC_have_configuration_value (core_api->cfg, "SMTP", "EMAIL")) | 642 | if (!GNUNET_GC_have_configuration_value(core_api->cfg, "SMTP", "EMAIL")) |
649 | { | 643 | { |
650 | GNUNET_GE_LOG (ectx, GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER, | 644 | GNUNET_GE_LOG(ectx, GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER, |
651 | _ | 645 | _ |
652 | ("No email-address specified, can not start SMTP transport.\n")); | 646 | ("No email-address specified, can not start SMTP transport.\n")); |
653 | return NULL; | 647 | return NULL; |
654 | } | 648 | } |
655 | GNUNET_GC_get_configuration_value_number (core_api->cfg, "SMTP", "MTU", 1200, | 649 | GNUNET_GC_get_configuration_value_number(core_api->cfg, "SMTP", "MTU", 1200, |
656 | SMTP_MESSAGE_SIZE, | 650 | SMTP_MESSAGE_SIZE, |
657 | SMTP_MESSAGE_SIZE, &mtu); | 651 | SMTP_MESSAGE_SIZE, &mtu); |
658 | GNUNET_GC_get_configuration_value_number (core_api->cfg, "SMTP", "RATELIMIT", | 652 | GNUNET_GC_get_configuration_value_number(core_api->cfg, "SMTP", "RATELIMIT", |
659 | 0, 0, 1024 * 1024, &rate_limit); | 653 | 0, 0, 1024 * 1024, &rate_limit); |
660 | stats = core_api->service_request ("stats"); | 654 | stats = core_api->service_request("stats"); |
661 | if (stats != NULL) | 655 | if (stats != NULL) |
662 | { | 656 | { |
663 | stat_bytesReceived = | 657 | stat_bytesReceived = |
664 | stats->create (gettext_noop ("# bytes received via SMTP")); | 658 | stats->create(gettext_noop("# bytes received via SMTP")); |
665 | stat_bytesSent = stats->create (gettext_noop ("# bytes sent via SMTP")); | 659 | stat_bytesSent = stats->create(gettext_noop("# bytes sent via SMTP")); |
666 | stat_bytesDropped = | 660 | stat_bytesDropped = |
667 | stats->create (gettext_noop ("# bytes dropped by SMTP (outgoing)")); | 661 | stats->create(gettext_noop("# bytes dropped by SMTP (outgoing)")); |
668 | } | 662 | } |
669 | GNUNET_GC_get_configuration_value_filename (core_api->cfg, "SMTP", "PIPE", &pipename); | 663 | GNUNET_GC_get_configuration_value_filename(core_api->cfg, "SMTP", "PIPE", &pipename); |
670 | unlink (pipename); | 664 | unlink(pipename); |
671 | if (0 != mkfifo (pipename, S_IWUSR | S_IRUSR | S_IWGRP | S_IWOTH)) | 665 | if (0 != mkfifo(pipename, S_IWUSR | S_IRUSR | S_IWGRP | S_IWOTH)) |
672 | { | 666 | { |
673 | GNUNET_GE_LOG_STRERROR (ectx, | 667 | GNUNET_GE_LOG_STRERROR(ectx, |
674 | GNUNET_GE_ADMIN | GNUNET_GE_BULK | GNUNET_GE_FATAL, | 668 | GNUNET_GE_ADMIN | GNUNET_GE_BULK | GNUNET_GE_FATAL, |
675 | "mkfifo"); | 669 | "mkfifo"); |
676 | GNUNET_free (pipename); | 670 | GNUNET_free(pipename); |
677 | core_api->service_release (stats); | 671 | core_api->service_release(stats); |
678 | stats = NULL; | 672 | stats = NULL; |
679 | return NULL; | 673 | return NULL; |
680 | } | 674 | } |
681 | /* we need to allow the mailer program to send us messages; | 675 | /* we need to allow the mailer program to send us messages; |
682 | * easiest done by giving it write permissions (see Mantis #1142) */ | 676 | * easiest done by giving it write permissions (see Mantis #1142) */ |
683 | if (0 != chmod (pipename, S_IWUSR | S_IRUSR | S_IWGRP | S_IWOTH)) | 677 | if (0 != chmod(pipename, S_IWUSR | S_IRUSR | S_IWGRP | S_IWOTH)) |
684 | GNUNET_GE_LOG_STRERROR (ectx, | 678 | GNUNET_GE_LOG_STRERROR(ectx, |
685 | GNUNET_GE_ADMIN | GNUNET_GE_BULK | | 679 | GNUNET_GE_ADMIN | GNUNET_GE_BULK | |
686 | GNUNET_GE_WARNING, "chmod"); | 680 | GNUNET_GE_WARNING, "chmod"); |
687 | GNUNET_GC_get_configuration_value_string (core_api->cfg, "SMTP", "EMAIL", NULL, | 681 | GNUNET_GC_get_configuration_value_string(core_api->cfg, "SMTP", "EMAIL", NULL, |
688 | &email); | 682 | &email); |
689 | lock = GNUNET_mutex_create (GNUNET_NO); | 683 | lock = GNUNET_mutex_create(GNUNET_NO); |
690 | GNUNET_GC_get_configuration_value_string (core_api->cfg, "SMTP", "SERVER", | 684 | GNUNET_GC_get_configuration_value_string(core_api->cfg, "SMTP", "SERVER", |
691 | "localhost:25", &smtp_server_name); | 685 | "localhost:25", &smtp_server_name); |
692 | sa.sa_handler = SIG_IGN; | 686 | sa.sa_handler = SIG_IGN; |
693 | sigemptyset (&sa.sa_mask); | 687 | sigemptyset(&sa.sa_mask); |
694 | sa.sa_flags = 0; | 688 | sa.sa_flags = 0; |
695 | sigaction (SIGPIPE, &sa, &old_handler); | 689 | sigaction(SIGPIPE, &sa, &old_handler); |
696 | 690 | ||
697 | smtpAPI.protocol_number = GNUNET_TRANSPORT_PROTOCOL_NUMBER_SMTP; | 691 | smtpAPI.protocol_number = GNUNET_TRANSPORT_PROTOCOL_NUMBER_SMTP; |
698 | smtpAPI.mtu = mtu - sizeof (SMTPMessage); | 692 | smtpAPI.mtu = mtu - sizeof(SMTPMessage); |
699 | smtpAPI.cost = 50; | 693 | smtpAPI.cost = 50; |
700 | smtpAPI.hello_verify = &api_verify_hello; | 694 | smtpAPI.hello_verify = &api_verify_hello; |
701 | smtpAPI.hello_create = &api_create_hello; | 695 | smtpAPI.hello_create = &api_create_hello; |
@@ -711,21 +705,21 @@ inittransport_smtp (struct GNUNET_CoreAPIForTransport * core) | |||
711 | } | 705 | } |
712 | 706 | ||
713 | void | 707 | void |
714 | donetransport_smtp () | 708 | donetransport_smtp() |
715 | { | 709 | { |
716 | sigaction (SIGPIPE, &old_handler, NULL); | 710 | sigaction(SIGPIPE, &old_handler, NULL); |
717 | GNUNET_free (smtp_server_name); | 711 | GNUNET_free(smtp_server_name); |
718 | if (stats != NULL) | 712 | if (stats != NULL) |
719 | { | 713 | { |
720 | core_api->service_release (stats); | 714 | core_api->service_release(stats); |
721 | stats = NULL; | 715 | stats = NULL; |
722 | } | 716 | } |
723 | GNUNET_mutex_destroy (lock); | 717 | GNUNET_mutex_destroy(lock); |
724 | lock = NULL; | 718 | lock = NULL; |
725 | unlink (pipename); | 719 | unlink(pipename); |
726 | GNUNET_free (pipename); | 720 | GNUNET_free(pipename); |
727 | pipename = NULL; | 721 | pipename = NULL; |
728 | GNUNET_free (email); | 722 | GNUNET_free(email); |
729 | email = NULL; | 723 | email = NULL; |
730 | } | 724 | } |
731 | 725 | ||