~ubuntu-branches/ubuntu/karmic/cyrus-imapd-2.2/karmic

« back to all changes in this revision

Viewing changes to imap/backend.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-07-11 18:51:39 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060711185139-gl3oe4tppp7g3euf
Tags: 2.2.13-4ubuntu1
Synchronize with Debian unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
40
40
 */
41
41
 
42
 
/* $Id: backend.c,v 1.35 2005/02/14 06:39:55 shadow Exp $ */
 
42
/* $Id: backend.c,v 1.39 2006/02/07 20:57:27 murch Exp $ */
43
43
 
44
44
#include <config.h>
45
45
 
200
200
        return r;
201
201
    }
202
202
 
203
 
    secprops = mysasl_secprops(0);
 
203
    secprops = mysasl_secprops(SASL_SEC_NOPLAINTEXT);
204
204
    r = sasl_setprop(s->saslconn, SASL_SEC_PROPS, secprops);
205
205
    if (r != SASL_OK) {
206
206
        return r;
271
271
    /* need to (re)establish connection to server or create one */
272
272
    int sock = -1;
273
273
    int r;
274
 
    int err;
275
 
    struct addrinfo hints, *res0 = NULL, *res;
 
274
    int err = 0;
 
275
    struct addrinfo hints, *res0 = NULL, *res1 = NULL, *res;
276
276
    struct sockaddr_un sunsock;
277
277
    char buf[2048], *mechlist = NULL;
278
278
    struct sigaction action;
315
315
            free(ret);
316
316
            return NULL;
317
317
        }
 
318
        /* Get addrinfo struct for local interface. */
 
319
        err = getaddrinfo(config_servername, NULL, &hints, &res1);
 
320
        if(err) {
 
321
            syslog(LOG_ERR, "getaddrinfo(%s) failed: %s",
 
322
                   config_servername, gai_strerror(err));
 
323
        }
318
324
    }
319
325
 
320
326
    /* Setup timeout */
331
337
        sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
332
338
        if (sock < 0)
333
339
            continue;
 
340
        /* Bind to local interface. */
 
341
        if (!err) {
 
342
            if (bind(sock, res1->ai_addr, res1->ai_addrlen) < 0) {
 
343
                struct sockaddr_in *local_sockaddr = (struct sockaddr_in *) res1->ai_addr;
 
344
                syslog(LOG_ERR, "failed to bind to address %s: %s",
 
345
                       inet_ntoa(local_sockaddr->sin_addr), strerror(errno));
 
346
            }
 
347
            freeaddrinfo(res1);
 
348
        }
334
349
        alarm(config_getint(IMAPOPT_CLIENT_TIMEOUT));
335
350
        if (connect(sock, res->ai_addr, res->ai_addrlen) >= 0)
336
351
            break;
420
435
        if (prot && prot->logout_cmd.cmd) {
421
436
            prot_printf(s->out, "%s\r\n", prot->logout_cmd.cmd);
422
437
            prot_flush(s->out);
423
 
 
 
438
#if 0  /* XXX  don't care about response -- we may not get one */
424
439
            while (prot_fgets(buf, sizeof(buf), s->in)) {
425
440
                if (!strncmp(prot->logout_cmd.resp, buf,
426
441
                             strlen(prot->logout_cmd.resp))) {
427
442
                    break;
428
443
                }
429
444
            }
 
445
#endif
430
446
        }
431
447
 
432
448
        /* Flush the incoming buffer */