summaryrefslogtreecommitdiff
path: root/source4/winbind
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2018-12-16 17:17:58 +0100
committerJeremy Allison <jra@samba.org>2019-01-08 03:40:28 +0100
commitf1e71a2c1e012596a0a753ea5f11df06244a3cb1 (patch)
tree2ac9a535fcc749130d47d9e0b459584788a5d939 /source4/winbind
parent6f4b2cc9659ff9da7f1e6c60678a0d4d4f453611 (diff)
downloadsamba-f1e71a2c1e012596a0a753ea5f11df06244a3cb1.tar.gz
winbind4: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source4/winbind')
-rw-r--r--source4/winbind/idmap.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/source4/winbind/idmap.c b/source4/winbind/idmap.c
index 86fd354b606..c944132ee76 100644
--- a/source4/winbind/idmap.c
+++ b/source4/winbind/idmap.c
@@ -401,7 +401,8 @@ static NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx,
struct ldb_result *res = NULL;
int trans = -1;
uint32_t low, high, hwm, new_xid;
- char *sid_string, *unixid_string, *hwm_string;
+ struct dom_sid_buf sid_string;
+ char *unixid_string, *hwm_string;
bool hwm_entry_exists;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
const char *sam_attrs[] = {"uidNumber", "gidNumber", "samAccountType", NULL};
@@ -445,6 +446,7 @@ static NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx,
*/
if (lpcfg_parm_bool(idmap_ctx->lp_ctx, NULL, "idmap_ldb", "use rfc2307", false)) {
+ struct dom_sid_buf buf;
ret = dsdb_search_one(idmap_ctx->samdb, tmp_ctx, &sam_msg,
ldb_get_default_basedn(idmap_ctx->samdb),
LDB_SCOPE_SUBTREE, sam_attrs, 0,
@@ -452,7 +454,7 @@ static NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx,
"(|(sAMaccountType=%u)(sAMaccountType=%u)(sAMaccountType=%u)"
"(sAMaccountType=%u)(sAMaccountType=%u))"
"(|(uidNumber=*)(gidNumber=*)))",
- dom_sid_string(tmp_ctx, sid),
+ dom_sid_str_buf(sid, &buf),
ATYPE_ACCOUNT, ATYPE_WORKSTATION_TRUST, ATYPE_INTERDOMAIN_TRUST,
ATYPE_SECURITY_GLOBAL_GROUP, ATYPE_SECURITY_LOCAL_GROUP);
} else {
@@ -461,8 +463,9 @@ static NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx,
}
if (ret == LDB_ERR_CONSTRAINT_VIOLATION) {
+ struct dom_sid_buf buf;
DEBUG(1, ("Search for objectSid=%s gave duplicate results, failing to map to a unix ID!\n",
- dom_sid_string(tmp_ctx, sid)));
+ dom_sid_str_buf(sid, &buf)));
status = NT_STATUS_NONE_MAPPED;
goto failed;
} else if (ret == LDB_SUCCESS) {
@@ -491,8 +494,10 @@ static NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx,
}
}
} else if (ret != LDB_ERR_NO_SUCH_OBJECT) {
+ struct dom_sid_buf buf;
DEBUG(1, ("Search for objectSid=%s gave '%s', failing to map to a SID!\n",
- dom_sid_string(tmp_ctx, sid), ldb_errstring(idmap_ctx->samdb)));
+ dom_sid_str_buf(sid, &buf),
+ ldb_errstring(idmap_ctx->samdb)));
status = NT_STATUS_NONE_MAPPED;
goto failed;
@@ -620,11 +625,7 @@ static NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx,
goto failed;
}
- sid_string = dom_sid_string(tmp_ctx, sid);
- if (sid_string == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto failed;
- }
+ dom_sid_str_buf(sid, &sid_string);
unixid_string = talloc_asprintf(tmp_ctx, "%u", new_xid);
if (unixid_string == NULL) {
@@ -700,7 +701,7 @@ static NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx,
goto failed;
}
- map_msg->dn = ldb_dn_new_fmt(tmp_ctx, ldb, "CN=%s", sid_string);
+ map_msg->dn = ldb_dn_new_fmt(tmp_ctx, ldb, "CN=%s", sid_string.buf);
if (map_msg->dn == NULL) {
status = NT_STATUS_NO_MEMORY;
goto failed;
@@ -731,7 +732,7 @@ static NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx,
goto failed;
}
- ret = ldb_msg_add_string(map_msg, "cn", sid_string);
+ ret = ldb_msg_add_string(map_msg, "cn", sid_string.buf);
if (ret != LDB_SUCCESS) {
status = NT_STATUS_NONE_MAPPED;
goto failed;
@@ -840,10 +841,11 @@ NTSTATUS idmap_sids_to_xids(struct idmap_context *idmap_ctx,
&id[i]->xid);
}
if (!NT_STATUS_IS_OK(status)) {
- char *str = dom_sid_string(mem_ctx, id[i]->sid);
+ struct dom_sid_buf buf;
DEBUG(1, ("idmapping sid_to_xid failed for id[%d]=%s: %s\n",
- i, str, nt_errstr(status)));
- talloc_free(str);
+ i,
+ dom_sid_str_buf(id[i]->sid, &buf),
+ nt_errstr(status)));
error_count++;
id[i]->status = ID_UNMAPPED;
} else {