From: Volker Lendecke Date: Sun, 16 Dec 2018 16:24:36 +0000 (+0100) Subject: libnet4: Use dom_sid_str_buf X-Git-Tag: tdb-1.3.17~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b06f0912fc6873d3f7ca49d57267005c0f5c6c19;p=thirdparty%2Fsamba.git libnet4: Use dom_sid_str_buf Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source4/libnet/libnet_join.c b/source4/libnet/libnet_join.c index 245485f69cd..825a81579cc 100644 --- a/source4/libnet/libnet_join.c +++ b/source4/libnet/libnet_join.c @@ -610,10 +610,13 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru status = od.out.result; } if (!NT_STATUS_IS_OK(status)) { - r->out.error_string = talloc_asprintf(mem_ctx, - "samr_OpenDomain for [%s] failed: %s", - dom_sid_string(tmp_ctx, connect_with_info->out.domain_sid), - nt_errstr(status)); + struct dom_sid_buf buf; + r->out.error_string = talloc_asprintf( + mem_ctx, + "samr_OpenDomain for [%s] failed: %s", + dom_sid_str_buf(connect_with_info->out.domain_sid, + &buf), + nt_errstr(status)); talloc_free(tmp_ctx); return status; } diff --git a/source4/libnet/libnet_samdump.c b/source4/libnet/libnet_samdump.c index 326d8041b26..097a6efe54e 100644 --- a/source4/libnet/libnet_samdump.c +++ b/source4/libnet/libnet_samdump.c @@ -183,6 +183,7 @@ NTSTATUS libnet_SamDump(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, for (s=samdump_state->secrets; s; s=s->next) { size_t converted_size = 0; char *secret_string; + struct dom_sid_buf buf; if (strcasecmp_m(s->name, secret_name) != 0) { continue; } @@ -196,7 +197,8 @@ NTSTATUS libnet_SamDump(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, return NT_STATUS_INVALID_PARAMETER; } printf("%s\t%s\t%s\n", - t->name, dom_sid_string(mem_ctx, t->sid), + t->name, + dom_sid_str_buf(t->sid, &buf), secret_string); } } diff --git a/source4/libnet/libnet_samsync_ldb.c b/source4/libnet/libnet_samsync_ldb.c index 9ea7dce041c..3171138886c 100644 --- a/source4/libnet/libnet_samsync_ldb.c +++ b/source4/libnet/libnet_samsync_ldb.c @@ -71,7 +71,7 @@ static NTSTATUS samsync_ldb_add_foreignSecurityPrincipal(TALLOC_CTX *mem_ctx, struct ldb_dn **fsp_dn, char **error_string) { - const char *sidstr = dom_sid_string(mem_ctx, sid); + struct dom_sid_buf buf; /* We assume that ForeignSecurityPrincipals are under the BASEDN of the main domain */ struct ldb_dn *basedn = samdb_search_dn(state->sam_ldb, mem_ctx, state->base_dn[SAM_DATABASE_DOMAIN], @@ -79,10 +79,6 @@ static NTSTATUS samsync_ldb_add_foreignSecurityPrincipal(TALLOC_CTX *mem_ctx, struct ldb_message *msg; int ret; - if (!sidstr) { - return NT_STATUS_NO_MEMORY; - } - if (basedn == NULL) { *error_string = talloc_asprintf(mem_ctx, "Failed to find DN for " @@ -98,7 +94,8 @@ static NTSTATUS samsync_ldb_add_foreignSecurityPrincipal(TALLOC_CTX *mem_ctx, /* add core elements to the ldb_message for the alias */ msg->dn = basedn; - if ( ! ldb_dn_add_child_fmt(msg->dn, "CN=%s", sidstr)) + if ( ! ldb_dn_add_child_fmt( + msg->dn, "CN=%s", dom_sid_str_buf(sid, &buf))) return NT_STATUS_UNSUCCESSFUL; ldb_msg_add_string(msg, "objectClass", "foreignSecurityPrincipal"); @@ -973,20 +970,15 @@ static NTSTATUS samsync_ldb_handle_account(TALLOC_CTX *mem_ctx, struct ldb_message *msg; int ret; uint32_t i; - char *dnstr, *sidstr; + char *dnstr; + struct dom_sid_buf buf; msg = ldb_msg_new(mem_ctx); if (msg == NULL) { return NT_STATUS_NO_MEMORY; } - sidstr = dom_sid_string(msg, sid); - if (sidstr == NULL) { - TALLOC_FREE(msg); - return NT_STATUS_NO_MEMORY; - } - - dnstr = talloc_asprintf(msg, "sid=%s", sidstr); + dnstr = talloc_asprintf(msg, "sid=%s", dom_sid_str_buf(sid, &buf)); if (dnstr == NULL) { TALLOC_FREE(msg); return NT_STATUS_NO_MEMORY; @@ -1050,8 +1042,11 @@ static NTSTATUS samsync_ldb_delete_account(TALLOC_CTX *mem_ctx, } else if (ret == 0) { return NT_STATUS_NO_SUCH_USER; } else if (ret > 1) { - *error_string = talloc_asprintf(mem_ctx, "More than one account with SID: %s", - dom_sid_string(mem_ctx, sid)); + struct dom_sid_buf buf; + *error_string = talloc_asprintf( + mem_ctx, + "More than one account with SID: %s", + dom_sid_str_buf(sid, &buf)); return NT_STATUS_INTERNAL_DB_CORRUPTION; } else { msg->dn = talloc_steal(msg, msgs[0]->dn);