geneweb / geneweb

GeneWeb is a free (as in free speech) genealogy software with a web interface created by Daniel de Rauglaudre.
GNU General Public License v2.0
311 stars 93 forks source link

[BUG] gwd does not start when ipv6 is not supported #1949

Open cyrilst opened 6 days ago

cyrilst commented 6 days ago

Describe the bug / Description du bogue

I run gwd (latest commit on git) on FreeBSD without problem. I try to run gwd inside a jail (=container) on the same FreeBSD system.

I get this error when starting gwd inside the jail: CRITICAL Unix.Unix_error(Unix.EPROTONOSUPPORT, "socket", "")

Using truss (=strace), I see this: socket(PF_INET6,SOCK_STREAM,0) ERR#43 'Protocol not supported'

And indeed, there is no ipv6 support on this jail.

I tried using the -a some.ip.v4 option, the bug is still present.

I reverted part of the commit enabling ipv6, and I could start gwd:

$ git diff
diff --git a/bin/setup/setup.ml b/bin/setup/setup.ml
index e7bb6ec16..9364f4ca9 100644
--- a/bin/setup/setup.ml
+++ b/bin/setup/setup.ml
@@ -1797,7 +1797,7 @@ let string_of_sockaddr = function
     else str

 let only_addr () =
-  let local_addr = Unix.string_of_inet_addr Unix.inet6_addr_loopback in
+  let local_addr = Unix.string_of_inet_addr Unix.inet_addr_loopback in
   let fname = Lazy.force only_file_name in
   match try Some (open_in fname) with Sys_error _ -> None with
     Some ic ->
diff --git a/lib/wserver/wserver.ml b/lib/wserver/wserver.ml
index cba85125e..239df0687 100644
--- a/lib/wserver/wserver.ml
+++ b/lib/wserver/wserver.ml
@@ -366,13 +366,12 @@ let f syslog addr_opt port tmout max_clients g =
       check_stopping ();
       let addr =
         match addr_opt with
-        | None -> Unix.inet6_addr_any
+        | None -> Unix.inet_addr_any
         | Some addr -> (
             try Unix.inet_addr_of_string addr
             with Failure _ -> (Unix.gethostbyname addr).Unix.h_addr_list.(0))
       in
-      let s = Unix.socket Unix.PF_INET6 Unix.SOCK_STREAM 0 in
-      Unix.setsockopt s Unix.IPV6_ONLY false;
+      let s = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in
       Unix.setsockopt s Unix.SO_REUSEADDR true;
       Unix.bind s (Unix.ADDR_INET (addr, port));
       Unix.listen s 4;

Expected behavior / Comportement attendu

gwd should not block if there is no ipv6 support. Even less if the -a option is present with an ipv4 set.

I guess there should be a way to make gwd work on ipv4 only systems, and also on ipv6 systems, and of course on ipv4+ipv6 systems.

Versions

FreeBSD 14.1 Latest commit of this git (master branch)

hgouraud commented 6 days ago

Can you propose à PR with the ipv6/4 support you are expecting?

cyrilst commented 6 days ago

I'd love to, but honestly, I don't think I can do this. I don't know ocaml at all… I can test any proposed changed though.