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;
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;
(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;
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);
}
}
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" };
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,
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) {