[PATCH] Add option to svnserve to disable ipv6

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Add option to svnserve to disable ipv6

Jim Morris
* subversion/svnserve/main.c
   (main): Add --noipv6 option, and if set do not bind to an ipv6 port

On at least one system I am using (OpenBSD) the 1.2.0 version of
svnserve detects there is an ipv6 network, and binds to that network
ONLY. So there is no listening port setup on ipv4, so no ipv4 clients
can connect.

As I do not use ipv6 I added an option --noipv6 which will force it to
bind to the ipv4 network as previous versions did.

Others with both ipv6 and ipv4 on their systems may encounter similar
problems as I do not think this is specific to OpenBSD.

Ideally the fix should actually allow it to bind to both ipv6 and ipv4
networks, however that fix is beyond me at the moment.


Index: main.c
===================================================================
--- main.c (revision 14826)
+++ main.c (working copy)
@@ -96,7 +96,9 @@
 #define SVNSERVE_OPT_FOREGROUND  258
 #define SVNSERVE_OPT_TUNNEL_USER 259
 #define SVNSERVE_OPT_VERSION     260
+#define SVNSERVE_OPT_NOIPV6 261
 
+
 static const apr_getopt_option_t svnserve__options[] =
   {
     {"daemon",           'd', 0, N_("daemon mode")},
@@ -119,7 +121,10 @@
     {"threads",          'T', 0, N_("use threads instead of fork")},
 #endif
     {"listen-once",      'X', 0, N_("listen once (useful for debugging)")},
-    {0,                  0,   0, 0}
+#if APR_HAVE_IPV6
+ {"noipv6", SVNSERVE_OPT_NOIPV6, 0, N_("disable ipv6")},
+#endif
+ {0,                  0,   0, 0}
   };
 
 
@@ -257,7 +262,8 @@
   const char *host = NULL;
   int family = APR_INET;
   int mode_opt_count = 0;
-
+  int useipv6= 1;
+  
   /* Initialize the app. */
   if (svn_cmdline_init("svn", stderr) != EXIT_SUCCESS)
     return EXIT_FAILURE;
@@ -368,7 +374,12 @@
         case 'T':
           handling_mode = connection_mode_thread;
           break;
-        }
+#if APR_HAVE_IPV6
+ case SVNSERVE_OPT_NOIPV6:
+ useipv6= 0;
+ break;
+#endif
+  }
     }
   if (os->ind != argc)
     usage(argv[0], pool);
@@ -407,18 +418,21 @@
      create IPV6 sockets. */  
 
 #if APR_HAVE_IPV6
+  if(useipv6 != 0)
+    {
 #ifdef MAX_SECS_TO_LINGER
   /* ### old APR interface */
-  status = apr_socket_create(&sock, APR_INET6, SOCK_STREAM, pool);
+     status = apr_socket_create(&sock, APR_INET6, SOCK_STREAM, pool);
 #else
-  status = apr_socket_create(&sock, APR_INET6, SOCK_STREAM, APR_PROTO_TCP,
-                             pool);
+     status = apr_socket_create(&sock, APR_INET6, SOCK_STREAM, APR_PROTO_TCP,
+                                pool);
 #endif
-  if (status == 0)  
-    {
-      apr_socket_close(sock);
-      family = APR_UNSPEC;
-    }
+     if (status == 0)  
+  {
+       apr_socket_close(sock);
+       family = APR_UNSPEC;
+  }
+ }
 #endif
   
   status = apr_sockaddr_info_get(&sa, host, family, port, 0, pool);


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]