static struct winbind_cache *get_cache(struct winbindd_domain *domain)
{
struct winbind_cache *ret = wcache;
+#ifdef HAVE_ADS
struct winbindd_domain *our_domain = domain;
+#endif
/* we have to know what type of domain we are dealing with first */
smb_panic("centry_string");
}
- if (mem_ctx != NULL)
- ret = TALLOC(mem_ctx, len+1);
- else
- ret = SMB_MALLOC(len+1);
+ ret = TALLOC(mem_ctx, len+1);
if (!ret) {
smb_panic("centry_string out of memory\n");
}
/* pull a string from a cache entry, using the supplied
talloc context
*/
-static BOOL centry_sid(struct cache_entry *centry, DOM_SID *sid)
+static BOOL centry_sid(struct cache_entry *centry, TALLOC_CTX *mem_ctx, DOM_SID *sid)
{
char *sid_string;
- sid_string = centry_string(centry, NULL);
+ sid_string = centry_string(centry, mem_ctx);
if (!string_to_sid(sid, sid_string)) {
return False;
}
- SAFE_FREE(sid_string);
return True;
}
struct winbind_cache *cache = get_cache(domain);
TDB_DATA data;
fstring key_str;
+ uint32 rid;
if (!cache->tdb) {
return NT_STATUS_INTERNAL_DB_ERROR;
}
+ if (is_null_sid(sid)) {
+ return NT_STATUS_INVALID_SID;
+ }
+
+ if (!(sid_peek_rid(sid, &rid)) || (rid == 0)) {
+ return NT_STATUS_INVALID_SID;
+ }
+
fstr_sprintf(key_str, "CRED/%s", sid_string_static(sid));
data = tdb_fetch(cache->tdb, make_tdb_data(key_str, strlen(key_str)));
struct cache_entry *centry = NULL;
NTSTATUS status;
time_t t;
+ uint32 rid;
if (!cache->tdb) {
return NT_STATUS_INTERNAL_DB_ERROR;
}
+ if (is_null_sid(sid)) {
+ return NT_STATUS_INVALID_SID;
+ }
+
+ if (!(sid_peek_rid(sid, &rid)) || (rid == 0)) {
+ return NT_STATUS_INVALID_SID;
+ }
+
centry = wcache_fetch(cache, domain, "CRED/%s", sid_string_static(sid));
if (!centry) {
t = centry_time(centry);
*cached_nt_pass = (const uint8 *)centry_string(centry, mem_ctx);
- dump_data(10, (const char *)cached_nt_pass, NT_HASH_LEN);
+#if DEBUG_PASSWORD
+ dump_data(100, (const char *)cached_nt_pass, NT_HASH_LEN);
+#endif
status = centry->status;
DEBUG(10,("wcache_get_creds: [Cached] - cached creds for user %s status %s\n",
{
struct cache_entry *centry;
fstring sid_string;
- NTSTATUS status = NT_STATUS_OK; /* ??? */
+ uint32 rid;
- centry = centry_start(domain, status);
+ if (is_null_sid(sid)) {
+ return NT_STATUS_INVALID_SID;
+ }
+
+ if (!(sid_peek_rid(sid, &rid)) || (rid == 0)) {
+ return NT_STATUS_INVALID_SID;
+ }
+
+ centry = centry_start(domain, NT_STATUS_OK);
if (!centry) {
return NT_STATUS_INTERNAL_DB_ERROR;
}
+#if DEBUG_PASSWORD
dump_data(100, (const char *)nt_pass, NT_HASH_LEN);
+#endif
centry_put_time(centry, time(NULL));
centry_put_string(centry, (const char *)nt_pass);
(*info)[i].full_name = centry_string(centry, mem_ctx);
(*info)[i].homedir = centry_string(centry, mem_ctx);
(*info)[i].shell = centry_string(centry, mem_ctx);
- centry_sid(centry, &(*info)[i].user_sid);
- centry_sid(centry, &(*info)[i].group_sid);
+ centry_sid(centry, mem_ctx, &(*info)[i].user_sid);
+ centry_sid(centry, mem_ctx, &(*info)[i].group_sid);
}
do_cached:
*type = (enum SID_NAME_USE)centry_uint32(centry);
status = centry->status;
if (NT_STATUS_IS_OK(status)) {
- centry_sid(centry, sid);
+ centry_sid(centry, mem_ctx, sid);
}
DEBUG(10,("name_to_sid: [Cached] - cached name for domain %s status %s\n",
info->full_name = centry_string(centry, mem_ctx);
info->homedir = centry_string(centry, mem_ctx);
info->shell = centry_string(centry, mem_ctx);
- centry_sid(centry, &info->user_sid);
- centry_sid(centry, &info->group_sid);
+ centry_sid(centry, mem_ctx, &info->user_sid);
+ centry_sid(centry, mem_ctx, &info->group_sid);
status = centry->status;
DEBUG(10,("query_user: [Cached] - cached info for domain %s status %s\n",
if (! (*user_gids))
smb_panic("lookup_usergroups out of memory");
for (i=0; i<(*num_groups); i++) {
- centry_sid(centry, &(*user_gids)[i]);
+ centry_sid(centry, mem_ctx, &(*user_gids)[i]);
}
do_cached:
}
for (i=0; i<(*num_names); i++) {
- centry_sid(centry, &(*sid_mem)[i]);
+ centry_sid(centry, mem_ctx, &(*sid_mem)[i]);
(*names)[i] = centry_string(centry, mem_ctx);
(*name_types)[i] = centry_uint32(centry);
}
for (i=0; i<(*num_domains); i++) {
(*names)[i] = centry_string(centry, mem_ctx);
(*alt_names)[i] = centry_string(centry, mem_ctx);
- centry_sid(centry, &(*dom_sids)[i]);
+ centry_sid(centry, mem_ctx, &(*dom_sids)[i]);
}
status = centry->status;
status = domain->backend->trusted_domains(domain, mem_ctx, num_domains,
names, alt_names, dom_sids);
-
+
+ /* no trusts gives NT_STATUS_NO_MORE_ENTRIES resetting to NT_STATUS_OK
+ * so that the generic centry handling still applies correctly -
+ * Guenther*/
+
+ if (!NT_STATUS_IS_ERR(status)) {
+ status = NT_STATUS_OK;
+ }
+
/* and save it */
refresh_sequence_number(domain, False);
fstr_sprintf(key_str, "DE/%d", pid);
if (tdb_store(wcache->tdb, string_tdb_data(key_str),
- make_tdb_data(response->extra_data,
+ make_tdb_data(response->extra_data.data,
response->length - sizeof(*response)),
TDB_REPLACE) == 0)
return;
SAFE_FREE(data.dptr);
if (response->length == sizeof(*response)) {
- response->extra_data = NULL;
+ response->extra_data.data = NULL;
return True;
}
dump_data(11, data.dptr, data.dsize);
- response->extra_data = data.dptr;
+ response->extra_data.data = data.dptr;
return True;
}
if (NT_STATUS_IS_OK(centry->status)) {
*type = (enum SID_NAME_USE)centry_uint32(centry);
- centry_sid(centry, sid);
+ centry_sid(centry, mem_ctx, sid);
}
status = centry->status;