]> git.pld-linux.org Git - packages/cyrus-sasl.git/blob - cyrus-sasl-ipv6.patch
IPv6 support for SASL
[packages/cyrus-sasl.git] / cyrus-sasl-ipv6.patch
1 diff -ruN --exclude *.wiget cyrus-sasl-1.5.27.noipv6/acconfig.h cyrus-sasl-1.5.27/acconfig.h
2 --- cyrus-sasl-1.5.27.noipv6/acconfig.h Thu Apr 26 16:20:50 2001
3 +++ cyrus-sasl-1.5.27/acconfig.h        Thu Apr 26 16:21:12 2001
4 @@ -137,8 +137,20 @@
5  /* define if your system has getpid() */
6  #undef HAVE_GETPID
7  
8 +/* define if your system has struct sockaddr_storage */
9 +#undef HAVE_SOCKADDR_STORAGE
10 +
11  @BOTTOM@
12  
13 +/* define if your system has getnameinfo() */
14 +#undef HAVE_GETNAMEINFO
15 +
16 +/* Define if you have ss_family in struct sockaddr_storage. */
17 +#undef HAVE_SS_FAMILY
18 +
19 +/* do we have socklen_t? */
20 +#undef HAVE_SOCKLEN_T
21 +
22  /* location of the random number generator */
23  #ifndef DEV_RANDOM
24  #define DEV_RANDOM "/dev/random"
25 @@ -181,6 +193,22 @@
26  #endif /* WIN32 */
27  #include <string.h>
28  
29 +#if defined(HAVE_SOCKADDR_STORAGE) && defined(HAVE_GETNAMEINFO)
30 +#define INET6
31 +#endif
32 +#ifdef INET6
33 +#include <sys/socket.h>
34 +#ifndef NI_WITHSCOPEID
35 +#define NI_WITHSCOPEID 0
36 +#endif
37 +#ifndef HAVE_SS_FAMILY
38 +#define ss_family      __ss_family
39 +#endif
40 +#endif
41  #include <netinet/in.h>
42 +
43 +#ifndef HAVE_SOCKLEN_T
44 +typedef int socklen_t;
45 +#endif
46  
47  #endif /* CONFIG_H */
48 diff -ruN --exclude *.wiget cyrus-sasl-1.5.27.noipv6/aclocal.m4 cyrus-sasl-1.5.27/aclocal.m4
49 --- cyrus-sasl-1.5.27.noipv6/aclocal.m4 Sat Mar 24 02:48:12 2001
50 +++ cyrus-sasl-1.5.27/aclocal.m4        Thu Apr 26 16:21:12 2001
51 @@ -692,3 +692,72 @@
52         AC_SUBST(LIB_SOCKET)
53         ])
54  
55 +dnl See whether we can use IPv6 related functions
56 +AC_DEFUN(IPv6_CHECK_FUNC, [
57 +changequote(, )dnl
58 +ac_tr_lib=HAVE_`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
59 +  -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
60 +changequote([, ])dnl
61 +AC_CHECK_FUNC($1, [dnl
62 +  AC_DEFINE_UNQUOTED($ac_tr_lib)
63 +  ac_cv_lib_socket_$1=no
64 +  ac_cv_lib_inet6_$1=no
65 +], [dnl
66 +  AC_CHECK_LIB(socket, $1, [dnl
67 +    AC_DEFINE_UNQUOTED($ac_tr_lib)
68 +    LIBS="$LIBS -lsocket"
69 +    ac_cv_lib_inet6_$1=no
70 +  ], [dnl
71 +    AC_MSG_CHECKING([whether your system has IPv6 directory])
72 +    AC_CACHE_VAL(ipv6_cv_dir, [dnl
73 +      for ipv6_cv_dir in /usr/local/v6 /usr/inet6 no; do
74 +       if test $ipv6_cv_dir = no -o -d $ipv6_cv_dir; then
75 +         break
76 +       fi
77 +      done])dnl
78 +    AC_MSG_RESULT($ipv6_cv_dir)
79 +    if test $ipv6_cv_dir = no; then
80 +      ac_cv_lib_inet6_$1=no
81 +    else
82 +      if test x$ipv6_libinet6 = x; then
83 +       ipv6_libinet6=no
84 +       SAVELDFLAGS="$LDFLAGS"
85 +       LDFLAGS="$LDFLAGS -L$ipv6_cv_dir/lib"
86 +      fi
87 +      AC_CHECK_LIB(inet6, $1, [dnl
88 +       AC_DEFINE_UNQUOTED($ac_tr_lib)
89 +       if test $ipv6_libinet6 = no; then
90 +         ipv6_libinet6=yes
91 +         LIBS="$LIBS -linet6"
92 +       fi],)dnl
93 +      if test $ipv6_libinet6 = no; then
94 +       LDFLAGS="$SAVELDFLAGS"
95 +      fi
96 +    fi])dnl
97 +])dnl
98 +if test $ac_cv_func_$1 = yes -o $ac_cv_lib_socket_$1 = yes \
99 +     -o $ac_cv_lib_inet6_$1 = yes
100 +then
101 +  ipv6_cv_$1=yes
102 +  ifelse([$2], , :, [$2])
103 +else
104 +  ipv6_cv_$1=no
105 +  ifelse([$3], , :, [$3])
106 +fi])
107 +
108 +
109 +dnl See whether we have ss_family in sockaddr_storage
110 +AC_DEFUN(IPv6_CHECK_SS_FAMILY, [
111 +AC_MSG_CHECKING([whether you have ss_family in struct sockaddr_storage])
112 +AC_CACHE_VAL(ipv6_cv_ss_family, [dnl
113 +AC_TRY_COMPILE([#include <sys/types.h>
114 +#include <sys/socket.h>],
115 +       [struct sockaddr_storage ss; int i = ss.ss_family;],
116 +       [ipv6_cv_ss_family=yes], [ipv6_cv_ss_family=no])])dnl
117 +if test $ipv6_cv_ss_family = yes; then
118 +  ifelse([$1], , AC_DEFINE(HAVE_SS_FAMILY), [$1])
119 +else
120 +  ifelse([$2], , :, [$2])
121 +fi
122 +AC_MSG_RESULT($ipv6_cv_ss_family)])
123 +
124 diff -ruN --exclude *.wiget cyrus-sasl-1.5.27.noipv6/cmulocal/ipv6.m4 cyrus-sasl-1.5.27/cmulocal/ipv6.m4
125 --- cyrus-sasl-1.5.27.noipv6/cmulocal/ipv6.m4   Thu Jan  1 01:00:00 1970
126 +++ cyrus-sasl-1.5.27/cmulocal/ipv6.m4  Thu Apr 26 16:21:12 2001
127 @@ -0,0 +1,68 @@
128 +dnl See whether we can use IPv6 related functions
129 +AC_DEFUN(IPv6_CHECK_FUNC, [
130 +changequote(, )dnl
131 +ac_tr_lib=HAVE_`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
132 +  -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
133 +changequote([, ])dnl
134 +AC_CHECK_FUNC($1, [dnl
135 +  AC_DEFINE_UNQUOTED($ac_tr_lib)
136 +  ac_cv_lib_socket_$1=no
137 +  ac_cv_lib_inet6_$1=no
138 +], [dnl
139 +  AC_CHECK_LIB(socket, $1, [dnl
140 +    AC_DEFINE_UNQUOTED($ac_tr_lib)
141 +    LIBS="$LIBS -lsocket"
142 +    ac_cv_lib_inet6_$1=no
143 +  ], [dnl
144 +    AC_MSG_CHECKING([whether your system has IPv6 directory])
145 +    AC_CACHE_VAL(ipv6_cv_dir, [dnl
146 +      for ipv6_cv_dir in /usr/local/v6 /usr/inet6 no; do
147 +       if test $ipv6_cv_dir = no -o -d $ipv6_cv_dir; then
148 +         break
149 +       fi
150 +      done])dnl
151 +    AC_MSG_RESULT($ipv6_cv_dir)
152 +    if test $ipv6_cv_dir = no; then
153 +      ac_cv_lib_inet6_$1=no
154 +    else
155 +      if test x$ipv6_libinet6 = x; then
156 +       ipv6_libinet6=no
157 +       SAVELDFLAGS="$LDFLAGS"
158 +       LDFLAGS="$LDFLAGS -L$ipv6_cv_dir/lib"
159 +      fi
160 +      AC_CHECK_LIB(inet6, $1, [dnl
161 +       AC_DEFINE_UNQUOTED($ac_tr_lib)
162 +       if test $ipv6_libinet6 = no; then
163 +         ipv6_libinet6=yes
164 +         LIBS="$LIBS -linet6"
165 +       fi],)dnl
166 +      if test $ipv6_libinet6 = no; then
167 +       LDFLAGS="$SAVELDFLAGS"
168 +      fi
169 +    fi])dnl
170 +])dnl
171 +if test $ac_cv_func_$1 = yes -o $ac_cv_lib_socket_$1 = yes \
172 +     -o $ac_cv_lib_inet6_$1 = yes
173 +then
174 +  ipv6_cv_$1=yes
175 +  ifelse([$2], , :, [$2])
176 +else
177 +  ipv6_cv_$1=no
178 +  ifelse([$3], , :, [$3])
179 +fi])
180 +
181 +
182 +dnl See whether we have ss_family in sockaddr_storage
183 +AC_DEFUN(IPv6_CHECK_SS_FAMILY, [
184 +AC_MSG_CHECKING([whether you have ss_family in struct sockaddr_storage])
185 +AC_CACHE_VAL(ipv6_cv_ss_family, [dnl
186 +AC_TRY_COMPILE([#include <sys/types.h>
187 +#include <sys/socket.h>],
188 +       [struct sockaddr_storage ss; int i = ss.ss_family;],
189 +       [ipv6_cv_ss_family=yes], [ipv6_cv_ss_family=no])])dnl
190 +if test $ipv6_cv_ss_family = yes; then
191 +  ifelse([$1], , AC_DEFINE(HAVE_SS_FAMILY), [$1])
192 +else
193 +  ifelse([$2], , :, [$2])
194 +fi
195 +AC_MSG_RESULT($ipv6_cv_ss_family)])
196 diff -ruN --exclude *.wiget cyrus-sasl-1.5.27.noipv6/config.h.in cyrus-sasl-1.5.27/config.h.in
197 --- cyrus-sasl-1.5.27.noipv6/config.h.in        Wed Mar 14 05:49:33 2001
198 +++ cyrus-sasl-1.5.27/config.h.in       Thu Apr 26 16:21:12 2001
199 @@ -119,6 +119,9 @@
200  /* do we have a preferred mechanism, or should we just pick the highest ssf? */
201  #undef PREFER_MECH
202  
203 +/* define if your system has struct sockaddr_storage */
204 +#undef HAVE_SOCKADDR_STORAGE
205 +
206  /* Define if you have the getdomainname function.  */
207  #undef HAVE_GETDOMAINNAME
208  
209 @@ -198,6 +201,15 @@
210  #undef HAVE___ATTRIBUTE__
211  
212  
213 +/* define if your system has getnameinfo() */
214 +#undef HAVE_GETNAMEINFO
215 +
216 +/* Define if you have ss_family in struct sockaddr_storage. */
217 +#undef HAVE_SS_FAMILY
218 +
219 +/* do we have socklen_t? */
220 +#undef HAVE_SOCKLEN_T
221 +
222  /* location of the random number generator */
223  #ifndef DEV_RANDOM
224  #define DEV_RANDOM "/dev/random"
225 @@ -239,6 +251,22 @@
226  #endif /* WIN32 */
227  #include <string.h>
228  
229 +#if defined(HAVE_SOCKADDR_STORAGE) && defined(HAVE_GETNAMEINFO)
230 +#define INET6
231 +#endif
232 +#ifdef INET6
233 +#include <sys/socket.h>
234 +#ifndef NI_WITHSCOPEID
235 +#define NI_WITHSCOPEID 0
236 +#endif
237 +#ifndef HAVE_SS_FAMILY
238 +#define ss_family      __ss_family
239 +#endif
240 +#endif
241  #include <netinet/in.h>
242 +
243 +#ifndef HAVE_SOCKLEN_T
244 +typedef int socklen_t;
245 +#endif
246  
247  #endif /* CONFIG_H */
248 diff -ruN --exclude *.wiget cyrus-sasl-1.5.27.noipv6/configure.in cyrus-sasl-1.5.27/configure.in
249 --- cyrus-sasl-1.5.27.noipv6/configure.in       Thu Apr 26 16:20:50 2001
250 +++ cyrus-sasl-1.5.27/configure.in      Thu Apr 26 16:21:12 2001
251 @@ -782,6 +782,19 @@
252      AC_DEFINE_UNQUOTED(PREFER_MECH, "KERBEROS_V4")
253  fi
254  
255 +AC_ARG_ENABLE(ipv6, [ --disable-ipv6           Don't compile in IPv6 support],
256 +              ipv6="$enableval", ipv6="yes")
257 +if test "$ipv6" != "yes"; then
258 +    AC_MSG_RESULT(IPv6 support is disabled)
259 +else
260 +    IPv6_CHECK_FUNC(getnameinfo)
261 +    AC_EGREP_HEADER(sockaddr_storage, sys/socket.h,
262 +                   AC_DEFINE(HAVE_SOCKADDR_STORAGE))
263 +    IPv6_CHECK_SS_FAMILY()
264 +fi
265 +
266 +AC_EGREP_HEADER(socklen_t, sys/socket.h, AC_DEFINE(HAVE_SOCKLEN_T))
267 +
268  AC_SUBST(DIRS)
269  
270  AC_OUTPUT(Makefile
271 diff -ruN --exclude *.wiget cyrus-sasl-1.5.27.noipv6/lib/checkpw.c cyrus-sasl-1.5.27/lib/checkpw.c
272 --- cyrus-sasl-1.5.27.noipv6/lib/checkpw.c      Thu Apr 26 16:20:50 2001
273 +++ cyrus-sasl-1.5.27/lib/checkpw.c     Thu Apr 26 16:23:39 2001
274 @@ -571,7 +571,12 @@
275                                   const char **reply)
276  {
277    char *host;
278 +#ifdef INET6
279 +  struct sockaddr *addr;
280 +  socklen_t salen;
281 +#else
282    struct sockaddr_in *addr;
283 +#endif
284    char *argv[2], *argv0 = "SASL";
285    SIAENTITY *ent;
286    int ret;
287 @@ -586,8 +591,21 @@
288    /* Get the remote host */
289    if (sasl_getprop(conn, SASL_IP_REMOTE, (void **) &addr) != SASL_OK)
290        host = NULL;
291 -  else
292 +  else {
293 +#ifdef INET6
294 +#ifdef SIN6_LEN
295 +      salen = addr->sa_len;
296 +#else
297 +      salen = (addr->sa_family == AF_INET) ? sizeof(struct sockaddr_in)
298 +                                          : sizeof(struct sockaddr_in6);
299 +#endif
300 +      getnameinfo(addr, salen, hbuf, sizeof(hbuf), NULL, 0,
301 +                 NI_NUMERICHOST | NI_WITHSCOPEID);
302 +      host = hbuf;
303 +#else
304        host = inet_ntoa(*addr);
305 +#endif
306 +  }
307  
308    /* Try to validate */
309    if (sia_ses_init (&ent, 1, argv, host, userid, NULL, 0, NULL) != SIASUCCESS)
310 diff -ruN --exclude *.wiget cyrus-sasl-1.5.27.noipv6/lib/common.c cyrus-sasl-1.5.27/lib/common.c
311 --- cyrus-sasl-1.5.27.noipv6/lib/common.c       Thu Apr 26 16:20:49 2001
312 +++ cyrus-sasl-1.5.27/lib/common.c      Thu Apr 26 16:21:12 2001
313 @@ -359,13 +359,21 @@
314        if (! conn->got_ip_local)
315         result = SASL_NOTDONE;
316        else
317 +#ifdef INET6
318 +       *(struct sockaddr **)pvalue = (struct sockaddr *)&conn->ip_local;
319 +#else
320         *(struct sockaddr_in **)pvalue = &conn->ip_local;
321 +#endif
322        break;
323      case SASL_IP_REMOTE:
324        if (! conn->got_ip_remote)
325         result = SASL_NOTDONE;
326        else
327 +#ifdef INET6
328 +       *(struct sockaddr **)pvalue = (struct sockaddr *)&conn->ip_remote;
329 +#else
330         *(struct sockaddr_in **)pvalue = &conn->ip_remote;
331 +#endif
332        break;
333      default: 
334        result = SASL_BADPARAM;
335 @@ -382,6 +390,10 @@
336  {
337    int result = SASL_OK;
338    char *str;
339 +#ifdef INET6
340 +  int family;
341 +  socklen_t salen;
342 +#endif
343  
344    /* make sure the sasl context is valid */
345    if (!conn)
346 @@ -413,12 +425,40 @@
347              sizeof(sasl_security_properties_t));
348        break;
349      case SASL_IP_LOCAL:
350 -      conn->got_ip_local = 1;
351 +#ifdef INET6
352 +      /* XXX: Yes, this is ugly.  But, there is such code, eg. testsuite.c */
353 +      family = ((struct sockaddr *)value)->sa_family;
354 +      if (family!= AF_INET && family != AF_INET6)
355 +       family = AF_INET;
356 +      salen = (family == AF_INET) ? sizeof(struct sockaddr_in)
357 +                                 : sizeof(struct sockaddr_in6);
358 +      memcpy(&conn->ip_local, value, salen);
359 +      conn->ip_local.ss_family = family;
360 +#ifdef SIN6_LEN
361 +      conn->ip_local.ss_len = salen;
362 +#endif
363 +#else
364        conn->ip_local= *(struct sockaddr_in *) value;
365 +#endif
366 +      conn->got_ip_local = 1;
367        break;
368      case SASL_IP_REMOTE:
369 -      conn->got_ip_remote = 1;
370 +#ifdef INET6
371 +      /* XXX: Yes, this is ugly.  But, there is such code, eg. testsuite.c */
372 +      family = ((struct sockaddr *)value)->sa_family;
373 +      if (family!= AF_INET && family != AF_INET6)
374 +       family = AF_INET;
375 +      salen = (family == AF_INET) ? sizeof(struct sockaddr_in)
376 +                                 : sizeof(struct sockaddr_in6);
377 +      memcpy(&conn->ip_remote, value, salen);
378 +      conn->ip_remote.ss_family = family;
379 +#ifdef SIN6_LEN
380 +      conn->ip_remote.ss_len = salen;
381 +#endif
382 +#else
383        conn->ip_remote= *(struct sockaddr_in *) value;
384 +#endif
385 +      conn->got_ip_remote = 1;
386        break;
387      default:
388        result = SASL_BADPARAM;
389 diff -ruN --exclude *.wiget cyrus-sasl-1.5.27.noipv6/lib/saslint.h cyrus-sasl-1.5.27/lib/saslint.h
390 --- cyrus-sasl-1.5.27.noipv6/lib/saslint.h      Thu Apr 26 16:20:49 2001
391 +++ cyrus-sasl-1.5.27/lib/saslint.h     Thu Apr 26 16:21:12 2001
392 @@ -95,7 +95,11 @@
393  
394    int secflags;  /* security layer flags passed to sasl_*_new */
395    int got_ip_local, got_ip_remote;
396 +#ifdef INET6
397 +  struct sockaddr_storage ip_local, ip_remote;
398 +#else
399    struct sockaddr_in ip_local, ip_remote;
400 +#endif
401    sasl_external_properties_t external;
402  
403    void *context;
404 diff -ruN --exclude *.wiget cyrus-sasl-1.5.27.noipv6/plugins/anonymous.c cyrus-sasl-1.5.27/plugins/anonymous.c
405 --- cyrus-sasl-1.5.27.noipv6/plugins/anonymous.c        Sat Mar 10 06:56:44 2001
406 +++ cyrus-sasl-1.5.27/plugins/anonymous.c       Thu Apr 26 16:21:12 2001
407 @@ -101,7 +101,11 @@
408                const char **errstr)
409  {
410    int result;
411 +#ifdef INET6
412 +  struct sockaddr *remote_addr;   
413 +#else
414    struct sockaddr_in *remote_addr;   
415 +#endif
416    char *clientdata;
417  
418    if (!sparams
419 @@ -133,6 +137,23 @@
420                                    SASL_IP_REMOTE, (void **)&remote_addr);
421  
422    if (result==SASL_OK) {
423 +#ifdef INET6
424 +    socklen_t salen;
425 +    char hbuf[NI_MAXHOST];
426 +
427 +#ifdef SIN6_LEN
428 +    salen = remote_addr->sa_len;
429 +#else
430 +    salen = (remote_addr->sa_family == AF_INET)
431 +       ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6);
432 +#endif
433 +    getnameinfo(remote_addr, salen, hbuf, sizeof(hbuf), NULL, 0,
434 +               NI_NUMERICHOST | NI_WITHSCOPEID);
435 +    sparams->utils->log(sparams->utils->conn,
436 +                       SASL_LOG_INFO,
437 +                       "ANONYMOUS", 0, 0,
438 +                       "login: \"%s\" from [%s]", clientdata, hbuf);
439 +#else
440      int ipnum = remote_addr->sin_addr.s_addr;
441  
442      sparams->utils->log(sparams->utils->conn,
443 @@ -144,6 +165,7 @@
444                         ipnum >> 16 & 0xFF,
445                         ipnum >> 8 &0xFF,
446                         ipnum & 0xFF);
447 +#endif
448    } else {
449      sparams->utils->log(sparams->utils->conn,
450                         SASL_LOG_INFO,
451 diff -ruN --exclude *.wiget cyrus-sasl-1.5.27.noipv6/plugins/kerberos4.c cyrus-sasl-1.5.27/plugins/kerberos4.c
452 --- cyrus-sasl-1.5.27.noipv6/plugins/kerberos4.c        Thu Apr 26 16:20:50 2001
453 +++ cyrus-sasl-1.5.27/plugins/kerberos4.c       Thu Apr 26 16:21:12 2001
454 @@ -131,10 +131,17 @@
455    des_key_schedule dec_keysched;   /* decryption key schedule */
456  
457  
458 +#ifdef INET6
459 +  struct sockaddr *ip_local;        /* local ip address and port.
460 +                                      needed for layers */
461 +  struct sockaddr *ip_remote;       /* remote ip address and port.
462 +                                      needed for layers */
463 +#else
464    struct sockaddr_in *ip_local;     /* local ip address and port.
465                                        needed for layers */
466    struct sockaddr_in *ip_remote;    /* remote ip address and port.
467                                        needed for layers */
468 +#endif
469  
470    sasl_malloc_t *malloc;           /* encode and decode need these */
471    sasl_realloc_t *realloc;       
472 @@ -580,7 +587,11 @@
473      AUTH_DAT ad;
474      KTEXT_ST ticket;
475      int lup;
476 +#ifdef INET6
477 +    struct sockaddr *addr;
478 +#else
479      struct sockaddr_in *addr;
480 +#endif
481  
482      VL(("KERBEROS_V4 Step 2\n"));
483  
484 @@ -619,9 +630,17 @@
485         return SASL_BADAUTH;
486      }
487  #endif
488 +#ifdef INET6
489 +    if (addr->sa_family != AF_INET) {
490 +       if (errstr)
491 +           *errstr = "unsupported address family";
492 +       return SASL_BADAUTH;
493 +    }
494 +#endif
495      /* check ticket */
496      result = krb_rd_req(&ticket, (char *) sparams->service, text->instance, 
497 -                       addr ? addr->sin_addr.s_addr : 0L, &ad, srvtab);
498 +                       addr ? ((struct sockaddr_in *)addr)->sin_addr.s_addr
499 +                            : 0L, &ad, srvtab);
500  
501      if (result) { /* if fails mechanism fails */
502         VL(("krb_rd_req failed service=%s instance=%s error code=%i\n",
This page took 0.125576 seconds and 4 git commands to generate.