- switch (conn->account.type)
- {
- case M_ACCT_TYPE_IMAP:
- service = "imap";
- break;
- case M_ACCT_TYPE_POP:
- service = "pop-3";
- break;
- default:
- dprint (1, (debugfile, "mutt_sasl_client_new: account type unset\n"));
- return -1;
- }
-
-#ifdef USE_SASL2
- size = sizeof (local);
- if (getsockname (conn->fd, (struct sockaddr *)&local, &size)){
- dprint (1, (debugfile, "mutt_sasl_client_new: getsockname for local failed\n"));
- return -1;
- }
- else
- if (iptostring((struct sockaddr *)&local, size, iplocalport, IP_PORT_BUFLEN) != SASL_OK){
- dprint (1, (debugfile, "mutt_sasl_client_new: iptostring for local failed\n"));
- return -1;
- }
-
- size = sizeof (remote);
- if (getpeername (conn->fd, (struct sockaddr *)&remote, &size)){
- dprint (1, (debugfile, "mutt_sasl_client_new: getsockname for remote failed\n"));
- return -1;
- }
- else
- if (iptostring((struct sockaddr *)&remote, size, ipremoteport, IP_PORT_BUFLEN) != SASL_OK){
- dprint (1, (debugfile, "mutt_sasl_client_new: iptostring for remote failed\n"));
- return -1;
- }
-
-dprint(1,(debugfile, "local ip: %s, remote ip:%s\n", iplocalport, ipremoteport));
-
- rc = sasl_client_new (service, conn->account.host, iplocalport, ipremoteport,
- mutt_sasl_get_callbacks (&conn->account), 0, saslconn);
-
-#else
- rc = sasl_client_new (service, conn->account.host,
- mutt_sasl_get_callbacks (&conn->account), SASL_SECURITY_LAYER, saslconn);
-#endif
-
- if (rc != SASL_OK)
- {
- dprint (1, (debugfile,
- "mutt_sasl_client_new: Error allocating SASL connection\n"));
- return -1;
- }
-
- /*** set sasl IP properties, necessary for use with krb4 ***/
- /* Do we need to fail if this fails? I would assume having these unset
- * would just disable KRB4. Who wrote this code? I'm not sure how this
- * interacts with the NSS code either, since that mucks with the fd. */
-#ifndef USE_SASL2 /* with SASLv2 this all happens in sasl_client_new */
- {
- struct sockaddr_in local, remote;