1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

winbindd_cache: Use dom_sid_str_buf

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2018-12-06 18:25:02 +01:00 committed by Jeremy Allison
parent a32564eaf9
commit 263edf7fe9

View File

@ -1241,7 +1241,8 @@ NTSTATUS wcache_cached_creds_exist(struct winbindd_domain *domain, const struct
{
struct winbind_cache *cache = get_cache(domain);
int ret;
fstring key_str, tmp;
struct dom_sid_buf tmp;
fstring key_str;
uint32_t rid;
if (!cache->tdb) {
@ -1256,7 +1257,7 @@ NTSTATUS wcache_cached_creds_exist(struct winbindd_domain *domain, const struct
return NT_STATUS_INVALID_SID;
}
fstr_sprintf(key_str, "CRED/%s", sid_to_fstring(tmp, sid));
fstr_sprintf(key_str, "CRED/%s", dom_sid_str_buf(sid, &tmp));
ret = tdb_exists(cache->tdb, string_tdb_data(key_str));
if (ret != 1) {
@ -1279,7 +1280,7 @@ NTSTATUS wcache_get_creds(struct winbindd_domain *domain,
struct cache_entry *centry = NULL;
NTSTATUS status;
uint32_t rid;
fstring tmp;
struct dom_sid_buf tmp;
if (!cache->tdb) {
return NT_STATUS_INTERNAL_DB_ERROR;
@ -1297,7 +1298,7 @@ NTSTATUS wcache_get_creds(struct winbindd_domain *domain,
fall back to an unsalted cred. */
centry = wcache_fetch(cache, domain, "CRED/%s",
sid_to_fstring(tmp, sid));
dom_sid_str_buf(sid, &tmp));
if (!centry) {
DEBUG(10,("wcache_get_creds: entry for [CRED/%s] not found\n",
sid_string_dbg(sid)));
@ -1318,15 +1319,15 @@ NTSTATUS wcache_get_creds(struct winbindd_domain *domain,
*cached_nt_pass = (const uint8_t *)centry_hash16(centry, mem_ctx);
if (*cached_nt_pass == NULL) {
fstring sidstr;
struct dom_sid_buf sidstr;
sid_to_fstring(sidstr, sid);
dom_sid_str_buf(sid, &sidstr);
/* Bad (old) cred cache. Delete and pretend we
don't have it. */
DEBUG(0,("wcache_get_creds: bad entry for [CRED/%s] - deleting\n",
sidstr));
wcache_delete("CRED/%s", sidstr);
sidstr.buf));
wcache_delete("CRED/%s", sidstr.buf);
centry_free(centry);
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
@ -1359,7 +1360,7 @@ NTSTATUS wcache_save_creds(struct winbindd_domain *domain,
const uint8_t nt_pass[NT_HASH_LEN])
{
struct cache_entry *centry;
fstring sid_string;
struct dom_sid_buf sid_str;
uint32_t rid;
uint8_t cred_salt[NT_HASH_LEN];
uint8_t salted_hash[NT_HASH_LEN];
@ -1387,9 +1388,9 @@ NTSTATUS wcache_save_creds(struct winbindd_domain *domain,
centry_put_hash16(centry, salted_hash);
centry_put_hash16(centry, cred_salt);
centry_end(centry, "CRED/%s", sid_to_fstring(sid_string, sid));
centry_end(centry, "CRED/%s", dom_sid_str_buf(sid, &sid_str));
DEBUG(10,("wcache_save_creds: %s\n", sid_string));
DEBUG(10,("wcache_save_creds: %s\n", sid_str.buf));
centry_free(centry);
@ -2450,9 +2451,11 @@ static char *wcache_make_sidlist(TALLOC_CTX *mem_ctx, uint32_t num_sids,
return NULL;
}
for (i=0; i<num_sids; i++) {
fstring tmp;
struct dom_sid_buf tmp;
sidlist = talloc_asprintf_append_buffer(
sidlist, "/%s", sid_to_fstring(tmp, &sids[i]));
sidlist,
"/%s",
dom_sid_str_buf(&sids[i], &tmp));
if (sidlist == NULL) {
return NULL;
}
@ -3423,11 +3426,12 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const
/* we possibly already have an entry */
if (sid && NT_STATUS_IS_OK(wcache_cached_creds_exist(domain, sid))) {
fstring key_str, tmp;
fstring key_str;
struct dom_sid_buf tmp;
DEBUG(11,("we already have an entry, deleting that\n"));
fstr_sprintf(key_str, "CRED/%s", sid_to_fstring(tmp, sid));
fstr_sprintf(key_str, "CRED/%s", dom_sid_str_buf(sid, &tmp));
tdb_delete(cache->tdb, string_tdb_data(key_str));
@ -4384,7 +4388,7 @@ static int pack_tdc_domains( struct winbindd_tdc_domain *domains,
/* now pack each domain trust record */
for ( i=0; i<num_domains; i++ ) {
fstring tmp;
struct dom_sid_buf tmp;
if ( buflen > 0 ) {
DEBUG(10,("pack_tdc_domains: Packing domain %s (%s)\n",
@ -4395,7 +4399,7 @@ static int pack_tdc_domains( struct winbindd_tdc_domain *domains,
len += tdb_pack( buffer+len, buflen-len, "fffddd",
domains[i].domain_name,
domains[i].dns_name ? domains[i].dns_name : "",
sid_to_fstring(tmp, &domains[i].sid),
dom_sid_str_buf(&domains[i].sid, &tmp),
domains[i].trust_flags,
domains[i].trust_attribs,
domains[i].trust_type );