Changeset 3545:31c0da584780
- Timestamp:
- 2003-12-29 03:37:41 (5 years ago)
- Author:
- Patrick Welche <prlw1@…>
- Branch:
- HEAD
- Message:
-
A while ago I posted a similar patch which is necessary as when mutt
tries to connect to an imap server over ipv6 it stores the address
in a sockaddr which may not be large enough to hold the ipv6 address.
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r3046
|
r3545
|
|
| 7 | 7 | dnl Defines GSSAPI_CFLAGS and GSSAPI_LIBS if found. |
| 8 | 8 | dnl Defines GSSAPI_IMPL to "Heimdal", "MIT", or "OldMIT", or "none" if not found |
| 9 | | AC_DEFUN(MUTT_AM_PATH_GSSAPI, |
| | 9 | AC_DEFUN([MUTT_AM_PATH_GSSAPI], |
| 10 | 10 | [ |
| 11 | 11 | GSSAPI_PREFIX=[$]$1 |
-
|
r3475
|
r3545
|
|
| 33 | 33 | #include <netinet/in.h> |
| 34 | 34 | |
| | 35 | #ifdef USE_SASL2 |
| | 36 | static int getnameinfo_err(int ret) |
| | 37 | { |
| | 38 | int err; |
| | 39 | dprint (1, (debugfile, "getnameinfo: ")); |
| | 40 | switch(ret) |
| | 41 | { |
| | 42 | case EAI_AGAIN: |
| | 43 | dprint (1, (debugfile, "The name could not be resolved at this time. Future attempts may succeed.\n")); |
| | 44 | err=SASL_TRYAGAIN; |
| | 45 | break; |
| | 46 | case EAI_BADFLAGS: |
| | 47 | dprint (1, (debugfile, "The flags had an invalid value.\n")); |
| | 48 | err=SASL_BADPARAM; |
| | 49 | break; |
| | 50 | case EAI_FAIL: |
| | 51 | dprint (1, (debugfile, "A non-recoverable error occurred.\n")); |
| | 52 | err=SASL_FAIL; |
| | 53 | break; |
| | 54 | case EAI_FAMILY: |
| | 55 | dprint (1, (debugfile, "The address family was not recognized or the address length was invalid for the specified family.\n")); |
| | 56 | err=SASL_BADPROT; |
| | 57 | break; |
| | 58 | case EAI_MEMORY: |
| | 59 | dprint (1, (debugfile, "There was a memory allocation failure.\n")); |
| | 60 | err=SASL_NOMEM; |
| | 61 | break; |
| | 62 | case EAI_NONAME: |
| | 63 | dprint (1, (debugfile, "The name does not resolve for the supplied parameters. NI_NAMEREQD is set and the host's name cannot be located, or both nodename and servname were null.\n")); |
| | 64 | err=SASL_FAIL; /* no real equivalent */ |
| | 65 | break; |
| | 66 | case EAI_SYSTEM: |
| | 67 | dprint (1, (debugfile, "A system error occurred. The error code can be found in errno(%d,%s)).\n",errno,strerror(errno))); |
| | 68 | err=SASL_FAIL; /* no real equivalent */ |
| | 69 | break; |
| | 70 | default: |
| | 71 | dprint (1, (debugfile, "Unknown error %d\n",ret)); |
| | 72 | err=SASL_FAIL; /* no real equivalent */ |
| | 73 | break; |
| | 74 | } |
| | 75 | return err; |
| | 76 | } |
| | 77 | #endif |
| | 78 | |
| 35 | 79 | /* arbitrary. SASL will probably use a smaller buffer anyway. OTOH it's |
| 36 | 80 | * been a while since I've had access to an SASL server which negotiated |
| … |
… |
|
| 65 | 109 | char *out, unsigned outlen) { |
| 66 | 110 | char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; |
| | 111 | int ret; |
| 67 | 112 | |
| 68 | 113 | if(!addr || !out) return SASL_BADPARAM; |
| 69 | 114 | |
| 70 | | getnameinfo(addr, addrlen, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), |
| 71 | | NI_NUMERICHOST | |
| | 115 | ret=getnameinfo(addr, addrlen, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), |
| | 116 | NI_NUMERICHOST | |
| 72 | 117 | #ifdef NI_WITHSCOPEID |
| 73 | | NI_WITHSCOPEID | |
| 74 | | #endif |
| 75 | | NI_NUMERICSERV); |
| | 118 | NI_WITHSCOPEID | |
| | 119 | #endif |
| | 120 | NI_NUMERICSERV); |
| | 121 | if(ret) |
| | 122 | return getnameinfo_err(ret); |
| 76 | 123 | |
| 77 | 124 | if(outlen < strlen(hbuf) + strlen(pbuf) + 2) |
| … |
… |
|
| 125 | 172 | sasl_security_properties_t secprops; |
| 126 | 173 | #ifdef USE_SASL2 |
| 127 | | struct sockaddr local, remote; |
| | 174 | struct sockaddr_storage local, remote; |
| 128 | 175 | socklen_t size; |
| 129 | 176 | char iplocalport[IP_PORT_BUFLEN], ipremoteport[IP_PORT_BUFLEN]; |
| … |
… |
|
| 152 | 199 | #ifdef USE_SASL2 |
| 153 | 200 | size = sizeof (local); |
| 154 | | if (getsockname (conn->fd, &local, &size)){ |
| | 201 | if (getsockname (conn->fd, (struct sockaddr *)&local, &size)){ |
| 155 | 202 | dprint (1, (debugfile, "mutt_sasl_client_new: getsockname for local failed\n")); |
| 156 | 203 | return -1; |
| 157 | 204 | } |
| 158 | 205 | else |
| 159 | | if (iptostring(&local, size, iplocalport, IP_PORT_BUFLEN) != SASL_OK){ |
| | 206 | if (iptostring((struct sockaddr *)&local, local.ss_len, iplocalport, IP_PORT_BUFLEN) != SASL_OK){ |
| 160 | 207 | dprint (1, (debugfile, "mutt_sasl_client_new: iptostring for local failed\n")); |
| 161 | 208 | return -1; |
| … |
… |
|
| 163 | 210 | |
| 164 | 211 | size = sizeof (remote); |
| 165 | | if (getpeername (conn->fd, &remote, &size)){ |
| | 212 | if (getpeername (conn->fd, (struct sockaddr *)&remote, &size)){ |
| 166 | 213 | dprint (1, (debugfile, "mutt_sasl_client_new: getsockname for remote failed\n")); |
| 167 | 214 | return -1; |
| 168 | 215 | } |
| 169 | 216 | else |
| 170 | | if (iptostring(&remote, size, ipremoteport, IP_PORT_BUFLEN) != SASL_OK){ |
| | 217 | if (iptostring((struct sockaddr *)&remote, remote.ss_len, ipremoteport, IP_PORT_BUFLEN) != SASL_OK){ |
| 171 | 218 | dprint (1, (debugfile, "mutt_sasl_client_new: iptostring for remote failed\n")); |
| 172 | 219 | return -1; |