More formatting fixes.
[ab/samba.git/.git] / source4 / lib / com / dcom / main.c
index 01efb68c05c95d6eea1ec3727ffe7b14051dc64c..a4b37f192717cb8b041786820ae7d19ba7c41db7 100644 (file)
@@ -84,12 +84,23 @@ struct cli_credentials *dcom_get_server_credentials(struct com_context *ctx, con
        return d;
 }
 
-void dcom_set_server_credentials(struct com_context *ctx, const char *server, struct cli_credentials *credentials)
+/**
+ * Register credentials for a specific server.
+ *
+ * @param ctx COM context
+ * @param server Name of server, can be NULL
+ * @param credentials Credentials object
+ */
+void dcom_add_server_credentials(struct com_context *ctx, const char *server, 
+                                                                struct cli_credentials *credentials)
 {
        struct dcom_server_credentials *c;
 
+       /* FIXME: Don't use talloc_find_parent_bytype */
        for (c = ctx->dcom->credentials; c; c = c->next) {
-               if ((server == NULL && c->server == NULL) ||(server && c->server && !strcmp(c->server, server))) {
+               if ((server == NULL && c->server == NULL) ||
+                       (server != NULL && c->server != NULL && 
+                        !strcmp(c->server, server))) {
                        if (c->credentials && c->credentials != credentials) {
                                talloc_unlink(c, c->credentials);
                                c->credentials = credentials;
@@ -98,9 +109,11 @@ void dcom_set_server_credentials(struct com_context *ctx, const char *server, st
                                else
                                        talloc_steal(c, c->credentials);
                        }
+
                        return;
                }
        }
+
        c = talloc(ctx->event_ctx, struct dcom_server_credentials);
        c->server = talloc_strdup(c, server);
        c->credentials = credentials;
@@ -108,10 +121,13 @@ void dcom_set_server_credentials(struct com_context *ctx, const char *server, st
                (void)talloc_reference(c, c->credentials);
        else
                talloc_steal(c, c->credentials);
+
        DLIST_ADD(ctx->dcom->credentials, c);
 }
 
-void dcom_update_credentials_for_aliases(struct com_context *ctx, const char *server, struct DUALSTRINGARRAY *pds)
+void dcom_update_credentials_for_aliases(struct com_context *ctx, 
+                                                                                const char *server, 
+                                                                                struct DUALSTRINGARRAY *pds)
 {
        struct cli_credentials *cc;
        struct dcerpc_binding *b;
@@ -120,10 +136,12 @@ void dcom_update_credentials_for_aliases(struct com_context *ctx, const char *se
 
        cc = dcom_get_server_credentials(ctx, server);
         for (i = 0; pds->stringbindings[i]; ++i) {
-                if (pds->stringbindings[i]->wTowerId != EPM_PROTOCOL_TCP) continue;
+                if (pds->stringbindings[i]->wTowerId != EPM_PROTOCOL_TCP) 
+                                       continue;
                 status = dcerpc_binding_from_STRINGBINDING(ctx, &b, pds->stringbindings[i]);
-               if (!NT_STATUS_IS_OK(status)) continue;
-               dcom_set_server_credentials(ctx, b->host, cc);
+               if (!NT_STATUS_IS_OK(status)) 
+                       continue;
+               dcom_add_server_credentials(ctx, b->host, cc);
                talloc_free(b);
        }
 }
@@ -140,7 +158,8 @@ struct dcom_client_context *dcom_client_init(struct com_context *ctx, struct cli
        return ctx->dcom;
 }
 
-static NTSTATUS dcom_connect_host(struct com_context *ctx, struct dcerpc_pipe **p, const char *server)
+static NTSTATUS dcom_connect_host(struct com_context *ctx, 
+                                                                 struct dcerpc_pipe **p, const char *server)
 {
        struct dcerpc_binding *bd;
        const char * available_transports[] = { "ncacn_ip_tcp", "ncacn_np" };
@@ -156,7 +175,8 @@ static NTSTATUS dcom_connect_host(struct com_context *ctx, struct dcerpc_pipe **
        loc_ctx = talloc_new(ctx);
 
        /* Allow server name to contain a binding string */
-       if (strchr(server, ':') && NT_STATUS_IS_OK(dcerpc_parse_binding(loc_ctx, server, &bd))) {
+       if (strchr(server, ':') && 
+               NT_STATUS_IS_OK(dcerpc_parse_binding(loc_ctx, server, &bd))) {
                if (DEBUGLVL(11))
                        bd->flags |= DCERPC_DEBUG_PRINT_BOTH;
                status = dcerpc_pipe_connect_b(ctx->event_ctx, p, bd, 
@@ -189,7 +209,8 @@ end:
        return status;
 }
 
-struct dcom_object_exporter *object_exporter_by_oxid(struct com_context *ctx, uint64_t oxid)
+struct dcom_object_exporter *object_exporter_by_oxid(struct com_context *ctx, 
+                                                                                                        uint64_t oxid)
 {
        struct dcom_object_exporter *ox;
        for (ox = ctx->dcom->object_exporters; ox; ox = ox->next) {