~ubuntu-branches/ubuntu/trusty/keepalived/trusty

« back to all changes in this revision

Viewing changes to keepalived/core/smtp.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-05-12 20:26:15 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090512202615-k850bw35qpuvpq4p
Tags: 1.1.17-1ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/rules: DEB_UPDATE_RCD_PARAMS := expicit init start/stop
    parameters (don't stop at 0 and 6)
  - debian/init.d: init script header adapted to stop rule
  - debian/keepalived.postinst: Remove shutdown and reboot links

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 *              using the smtp protocol according to the RFC 821. A non blocking
8
8
 *              timeouted connection is used to handle smtp protocol.
9
9
 *
10
 
 * Version:     $Id: smtp.c,v 1.1.15 2007/09/15 04:07:41 acassen Exp $
 
10
 * Version:     $Id: smtp.c,v 1.1.17 2009/03/05 01:31:12 acassen Exp $
11
11
 *
12
12
 * Author:      Alexandre Cassen, <acassen@linux-vs.org>
13
13
 *
21
21
 *              as published by the Free Software Foundation; either version
22
22
 *              2 of the License, or (at your option) any later version.
23
23
 *
24
 
 * Copyright (C) 2001-2007 Alexandre Cassen, <acassen@freebox.fr>
 
24
 * Copyright (C) 2001-2009 Alexandre Cassen, <acassen@freebox.fr>
25
25
 */
26
26
 
27
27
#include <time.h>
32
32
#include "scheduler.h"
33
33
#include "memory.h"
34
34
#include "list.h"
 
35
#include "logger.h"
35
36
#include "utils.h"
36
37
 
37
38
/* SMTP FSM definition */
96
97
{
97
98
        smtp_thread_arg *smtp_arg = THREAD_ARG(thread_obj);
98
99
 
99
 
        syslog(LOG_INFO, "SMTP connection ERROR to [%s:%d].",
 
100
        log_message(LOG_INFO, "SMTP connection ERROR to [%s:%d].",
100
101
               inet_ntop2(data->smtp_server), SMTP_PORT);
101
102
        free_smtp_all(smtp_arg);
102
103
        return 0;
106
107
{
107
108
        smtp_thread_arg *smtp_arg = THREAD_ARG(thread_obj);
108
109
 
109
 
        syslog(LOG_INFO, "Timeout connecting SMTP server [%s:%d].",
 
110
        log_message(LOG_INFO, "Timeout connecting SMTP server [%s:%d].",
110
111
               inet_ntop2(data->smtp_server), SMTP_PORT);
111
112
        free_smtp_all(smtp_arg);
112
113
        return 0;
137
138
{
138
139
        smtp_thread_arg *smtp_arg = THREAD_ARG(thread_obj);
139
140
 
140
 
        syslog(LOG_INFO, "Remote SMTP server [%s:%d] connected.",
 
141
        log_message(LOG_INFO, "Remote SMTP server [%s:%d] connected.",
141
142
               inet_ntop2(data->smtp_server), SMTP_PORT);
142
143
 
143
144
        smtp_arg->stage = connect_success;
159
160
        smtp_arg = THREAD_ARG(thread_obj);
160
161
 
161
162
        if (thread_obj->type == THREAD_READ_TIMEOUT) {
162
 
                syslog(LOG_INFO,
 
163
                log_message(LOG_INFO,
163
164
                       "Timeout reading data to remote SMTP server [%s:%d].",
164
165
                       inet_ntop2(data->smtp_server), SMTP_PORT);
165
166
                SMTP_FSM_READ(QUIT, thread_obj, 0);
174
175
        if (rcv_buffer_size == -1) {
175
176
                if (errno == EAGAIN)
176
177
                        goto end;
177
 
                syslog(LOG_INFO,
 
178
                log_message(LOG_INFO,
178
179
                       "Error reading data from remote SMTP server [%s:%d].",
179
180
                       inet_ntop2(data->smtp_server), SMTP_PORT);
180
181
                SMTP_FSM_READ(QUIT, thread_obj, 0);
183
184
 
184
185
        /* received data overflow buffer size ? */
185
186
        if (smtp_arg->buflen >= SMTP_BUFFER_MAX) {
186
 
                syslog(LOG_INFO,
 
187
                log_message(LOG_INFO,
187
188
                       "Received buffer from remote SMTP server [%s:%d]"
188
189
                       " overflow our get read buffer length.",
189
190
                       inet_ntop2(data->smtp_server), SMTP_PORT);
245
246
                thread_add_write(thread_obj->master, smtp_send_thread, smtp_arg,
246
247
                                 smtp_arg->fd, data->smtp_connection_to);
247
248
        } else {
248
 
                syslog(LOG_INFO,
 
249
                log_message(LOG_INFO,
249
250
                       "Can not read data from remote SMTP server [%s:%d].",
250
251
                       inet_ntop2(data->smtp_server), SMTP_PORT);
251
252
                SMTP_FSM_READ(QUIT, thread_obj, 0);
260
261
        smtp_thread_arg *smtp_arg = THREAD_ARG(thread_obj);
261
262
 
262
263
        if (thread_obj->type == THREAD_WRITE_TIMEOUT) {
263
 
                syslog(LOG_INFO,
 
264
                log_message(LOG_INFO,
264
265
                       "Timeout sending data to remote SMTP server [%s:%d].",
265
266
                       inet_ntop2(data->smtp_server), SMTP_PORT);
266
267
                SMTP_FSM_READ(QUIT, thread_obj, 0);
280
281
                thread_add_read(thread_obj->master, smtp_read_thread, smtp_arg,
281
282
                                thread_obj->u.fd, data->smtp_connection_to);
282
283
        } else {
283
 
                syslog(LOG_INFO,
 
284
                log_message(LOG_INFO,
284
285
                       "Can not send data to remote SMTP server [%s:%d].",
285
286
                       inet_ntop2(data->smtp_server), SMTP_PORT);
286
287
                SMTP_FSM_READ(QUIT, thread_obj, 0);
297
298
        if (status == 220) {
298
299
                smtp_arg->stage++;
299
300
        } else {
300
 
                syslog(LOG_INFO, "Error connecting SMTP server[%s:%d]."
 
301
                log_message(LOG_INFO, "Error connecting SMTP server[%s:%d]."
301
302
                       " SMTP status code = %d", inet_ntop2(data->smtp_server),
302
303
                       SMTP_PORT, status);
303
304
                smtp_arg->stage = ERROR;
329
330
        if (status == 250) {
330
331
                smtp_arg->stage++;
331
332
        } else {
332
 
                syslog(LOG_INFO,
 
333
                log_message(LOG_INFO,
333
334
                       "Error processing HELO cmd on SMTP server [%s:%d]."
334
335
                       " SMTP status code = %d", inet_ntop2(data->smtp_server),
335
336
                       SMTP_PORT, status);
362
363
        if (status == 250) {
363
364
                smtp_arg->stage++;
364
365
        } else {
365
 
                syslog(LOG_INFO,
 
366
                log_message(LOG_INFO,
366
367
                       "Error processing MAIL cmd on SMTP server [%s:%d]."
367
368
                       " SMTP status code = %d", inet_ntop2(data->smtp_server),
368
369
                       SMTP_PORT, status);
407
408
                if (!fetched_email)
408
409
                        smtp_arg->stage++;
409
410
        } else {
410
 
                syslog(LOG_INFO,
 
411
                log_message(LOG_INFO,
411
412
                       "Error processing RCPT cmd on SMTP server [%s:%d]."
412
413
                       " SMTP status code = %d", inet_ntop2(data->smtp_server),
413
414
                       SMTP_PORT, status);
436
437
        if (status == 354) {
437
438
                smtp_arg->stage++;
438
439
        } else {
439
 
                syslog(LOG_INFO,
 
440
                log_message(LOG_INFO,
440
441
                       "Error processing DATA cmd on SMTP server [%s:%d]."
441
442
                       " SMTP status code = %d", inet_ntop2(data->smtp_server),
442
443
                       SMTP_PORT, status);
491
492
        smtp_thread_arg *smtp_arg = THREAD_ARG(thread_obj);
492
493
 
493
494
        if (status == 250) {
494
 
                syslog(LOG_INFO, "SMTP alert successfully sent.");
 
495
                log_message(LOG_INFO, "SMTP alert successfully sent.");
495
496
                smtp_arg->stage++;
496
497
        } else {
497
 
                syslog(LOG_INFO,
 
498
                log_message(LOG_INFO,
498
499
                       "Error processing DOT cmd on SMTP server [%s:%d]."
499
500
                       " SMTP status code = %d", inet_ntop2(data->smtp_server),
500
501
                       SMTP_PORT, status);