diff --git a/bind-to-local-hostname.patch b/bind-to-local-hostname.patch new file mode 100644 index 0000000..39ffe34 --- /dev/null +++ b/bind-to-local-hostname.patch @@ -0,0 +1,38 @@ +Index: csync2-1.34/conn.c +=================================================================== +--- csync2-1.34.orig/conn.c ++++ csync2-1.34/conn.c +@@ -50,7 +50,9 @@ SSL *conn_ssl; + int conn_open(const char *peername) + { + struct sockaddr_in sin; ++ struct sockaddr_in sme; + struct hostent *hp; ++ struct hostent *me; + int on = 1; + + hp = gethostbyname(peername); +@@ -69,6 +71,23 @@ int conn_open(const char *peername) + bcopy(hp->h_addr, &sin.sin_addr, hp->h_length); + sin.sin_port = htons(csync_port); + ++ /* Try to bind to IP address of local hostname, else in cases where ++ * there's multiple local IPs on the same subnet, we might autobind ++ * to the wrong one, and the remote csync2 instance will fail because ++ * it verifies the expected hostname against the initiating IP. ++ * If the explicit bind fails for some reason though, we'll still ++ * try to connect (it might work, and it can't hurt...). ++ */ ++ me = gethostbyname(myhostname); ++ if (me) { ++ sme.sin_family = me->h_addrtype; ++ bcopy(me->h_addr, &sme.sin_addr, me->h_length); ++ sme.sin_port = 0; /* random port */ ++ if (bind(conn_fd_in, (struct sockaddr *)&sme, sizeof(sme)) < 0) { ++ csync_debug(1, "Can't bind local socket (attempting connect anyway).\n"); ++ } ++ } ++ + if (connect(conn_fd_in, (struct sockaddr *)&sin, sizeof (sin)) < 0) { + csync_debug(1, "Can't connect to remote host.\n"); + close(conn_fd_in); conn_fd_in = -1; diff --git a/csync2.changes b/csync2.changes index 8d6947b..041b5ac 100644 --- a/csync2.changes +++ b/csync2.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri May 10 12:56:38 UTC 2013 - tserong@suse.com + +- Try to bind to "local" IP explicitly to avoid "identification failed" + errors with multiple IPs on same subnet (bnc#757327) + + Added bind-to-local-hostname.patch + ------------------------------------------------------------------- Thu Feb 28 06:00:00 UTC 2013 - coolo@suse.com diff --git a/csync2.spec b/csync2.spec index 0e83cbc..0ba028f 100644 --- a/csync2.spec +++ b/csync2.spec @@ -34,6 +34,7 @@ Patch2: csync2-1.34-pure-gnutls-r2.patch BuildRequires: pkg-config %endif Patch3: force-debug-stderr-off-inetd.patch +Patch4: bind-to-local-hostname.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build Requires(post): openssl Requires: gnutls @@ -68,6 +69,7 @@ and server farms. %patch2 -p1 %endif %patch3 -p1 +%patch4 -p1 install -p -m 644 %{SOURCE1} README.quickstart %build