From 6438819609d1373da54a4efd4346fcd49ab91ff4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 11 Dec 2018 16:09:41 +0100 Subject: [PATCH] passdb: Use dom_sid_str_buf Signed-off-by: Volker Lendecke Reviewed-by: Gary Lockyer --- source3/passdb/passdb.c | 11 ++++++++--- source3/passdb/pdb_compat.c | 6 ++++-- source3/passdb/pdb_get_set.c | 7 +++++-- source3/passdb/pdb_interface.c | 14 +++++++++----- source3/passdb/pdb_secrets.c | 3 ++- source3/passdb/pdb_util.c | 12 ++++++++---- 6 files changed, 36 insertions(+), 17 deletions(-) diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index 64e05b346de..401a11135cd 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -608,8 +608,11 @@ bool lookup_global_sam_name(const char *name, int flags, uint32_t *rid, if (ret) { if (!sid_check_is_in_our_sam(&user_sid)) { - DEBUG(0, ("User %s with invalid SID %s in passdb\n", - name, sid_string_dbg(&user_sid))); + struct dom_sid_buf buf; + DBG_ERR("User %s with invalid SID %s" + " in passdb\n", + name, + dom_sid_str_buf(&user_sid, &buf)); return False; } @@ -639,9 +642,11 @@ bool lookup_global_sam_name(const char *name, int flags, uint32_t *rid, /* BUILTIN groups are looked up elsewhere */ if (!sid_check_is_in_our_sam(&map->sid)) { + struct dom_sid_buf buf; DEBUG(10, ("Found group %s (%s) not in our domain -- " "ignoring.\n", - name, sid_string_dbg(&map->sid))); + name, + dom_sid_str_buf(&map->sid, &buf))); TALLOC_FREE(map); return False; } diff --git a/source3/passdb/pdb_compat.c b/source3/passdb/pdb_compat.c index 6b7797a2d6d..2a32ec89012 100644 --- a/source3/passdb/pdb_compat.c +++ b/source3/passdb/pdb_compat.c @@ -52,6 +52,7 @@ uint32_t pdb_get_group_rid (struct samu *sampass) bool pdb_set_user_sid_from_rid (struct samu *sampass, uint32_t rid, enum pdb_value_state flag) { struct dom_sid u_sid; + struct dom_sid_buf buf; const struct dom_sid *global_sam_sid; if (!sampass) @@ -70,7 +71,7 @@ bool pdb_set_user_sid_from_rid (struct samu *sampass, uint32_t rid, enum pdb_val return False; DEBUG(10, ("pdb_set_user_sid_from_rid:\n\tsetting user sid %s from rid %d\n", - sid_string_dbg(&u_sid),rid)); + dom_sid_str_buf(&u_sid, &buf), rid)); return True; } @@ -78,6 +79,7 @@ bool pdb_set_user_sid_from_rid (struct samu *sampass, uint32_t rid, enum pdb_val bool pdb_set_group_sid_from_rid (struct samu *sampass, uint32_t grid, enum pdb_value_state flag) { struct dom_sid g_sid; + struct dom_sid_buf buf; const struct dom_sid *global_sam_sid; if (!sampass) @@ -96,7 +98,7 @@ bool pdb_set_group_sid_from_rid (struct samu *sampass, uint32_t grid, enum pdb_v return False; DEBUG(10, ("pdb_set_group_sid_from_rid:\n\tsetting group sid %s from rid %d\n", - sid_string_dbg(&g_sid), grid)); + dom_sid_str_buf(&g_sid, &buf), grid)); return True; } diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c index 35181da3a4f..31e18df0c08 100644 --- a/source3/passdb/pdb_get_set.c +++ b/source3/passdb/pdb_get_set.c @@ -486,13 +486,15 @@ bool pdb_set_init_flags(struct samu *sampass, enum pdb_elements element, enum pd bool pdb_set_user_sid(struct samu *sampass, const struct dom_sid *u_sid, enum pdb_value_state flag) { + struct dom_sid_buf buf; + if (!u_sid) return False; sid_copy(&sampass->user_sid, u_sid); DEBUG(10, ("pdb_set_user_sid: setting user sid %s\n", - sid_string_dbg(&sampass->user_sid))); + dom_sid_str_buf(&sampass->user_sid, &buf))); return pdb_set_init_flags(sampass, PDB_USERSID, flag); } @@ -532,6 +534,7 @@ bool pdb_set_group_sid(struct samu *sampass, const struct dom_sid *g_sid, enum p { gid_t gid; struct dom_sid dug_sid; + struct dom_sid_buf buf; if (!g_sid) return False; @@ -554,7 +557,7 @@ bool pdb_set_group_sid(struct samu *sampass, const struct dom_sid *g_sid, enum p } DEBUG(10, ("pdb_set_group_sid: setting group sid %s\n", - sid_string_dbg(sampass->group_sid))); + dom_sid_str_buf(sampass->group_sid, &buf))); return pdb_set_init_flags(sampass, PDB_GROUPSID, flag); } diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index 78ff2daafaf..d42d5e52932 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -1497,6 +1497,8 @@ static bool pdb_default_sid_to_id(struct pdb_methods *methods, TALLOC_CTX *mem_ctx; bool ret = False; uint32_t rid; + struct dom_sid_buf buf; + id->id = -1; mem_ctx = talloc_new(NULL); @@ -1529,13 +1531,14 @@ static bool pdb_default_sid_to_id(struct pdb_methods *methods, "an object exists in the database, " "but it is neither a user nor a " "group (got type %d).\n", - sid_string_dbg(sid), type)); + dom_sid_str_buf(sid, &buf), + type)); ret = false; } } else { DEBUG(5, ("SID %s belongs to our domain, but there is " "no corresponding object in the database.\n", - sid_string_dbg(sid))); + dom_sid_str_buf(sid, &buf))); } goto done; } @@ -1563,13 +1566,14 @@ static bool pdb_default_sid_to_id(struct pdb_methods *methods, if (!NT_STATUS_IS_OK(methods->getgrsid(methods, map, *sid))) { DEBUG(10, ("Could not find map for sid %s\n", - sid_string_dbg(sid))); + dom_sid_str_buf(sid, &buf))); goto done; } if ((map->sid_name_use != SID_NAME_ALIAS) && (map->sid_name_use != SID_NAME_WKN_GRP)) { DEBUG(10, ("Map for sid %s is a %s, expected an " - "alias\n", sid_string_dbg(sid), + "alias\n", + dom_sid_str_buf(sid, &buf), sid_type_lookup(map->sid_name_use))); goto done; } @@ -1581,7 +1585,7 @@ static bool pdb_default_sid_to_id(struct pdb_methods *methods, } DEBUG(5, ("Sid %s is neither ours, a Unix SID, nor builtin\n", - sid_string_dbg(sid))); + dom_sid_str_buf(sid, &buf))); done: diff --git a/source3/passdb/pdb_secrets.c b/source3/passdb/pdb_secrets.c index a581190a225..2e983058c61 100644 --- a/source3/passdb/pdb_secrets.c +++ b/source3/passdb/pdb_secrets.c @@ -75,9 +75,10 @@ static int list_trusted_domain(struct db_record *rec, void *private_data) } if (pass.domain_sid.num_auths != 4) { + struct dom_sid_buf buf; DEBUG(0, ("SID %s is not a domain sid, has %d " "auths instead of 4\n", - sid_string_dbg(&pass.domain_sid), + dom_sid_str_buf(&pass.domain_sid, &buf), pass.domain_sid.num_auths)); return 0; } diff --git a/source3/passdb/pdb_util.c b/source3/passdb/pdb_util.c index dcafbfcf62f..780c03fdc8d 100644 --- a/source3/passdb/pdb_util.c +++ b/source3/passdb/pdb_util.c @@ -47,16 +47,20 @@ static NTSTATUS add_sid_to_builtin(const struct dom_sid *builtin_sid, status = pdb_add_aliasmem(builtin_sid, dom_sid); if (NT_STATUS_EQUAL(status, NT_STATUS_MEMBER_IN_ALIAS)) { + struct dom_sid_buf buf1, buf2; DEBUG(5, ("add_sid_to_builtin %s is already a member of %s\n", - sid_string_dbg(dom_sid), - sid_string_dbg(builtin_sid))); + dom_sid_str_buf(dom_sid, &buf1), + dom_sid_str_buf(builtin_sid, &buf2))); return NT_STATUS_OK; } if (!NT_STATUS_IS_OK(status)) { + struct dom_sid_buf buf1, buf2; DEBUG(4, ("add_sid_to_builtin %s could not be added to %s: " - "%s\n", sid_string_dbg(dom_sid), - sid_string_dbg(builtin_sid), nt_errstr(status))); + "%s\n", + dom_sid_str_buf(dom_sid, &buf1), + dom_sid_str_buf(builtin_sid, &buf2), + nt_errstr(status))); } return status; }