extern struct winbindd_methods builtin_passdb_methods;
extern struct winbindd_methods sam_passdb_methods;
+static void wcache_flush_cache(void);
+
/*
* JRA. KEEP THIS LIST UP TO DATE IF YOU ADD CACHE ENTRIES.
* Here are the list of entry types that are *not* stored
void (*smb_panic_fn)(const char *const why) = smb_panic;
-#define WINBINDD_MAX_CACHE_SIZE (50*1024*1024)
-
static struct winbind_cache *wcache;
static char *wcache_path(void)
}
if (strequal(domain->name, get_global_sam_name()) &&
- sid_check_is_our_sam(&domain->sid)) {
+ sid_check_is_our_sam(&domain->sid))
+ {
domain->backend = &sam_passdb_methods;
}
- if ( !domain->initialized ) {
+ if (!domain->initialized) {
/* We do not need a connection to an RW DC for cache operation */
init_dc_connection(domain, false);
}
- /*
- OK. Listen up because I'm only going to say this once.
- We have the following scenarios to consider
- (a) trusted AD domains on a Samba DC,
- (b) trusted AD domains and we are joined to a non-kerberos domain
- (c) trusted AD domains and we are joined to a kerberos (AD) domain
-
- For (a) we can always contact the trusted domain using krb5
- since we have the domain trust account password
-
- For (b) we can only use RPC since we have no way of
- getting a krb5 ticket in our own domain
-
- For (c) we can always use krb5 since we have a kerberos trust
-
- --jerry
- */
-
- if (!domain->backend) {
#ifdef HAVE_ADS
+ if (domain->backend == NULL) {
struct winbindd_domain *our_domain = domain;
- /* find our domain first so we can figure out if we
+ /* find our domain first so we can figure out if we
are joined to a kerberized domain */
- if ( !domain->primary )
+ if (!domain->primary) {
our_domain = find_our_domain();
+ }
if ((our_domain->active_directory || IS_DC)
&& domain->active_directory
- && !lp_winbind_rpc_only()) {
- DEBUG(5,("get_cache: Setting ADS methods for domain %s\n", domain->name));
+ && !lp_winbind_rpc_only())
+ {
+ DBG_INFO("Setting ADS methods for domain %s\n",
+ domain->name);
domain->backend = &reconnect_ads_methods;
- } else {
-#endif /* HAVE_ADS */
- DEBUG(5,("get_cache: Setting MS-RPC methods for domain %s\n", domain->name));
- domain->backend = &reconnect_methods;
-#ifdef HAVE_ADS
}
+ }
#endif /* HAVE_ADS */
+
+ if (domain->backend == NULL) {
+ DBG_INFO("Setting MS-RPC methods for domain %s\n", domain->name);
+ domain->backend = &reconnect_methods;
}
- if (ret)
+ if (ret != NULL) {
return ret;
+ }
ret = SMB_XMALLOC_P(struct winbind_cache);
ZERO_STRUCTP(ret);
NTSTATUS wcache_cached_creds_exist(struct winbindd_domain *domain, const struct dom_sid *sid)
{
struct winbind_cache *cache = get_cache(domain);
- TDB_DATA data;
+ int ret;
fstring key_str, tmp;
uint32_t rid;
fstr_sprintf(key_str, "CRED/%s", sid_to_fstring(tmp, sid));
- data = tdb_fetch(cache->tdb, string_tdb_data(key_str));
- if (!data.dptr) {
+ ret = tdb_exists(cache->tdb, string_tdb_data(key_str));
+ if (ret != 0) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
- SAFE_FREE(data.dptr);
return NT_STATUS_OK;
}
return status;
}
-NTSTATUS wcache_name_to_sid(struct winbindd_domain *domain,
- const char *domain_name,
- const char *name,
- struct dom_sid *sid,
- enum lsa_SidType *type)
+static NTSTATUS wcache_name_to_sid(struct winbindd_domain *domain,
+ const char *domain_name,
+ const char *name,
+ struct dom_sid *sid,
+ enum lsa_SidType *type)
{
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry;
return result;
}
-NTSTATUS wcache_query_user(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- const struct dom_sid *user_sid,
- struct wbint_userinfo *info)
+static NTSTATUS wcache_query_user(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *user_sid,
+ struct wbint_userinfo *info)
{
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
return NT_STATUS_OK;
}
-NTSTATUS wcache_lookup_usergroups(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- const struct dom_sid *user_sid,
- uint32_t *pnum_sids,
- struct dom_sid **psids)
+static NTSTATUS wcache_lookup_usergroups(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *user_sid,
+ uint32_t *pnum_sids,
+ struct dom_sid **psids)
{
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
return sidlist;
}
-NTSTATUS wcache_lookup_useraliases(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx, uint32_t num_sids,
- const struct dom_sid *sids,
- uint32_t *pnum_aliases, uint32_t **paliases)
+static NTSTATUS wcache_lookup_useraliases(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ uint32_t num_sids,
+ const struct dom_sid *sids,
+ uint32_t *pnum_aliases,
+ uint32_t **paliases)
{
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
- uint32_t num_aliases;
+ uint32_t i, num_aliases;
uint32_t *aliases;
NTSTATUS status;
char *sidlist;
- int i;
if (cache->tdb == NULL) {
return NT_STATUS_NOT_FOUND;
struct cache_entry *centry = NULL;
NTSTATUS status;
char *sidlist;
- int i;
+ uint32_t i;
bool old_status;
old_status = domain->online;
return status;
}
-NTSTATUS wcache_lookup_groupmem(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- const struct dom_sid *group_sid,
- uint32_t *num_names,
- struct dom_sid **sid_mem, char ***names,
- uint32_t **name_types)
+static NTSTATUS wcache_lookup_groupmem(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ const struct dom_sid *group_sid,
+ uint32_t *num_names,
+ struct dom_sid **sid_mem, char ***names,
+ uint32_t **name_types)
{
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
struct winbindd_tdc_domain *dom_list = NULL;
size_t num_domains = 0;
bool retval = false;
- int i;
+ size_t i;
bool old_status;
old_status = domain->online;
return true;
}
-bool init_wcache(void)
+static bool init_wcache(void)
{
char *db_path;
}
/* flush the cache */
-void wcache_flush_cache(void)
+static void wcache_flush_cache(void)
{
char *db_path;
size_t *num_domains )
{
struct winbindd_tdc_domain *list = NULL;
- size_t idx;
- int i;
+ size_t i, idx;
bool set_only = false;
/* don't allow duplicates */
unsigned char *buffer = NULL;
int len = 0;
int buflen = 0;
- int i = 0;
+ size_t i = 0;
DEBUG(10,("pack_tdc_domains: Packing %d trusted domains\n",
(int)num_domains));
{
struct winbindd_tdc_domain *dom_list = NULL;
size_t num_domains = 0;
- int i;
+ size_t i;
struct winbindd_tdc_domain *d = NULL;
DEBUG(10,("wcache_tdc_fetch_domain: Searching for domain %s\n", name));
goto fail;
}
- if (!is_domain_offline(domain)) {
+ if (is_domain_online(domain)) {
uint32_t entry_seqnum, dom_seqnum, last_check;
uint64_t entry_timeout;