s4-winbind: use ncalrpc when talking to ourselves
authorAndrew Tridgell <tridge@samba.org>
Wed, 13 Jul 2011 07:27:45 +0000 (17:27 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 9 Feb 2012 04:41:48 +0000 (15:41 +1100)
this solves a problem with s3fs causing a fork bomb

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/winbind/wb_init_domain.c

index 9d807d87764d98bcbb50c3b2342bcccf5ef56e5f..007ee42935cdda536c03a5fae08740c679394477 100644 (file)
@@ -79,16 +79,28 @@ static struct dcerpc_binding *init_domain_binding(struct init_domain_state *stat
 {
        struct dcerpc_binding *binding;
        NTSTATUS status;
-
+       char *s;
+       char *our_name;
+
+       /* we avoid connecting to ourselves over ncacn_np, as that has
+          quite a high overhead with s3fs */
+       our_name = talloc_asprintf(state, "%s.%s",
+                                  lpcfg_netbios_name(state->service->task->lp_ctx),
+                                  lpcfg_realm(state->service->task->lp_ctx));
        /* Make a binding string */
-       {
-               char *s = talloc_asprintf(state, "ncacn_np:%s", state->domain->dc_name);
-               if (s == NULL) return NULL;
-               status = dcerpc_parse_binding(state, s, &binding);
-               talloc_free(s);
-               if (!NT_STATUS_IS_OK(status)) {
-                       return NULL;
-               }
+       if (strcasecmp(lpcfg_netbios_name(state->service->task->lp_ctx),
+                      state->domain->dc_name) == 0 ||
+           strcasecmp(our_name, state->domain->dc_name) == 0) {
+               s = talloc_asprintf(state, "ncalrpc:%s", state->domain->dc_name);
+       } else {
+               s = talloc_asprintf(state, "ncacn_np:%s", state->domain->dc_name);
+       }
+       talloc_free(our_name);
+       if (s == NULL) return NULL;
+       status = dcerpc_parse_binding(state, s, &binding);
+       talloc_free(s);
+       if (!NT_STATUS_IS_OK(status)) {
+               return NULL;
        }
 
        /* Alter binding to contain hostname, but also address (so we don't look it up twice) */