From f85e095dd29638dcb4819f60a7239bc37e8a41ca Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 May 2011 14:36:55 -0700 Subject: More simple const fixups. --- source3/winbindd/winbindd_cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index 68a86257da..4fa2375152 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -1856,8 +1856,8 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain, /* Only save the reverse mapping if this was not a UPN */ if (!strchr(name, '@')) { - strupper_m(CONST_DISCARD(char *,domain_name)); - strlower_m(CONST_DISCARD(char *,name)); + strupper_m(discard_const_p(char, domain_name)); + strlower_m(discard_const_p(char, name)); wcache_save_sid_to_name(domain, status, sid, domain_name, name, *type); } } -- cgit From d8cfca3a9bd2b6b6c562fd202377d95a98eb5472 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 5 May 2011 11:25:29 +0200 Subject: s3: only include tdb headers where needed. Guenther --- source3/winbindd/winbindd_cache.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index 4fa2375152..d733be0672 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -33,6 +33,7 @@ #include "nss_info.h" #include "../libcli/security/security.h" #include "passdb/machine_sid.h" +#include "util_tdb.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND -- cgit From ae6a779bf9f816680e724ede37324b7f5355996b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 8 Jun 2011 12:56:10 +0200 Subject: s3-winbindd: make sure we obey the -n switch also for samlogon cache access. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Guenther Autobuild-User: Günther Deschner Autobuild-Date: Wed Jun 8 14:44:31 CEST 2011 on sn-devel-104 --- source3/winbindd/winbindd_cache.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index d733be0672..50da98f62c 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -1296,6 +1296,10 @@ NTSTATUS wcache_get_creds(struct winbindd_domain *domain, uint32 rid; fstring tmp; + if (!winbindd_use_cache()) { + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + if (!cache->tdb) { return NT_STATUS_INTERNAL_DB_ERROR; } -- cgit From 73b377432c5efb8451f09f6d25d8aa1b28c239c9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Jun 2011 11:10:15 +1000 Subject: s3-talloc Change TALLOC_REALLOC_ARRAY() to talloc_realloc() Using the standard macro makes it easier to move code into common, as TALLOC_REALLOC_ARRAY isn't standard talloc. Andrew Bartlett --- source3/winbindd/winbindd_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index 50da98f62c..e1bacedaa4 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -4206,7 +4206,7 @@ static bool add_wbdomain_to_tdc_array( struct winbindd_domain *new_dom, list = TALLOC_ARRAY( NULL, struct winbindd_tdc_domain, 1 ); idx = 0; } else { - list = TALLOC_REALLOC_ARRAY( *domains, *domains, + list = talloc_realloc( *domains, *domains, struct winbindd_tdc_domain, (*num_domains)+1); idx = *num_domains; -- cgit From 3d15137653a7d1b593a9af2eef12f6e5b9a04c4f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Jun 2011 11:30:12 +1000 Subject: s3-talloc Change TALLOC_ARRAY() to talloc_array() Using the standard macro makes it easier to move code into common, as TALLOC_ARRAY isn't standard talloc. --- source3/winbindd/winbindd_cache.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index e1bacedaa4..a1f5ac69b5 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -309,7 +309,7 @@ static char *centry_string(struct cache_entry *centry, TALLOC_CTX *mem_ctx) smb_panic_fn("centry_string"); } - ret = TALLOC_ARRAY(mem_ctx, char, len+1); + ret = talloc_array(mem_ctx, char, len+1); if (!ret) { smb_panic_fn("centry_string out of memory\n"); } @@ -339,7 +339,7 @@ static char *centry_hash16(struct cache_entry *centry, TALLOC_CTX *mem_ctx) return NULL; } - ret = TALLOC_ARRAY(mem_ctx, char, 16); + ret = talloc_array(mem_ctx, char, 16); if (!ret) { smb_panic_fn("centry_hash out of memory\n"); } @@ -1436,7 +1436,7 @@ do_fetch_cache: if (*num_entries == 0) goto do_cached; - (*info) = TALLOC_ARRAY(mem_ctx, struct wbint_userinfo, *num_entries); + (*info) = talloc_array(mem_ctx, struct wbint_userinfo, *num_entries); if (! (*info)) { smb_panic_fn("query_user_list out of memory"); } @@ -1588,7 +1588,7 @@ do_fetch_cache: if (*num_entries == 0) goto do_cached; - (*info) = TALLOC_ARRAY(mem_ctx, struct wb_acct_info, *num_entries); + (*info) = talloc_array(mem_ctx, struct wb_acct_info, *num_entries); if (! (*info)) { smb_panic_fn("enum_dom_groups out of memory"); } @@ -1683,7 +1683,7 @@ do_fetch_cache: if (*num_entries == 0) goto do_cached; - (*info) = TALLOC_ARRAY(mem_ctx, struct wb_acct_info, *num_entries); + (*info) = talloc_array(mem_ctx, struct wb_acct_info, *num_entries); if (! (*info)) { smb_panic_fn("enum_dom_groups out of memory"); } @@ -2006,8 +2006,8 @@ static NTSTATUS rids_to_names(struct winbindd_domain *domain, return NT_STATUS_OK; } - *names = TALLOC_ARRAY(mem_ctx, char *, num_rids); - *types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_rids); + *names = talloc_array(mem_ctx, char *, num_rids); + *types = talloc_array(mem_ctx, enum lsa_SidType, num_rids); if ((*names == NULL) || (*types == NULL)) { result = NT_STATUS_NO_MEMORY; @@ -4203,7 +4203,7 @@ static bool add_wbdomain_to_tdc_array( struct winbindd_domain *new_dom, if ( !set_only ) { if ( !*domains ) { - list = TALLOC_ARRAY( NULL, struct winbindd_tdc_domain, 1 ); + list = talloc_array( NULL, struct winbindd_tdc_domain, 1 ); idx = 0; } else { list = talloc_realloc( *domains, *domains, @@ -4346,7 +4346,7 @@ static size_t unpack_tdc_domains( unsigned char *buf, int buflen, return 0; } - list = TALLOC_ARRAY( NULL, struct winbindd_tdc_domain, num_domains ); + list = talloc_array( NULL, struct winbindd_tdc_domain, num_domains ); if ( !list ) { DEBUG(0,("unpack_tdc_domains: Failed to talloc() domain list!\n")); return 0; -- cgit From d5e6a47f064a3923b1e257ab84fa7ccd7c4f89f4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Jun 2011 11:38:41 +1000 Subject: s3-talloc Change TALLOC_P() to talloc() Using the standard macro makes it easier to move code into common, as TALLOC_P isn't standard talloc. --- source3/winbindd/winbindd_cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index a1f5ac69b5..05261b70b0 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -4527,7 +4527,7 @@ struct winbindd_tdc_domain * wcache_tdc_fetch_domain( TALLOC_CTX *ctx, const cha DEBUG(10,("wcache_tdc_fetch_domain: Found domain %s\n", name)); - d = TALLOC_P( ctx, struct winbindd_tdc_domain ); + d = talloc( ctx, struct winbindd_tdc_domain ); if ( !d ) break; @@ -4577,7 +4577,7 @@ struct winbindd_tdc_domain* dom_list[i].domain_name, sid_string_dbg(sid))); - d = TALLOC_P(ctx, struct winbindd_tdc_domain); + d = talloc(ctx, struct winbindd_tdc_domain); if (!d) break; -- cgit From 5e26e94092b56ee47e7ec7837f7cd0feb3fb0119 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Jun 2011 11:58:39 +1000 Subject: s3-talloc Change TALLOC_ZERO_ARRAY() to talloc_zero_array() Using the standard macro makes it easier to move code into common, as TALLOC_ZERO_ARRAY isn't standard talloc. --- source3/winbindd/winbindd_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index 05261b70b0..1c4f5bd701 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -2774,7 +2774,7 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain, } do_fetch_cache: - trusts->array = TALLOC_ZERO_ARRAY(mem_ctx, struct netr_DomainTrust, num_domains); + trusts->array = talloc_zero_array(mem_ctx, struct netr_DomainTrust, num_domains); if (!trusts->array) { TALLOC_FREE(dom_list); return NT_STATUS_NO_MEMORY; -- cgit From 058c4f84924c07b88ccaf3d617f3abff797a7cc8 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 18:40:31 +0930 Subject: tdb_fetch_compat: use instead of tdb_fetch. This is a noop for tdb1. Signed-off-by: Rusty Russell --- source3/winbindd/winbindd_cache.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index 1c4f5bd701..daea4e866a 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -638,7 +638,7 @@ static struct cache_entry *wcache_fetch_raw(char *kstr) TDB_DATA key; key = string_tdb_data(kstr); - data = tdb_fetch(wcache->tdb, key); + data = tdb_fetch_compat(wcache->tdb, key); if (!data.dptr) { /* a cache miss */ return NULL; @@ -1271,7 +1271,7 @@ NTSTATUS wcache_cached_creds_exist(struct winbindd_domain *domain, const struct fstr_sprintf(key_str, "CRED/%s", sid_to_fstring(tmp, sid)); - data = tdb_fetch(cache->tdb, string_tdb_data(key_str)); + data = tdb_fetch_compat(cache->tdb, string_tdb_data(key_str)); if (!data.dptr) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -3394,7 +3394,7 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const TDB_DATA data; time_t t; - data = tdb_fetch(cache->tdb, string_tdb_data(cred->name)); + data = tdb_fetch_compat(cache->tdb, string_tdb_data(cred->name)); if (!data.dptr) { DEBUG(10,("wcache_remove_oldest_cached_creds: entry for [%s] not found\n", cred->name)); @@ -4437,7 +4437,7 @@ bool wcache_tdc_fetch_list( struct winbindd_tdc_domain **domains, size_t *num_do if ( !key.dptr ) return false; - data = tdb_fetch( wcache->tdb, key ); + data = tdb_fetch_compat( wcache->tdb, key ); SAFE_FREE( key.dptr ); @@ -4782,7 +4782,7 @@ bool wcache_fetch_ndr(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain, if (!wcache_ndr_key(talloc_tos(), domain->name, opnum, req, &key)) { return false; } - data = tdb_fetch(wcache->tdb, key); + data = tdb_fetch_compat(wcache->tdb, key); TALLOC_FREE(key.dptr); if (data.dptr == NULL) { -- cgit From 1078eb21c49d707ddeef2257353f35c10d131b9f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 18:40:31 +0930 Subject: tdb_delete: check returns for 0, not -1. TDB2 returns a negative error number on failure. This is compatible if we always check for != 0 instead of == -1. Signed-off-by: Rusty Russell --- source3/winbindd/winbindd_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index daea4e866a..c45aabc902 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -4420,7 +4420,7 @@ static bool wcache_tdc_store_list( struct winbindd_tdc_domain *domains, size_t n SAFE_FREE( data.dptr ); SAFE_FREE( key.dptr ); - return ( ret != -1 ); + return ( ret == 0 ); } /********************************************************************* -- cgit From 5a7874e119acbc80410b2f2c1847371236c22a56 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 18:40:31 +0930 Subject: tdb_traverse/tdb_traverse_read: check returns for negative, not -1. TDB2 returns a negative error number on failure. This is compatible if we always check for < 0 instead of == -1. Also, there's no tdb_traverse_read in TDB2: we don't try to make traverse reliable any more, so there are no write locks anyway. Signed-off-by: Rusty Russell --- source3/winbindd/winbindd_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index c45aabc902..b8028b1674 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -3383,7 +3383,7 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const ret = tdb_traverse(cache->tdb, traverse_fn_get_credlist, NULL); if (ret == 0) { return NT_STATUS_OK; - } else if ((ret == -1) || (wcache_cred_list == NULL)) { + } else if ((ret < 0) || (wcache_cred_list == NULL)) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } -- cgit From 58f7cda1bc6b7767c318a038bdb686f4e59e2e64 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 18:40:32 +0930 Subject: tdb_compat: use tdb_errorstr_compat() Since TDB2 functions return the error directly, tdb_errorstr() taken an error code, not the tdb as it does in TDB1. Signed-off-by: Rusty Russell --- source3/winbindd/winbindd_cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index b8028b1674..50218d0132 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -486,7 +486,7 @@ bool wcache_store_seqnum(const char *domain_name, uint32_t seqnum, TALLOC_FREE(key_str); if (ret == -1) { DEBUG(10, ("tdb_store_bystring failed: %s\n", - tdb_errorstr(wcache->tdb))); + tdb_errorstr_compat(wcache->tdb))); TALLOC_FREE(key_str); return false; } @@ -3165,7 +3165,7 @@ bool initialize_winbindd_cache(void) /* Write the version. */ if (!tdb_store_uint32(wcache->tdb, WINBINDD_CACHE_VERSION_KEYSTR, WINBINDD_CACHE_VERSION)) { DEBUG(0,("initialize_winbindd_cache: version number store failed %s\n", - tdb_errorstr(wcache->tdb) )); + tdb_errorstr_compat(wcache->tdb) )); return false; } } -- cgit From d925b327f4703cc141c0a7f3eec912dba8440880 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 18:40:33 +0930 Subject: tdb_compat: Higher level API fixes. My previous patches fixed up all direct TDB callers, but there are a few utility functions and the db_context functions which are still using the old -1 / 0 return codes. It's clearer to fix up all the callers of these too, so everywhere is consistent: non-zero means an error. Signed-off-by: Rusty Russell --- source3/winbindd/winbindd_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index 50218d0132..58a8e710f6 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -484,7 +484,7 @@ bool wcache_store_seqnum(const char *domain_name, uint32_t seqnum, ret = tdb_store_bystring(wcache->tdb, key_str, make_tdb_data(buf, sizeof(buf)), TDB_REPLACE); TALLOC_FREE(key_str); - if (ret == -1) { + if (ret != 0) { DEBUG(10, ("tdb_store_bystring failed: %s\n", tdb_errorstr_compat(wcache->tdb))); TALLOC_FREE(key_str); -- cgit