Merge remote-tracking branch 'origin/erp5scalabilitytestbed'
[slapos.git] / component / dropbear / ipv6-support.patch
1 @@ -0,0 +1,56 @@
2 --- dropbear-0.52.orig/svr-runopts.c    Wed May 13 20:56:03 2009
3 +++ dropbear-0.52/svr-runopts.c Wed May 13 22:20:22 2009
4 @@ -311,27 +311,39 @@
5  static void addportandaddress(char* spec) {
6  
7         char *myspec = NULL;
8 +       char *p = NULL;
9  
10         if (svr_opts.portcount < DROPBEAR_MAX_PORTS) {
11  
12                 /* We don't free it, it becomes part of the runopt state */
13                 myspec = m_strdup(spec);
14  
15 -               /* search for ':', that separates address and port */
16 -               svr_opts.ports[svr_opts.portcount] = strchr(myspec, ':');
17 -
18 -               if (svr_opts.ports[svr_opts.portcount] == NULL) {
19 -                       /* no ':' -> the whole string specifies just a port */
20 -                       svr_opts.ports[svr_opts.portcount] = myspec;
21 -               } else {
22 -                       /* Split the address/port */
23 -                       svr_opts.ports[svr_opts.portcount][0] = '\0'; 
24 -                       svr_opts.ports[svr_opts.portcount]++;
25 +               /* [ipv6]:port */
26 +               if (myspec[0] == '[' && (p = strchr(myspec, ']')) != NULL && *(p+1) == ':') {
27 +                       *p = '\0';
28 +                       p+=2;
29 +                       myspec++;
30 +                       svr_opts.ports[svr_opts.portcount] = p;
31                         svr_opts.addresses[svr_opts.portcount] = myspec;
32 -               }
33 -
34 -               if (svr_opts.addresses[svr_opts.portcount] == NULL) {
35 -                       /* no address given -> fill in the default address */
36 +               } else if ((p = strchr(myspec, '.')) != NULL) {
37 +                       if ((p = strchr(p, ':')) == NULL) {
38 +                               /* ipv4 */
39 +                               svr_opts.ports[svr_opts.portcount] = m_strdup(DROPBEAR_DEFPORT);
40 +                               svr_opts.addresses[svr_opts.portcount] = myspec;
41 +                       } else {
42 +                               /* ipv4:port */
43 +                               *p = '\0';
44 +                               p++;
45 +                               svr_opts.ports[svr_opts.portcount] = p;
46 +                               svr_opts.addresses[svr_opts.portcount] = myspec;
47 +                       }
48 +               } else if ((p = strchr(myspec, ':')) != NULL && (p = strchr(p, ':')) != NULL) {
49 +                       /* ipv6 */
50 +                       svr_opts.ports[svr_opts.portcount] = m_strdup(DROPBEAR_DEFPORT);
51 +                       svr_opts.addresses[svr_opts.portcount] = myspec;
52 +               } else {
53 +                       /* port */
54 +                       svr_opts.ports[svr_opts.portcount] = myspec;
55                         svr_opts.addresses[svr_opts.portcount] = m_strdup(DROPBEAR_DEFADDRESS);
56                 }
57