Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into registry
[kai/samba.git] / source4 / wrepl_server / wrepl_in_call.c
index 8ce88db6a9cd1a151347616b44c4461d2ec573ac..0508c306e01997839069e26c9ec2417eadcc745e 100644 (file)
@@ -7,7 +7,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -50,12 +49,19 @@ static NTSTATUS wreplsrv_in_start_association(struct wreplsrv_in_call *call)
                return NT_STATUS_OK;
        }
 
+/*
+ * it seems that we don't know all details about the start_association
+ * to support replication with NT4 (it sends 1.1 instead of 5.2)
+ * we ignore the version numbers until we know all details
+ */
+#if 0
        if (start->minor_version != 2 || start->major_version != 5) {
                /* w2k terminate the connection if the versions doesn't match */
                return NT_STATUS_UNKNOWN_REVISION;
        }
+#endif
 
-       call->wreplconn->assoc_ctx.stopped      = False;
+       call->wreplconn->assoc_ctx.stopped      = false;
        call->wreplconn->assoc_ctx.our_ctx      = WREPLSRV_VALID_ASSOC_CTX;
        call->wreplconn->assoc_ctx.peer_ctx     = start->assoc_ctx;
 
@@ -64,6 +70,19 @@ static NTSTATUS wreplsrv_in_start_association(struct wreplsrv_in_call *call)
        start_reply->minor_version              = 2;
        start_reply->major_version              = 5;
 
+       /*
+        * nt4 uses 41 bytes for the start_association call
+        * so do it the same and as we don't know the meanings of this bytes
+        * we just send zeros and nt4, w2k and w2k3 seems to be happy with this
+        *
+        * if we don't do this nt4 uses an old version of the wins replication protocol
+        * and that would break nt4 <-> samba replication
+        */
+       call->rep_packet.padding                = data_blob_talloc(call, NULL, 21);
+       NT_STATUS_HAVE_NO_MEMORY(call->rep_packet.padding.data);
+
+       memset(call->rep_packet.padding.data, 0, call->rep_packet.padding.length);
+
        return NT_STATUS_OK;
 }
 
@@ -71,7 +90,7 @@ static NTSTATUS wreplsrv_in_stop_assoc_ctx(struct wreplsrv_in_call *call)
 {
        struct wrepl_stop *stop_out             = &call->rep_packet.message.stop;
 
-       call->wreplconn->assoc_ctx.stopped      = True;
+       call->wreplconn->assoc_ctx.stopped      = true;
 
        call->rep_packet.mess_type              = WREPL_STOP_ASSOCIATION;
        stop_out->reason                        = 4;
@@ -101,7 +120,7 @@ static NTSTATUS wreplsrv_in_stop_association(struct wreplsrv_in_call *call)
        }
 
        /* this will cause to not receive packets anymore and terminate the connection if the reply is send */
-       call->terminate_after_send = True;
+       call->terminate_after_send = true;
        return wreplsrv_in_stop_assoc_ctx(call);
 }
 
@@ -114,7 +133,7 @@ static NTSTATUS wreplsrv_in_table_query(struct wreplsrv_in_call *call)
        repl_out->command = WREPL_REPL_TABLE_REPLY;
 
        return wreplsrv_fill_wrepl_table(service, call, table_out,
-                                        service->wins_db->local_owner, True);
+                                        service->wins_db->local_owner, true);
 }
 
 static int wreplsrv_in_sort_wins_name(struct wrepl_wins_name *n1,