summaryrefslogtreecommitdiff
path: root/source3/winbindd/winbindd_cache.c
AgeCommit message (Collapse)AuthorFilesLines
2026-02-25winbindd: Simplify wcache_make_sidlist()Volker Lendecke1-10/+3
Rely on talloc_asprintf_addbuf's NULL checks Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2025-12-08s3-winbindd: make sure we always have WINBINDD_CACHE_VERSION in ↵Günther Deschner1-0/+7
winbindd_cache.tdb Guenther BUG: https://bugzilla.samba.org/show_bug.cgi?id=15963 Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Mon Dec 8 09:59:58 UTC 2025 on atb-devel-224
2025-12-08s3-winbindd: provide one wcache_open() function for all tdb opensGünther Deschner1-35/+27
Guenther BUG: https://bugzilla.samba.org/show_bug.cgi?id=15963 Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2025-12-08s3-winbindd: make initialize_winbindd_cache() staticGünther Deschner1-1/+1
Guenther BUG: https://bugzilla.samba.org/show_bug.cgi?id=15963 Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2025-12-08s3-winbind: make wcache_store_seqnum staticGünther Deschner1-2/+2
Guenther BUG: https://bugzilla.samba.org/show_bug.cgi?id=15963 Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2025-12-08s3-winbindd: Fix winbind NDR caching.Günther Deschner1-0/+7
All of winbindd's core caching relies on NDR entries. Those entries can not be stored in winbindd_cache.tdb via wcache_store_ndr() as long as there is no SEQNUM entry present in the cache. Guenther BUG: https://bugzilla.samba.org/show_bug.cgi?id=15963 Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2025-11-10s3: talloc_destroy() -> TALLOC_FREE()Volker Lendecke1-1/+1
Sweeping change, I know. Should not change compiled code in most cases, the compiler should be smart enough to elide the assignment right before a return. In the cases where this is not right before the return, TALLOC_FREE() is safer as it makes use-after-free crash. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2025-09-10winbindd: Fixing CID 1508950 for time_t in DEBUG statementRabinarayan Panigrahi1-4/+4
Fix: typecast changing from (uint32_t)domain->last_seq_check to (intmax_t)domain->last_seq_check as intmax_t can hold epoch seconds after 2038 year Signed-off-by: Rabinarayan Panigrahi <rapanigr@redhat.com> Reviewed-by: Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Andreas Schneider <asn@samba.org>
2025-08-26winbindd: CID 1508963 Fixing print statement for time_tRabinarayan Panigrahi1-2/+2
Fixing DEBUG output for time_t to uintmax_t Signed-off-by: Rabinarayan Panigrahi <rapanigr@redhat.com> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Vinit Agnihotri <vagnihot@redhat.com> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Tue Aug 26 15:40:41 UTC 2025 on atb-devel-224
2025-05-15lib: Save lines by avoiding explicit ZERO_STRUCTP callsVolker Lendecke1-3/+1
SMB_CALLOC_ARRAY(..., 1) does this. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-07-26winbindd: let LookupNames return NT_STATUS_OK and SID_NAME_UNKNOWN for ↵Ralph Boehme1-13/+3
unmapped names Previously LookupNames would fail if a name could not be translated, so winbindd clients like libwbclient couldn't differentiate between not being able to talk to a DC and just an unkown name. As a visible change this alters $ bin/wbinfo -n Idontexist failed to call wbcLookupName: WBC_ERR_DOMAIN_NOT_FOUND Could not lookup name Idontexist to $ bin/wbinfo -n Idontexist failed to call wbcLookupName: WBC_ERR_SOME_NOT_MAPPED Could not lookup name Idontexist Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-07-26winbindd: properly initialize sid and type in wb_cache_name_to_sid()Ralph Boehme1-2/+3
No change in behaviour. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-07-26winbindd: collapse two if expressionsRalph Boehme1-7/+6
No change in behaviour. After calling set_domain_offline() domain->offline will be set to false, iow everytime if (!domain->internal && was_online) is true, if (!domain->internal && !domain->online && was_online) will also true, so we can drop the second if expression. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-07-26winbindd: reformattingRalph Boehme1-1/+2
No change in behaviour. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-07-26winbindd: rename variable old_status to was_online in wb_cache_name_to_sid()Ralph Boehme1-4/+4
A lot easier to make sense of the complex logic when using this name. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-06-30s3:winbind: Fix integer type of lenAndreas Schneider1-2/+3
"Error: INTEGER_OVERFLOW (CWE-190): samba-4.20.0rc2/source3/winbindd/winbindd_cache.c:849: cast_overflow: Truncation due to cast operation on ""len"" from 32 to 8 bits. samba-4.20.0rc2/source3/winbindd/winbindd_cache.c:851: overflow_sink: ""len"", which might have overflowed, is passed to ""memcpy(centry->data + centry->ofs, s, len)"". [Note: The source code implementation of the function has been overridden by a builtin model.] 849| centry_put_uint8(centry, len); 850| centry_expand(centry, len); 851|-> memcpy(centry->data + centry->ofs, s, len); 852| centry->ofs += len; 853| }" Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2024-05-14s3:winbindd: Update non cache entries keys (non_centry_keys)Pavel Filipenský1-0/+2
This change does NOT affect WHAT and HOW is cached. It only avoids undefined behavior for "NDR" and "TRUSTDOMCACHE" when processed in wcache_flush_cache() and wbcache_upgrade_v1_to_v2(). winbindd_cache.tdb contains two types of entries: 1) cache entries (typed as 'struct cache_entry') - internal format is: [ntstatus; sequence_number; timeout] 2) non cache entries (keys listed in non_centry_keys) - for "NDR" internal format is: [sequence_number; timeout] Without this commit, "NDR" would be processed as the first type (instead as the second type). E.g. in the stack below: wcache_fetch_raw() traverse_fn_cleanup() wcache_flush_cache() the triplet [ntstatus; sequence_number; timeout] would be initialized from data containing only [sequence_number; timeout], leading to mismatched values ('ntstatus' would be filled from 'sequence_number'). Anyway, current code is never calling wcache_flush_cache(), since wcache_flush_cache() can be called only from get_cache() and get_cache() will call it only if global/static wcache was not set yet. But wcache is set very early in the main winbind (and all winbind children get it after fork), sooner than any call of get_cache() can happen: #1 init_wcache + 0x19 #2 initialize_winbindd_cache + 0x35 #3 winbindd_cache_validate_and_initialize + 0x25 #4 main + 0x806 Signed-off-by: Pavel Filipenský <pfilipensky@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue May 14 21:04:57 UTC 2024 on atb-devel-224
2024-05-14s3:winbindd: Use TDB_REPLACE in tdb_storePavel Filipenský1-2/+2
tdb_store() should use as a flag TDB_REPLACE instead of undocumented 0 Signed-off-by: Pavel Filipenský <pfilipensky@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2023-08-08s3:winbindd: Add missing newlines to logging messagesJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-07-19s3:winbindd: Fix code spellingAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-07-05s3:winbindd: call reset_cm_connection_on_error() in wb_cache_query_user_list()Stefan Metzmacher1-0/+1
This is mostly for consistency, every remote call should call reset_cm_connection_on_error(). Note this is more than a simple invalidate_cm_connection() as it may set domain->conn.netlogon_force_reauth = true. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15413 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2023-07-02winbindd_cache.c: use DBG* macros instead of static log level numbersBjörn Jacke1-211/+212
Some log levels changed slightly because the macros don't cover all the previously used levels. Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-07-02winbindd_cache.c: move some some notice messages from ERR to NOTICE levelBjörn Jacke1-2/+2
Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-07-02winbindd_cache: adjust some debug levels to more appropriate severitiesBjörn Jacke1-5/+5
Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-13s3:winbind: Add wbint_LookupAliasMembers to winbind interfacePavel Filipenský1-0/+124
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2023-06-13s3:winbind: Fix trailing whitespace in winbindd_cache.cPavel Filipenský1-82/+82
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2022-04-08s3:winbind: Move function to flush cache to winbindd-lib subsystemSamuel Cabrero1-0/+14
The source3/winbindd/winbindd.c file does not belong to 'winbindd-lib' subsystem. Funtions called from winbindd-lib must be part of it. Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-04-08s3:winbind: Move functions to enable or disable cache to winbindd-lib subsystemSamuel Cabrero1-0/+17
The source3/winbindd/winbindd.c file does not belong to 'winbindd-lib' subsystem. Funtions called from winbindd-lib must be part of it. Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-03-25s3:winbind: Convert wcache_opnum_cacheable() to a whitelistSamuel Cabrero1-9/+15
It avoids having to explicitly blacklist new DCE/RPC calls. This is the current list of non cacheable calls: NDR_WBINT_PING NDR_WBINT_QUERYSEQUENCENUMBER NDR_WBINT_ALLOCATEUID NDR_WBINT_ALLOCATEGID NDR_WBINT_CHECKMACHINEACCOUNT NDR_WBINT_CHANGEMACHINEACCOUNT NDR_WBINT_PINGDC NDR_WBINT_LISTTRUSTEDDOMAINS It includes the ListTrustedDomains call recently converted to a local RPC call. Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2022-02-09s3:winbind: Reduce the level and improve a couple of debug messagesSamuel Cabrero1-2/+4
The commit 1d5c546 changed the debug message printed when setting winbind to offline state and offline logons are disabled from level 10 to level 0. This message isn't really an error and might scare some users, e.g. https://bugzilla.suse.com/show_bug.cgi?id=1195573 Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Feb 9 20:20:36 UTC 2022 on sn-devel-184
2021-05-12s3:winbind: Code cleanup for initialize_winbindd_cache()Andreas Schneider1-5/+13
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-05-12s3:winbind: Remove global variable for winbindd_offline_stateAndreas Schneider1-32/+32
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-04-29s3:winbindd: Simplfy sequence number cachingAndreas Schneider1-124/+3
The sequence number is used to detect if the cache is still valid. It expires when the `winbind cache time` is over. After that time we want to fetch new information from a DC to make sure we are up to date. If a DC goes down and we recreate the connection, we want to expire the caches sooner. So we reset the sequence number and the next call should refill the caches. Using the current time as the sequence number is more reliable, as the sequence number of two DCs could in theory be equal. All we have to do is to make sure we reset it after we reconnect to a DC. Previously the sequence number check was based on the AD database change sequence number. Now this is based on a current time value which gets reset after a successful (re)connect. Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Andreas Schneider <asn@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2020-08-28s3: safe_string: do not include string_wrappers.hMatthew DeVore1-0/+1
Rather than have safe_string.h #include string_wrappers.h, make users of string_wrappers.h include it explicitly. includes.h now no longer includes string_wrappers.h transitively. Still allow includes.h to #include safe_string.h for now so that as many modules as possible get the safety checks in it. Signed-off-by: Matthew DeVore <matvore@google.com> Reviewed-by: David Mulder <dmulder@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-12-02winbind: Use vasprintf() in winbindd_cacheVolker Lendecke1-3/+18
Don't need to panic, we can do explicit checks in these few callers Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martins@samba.org>
2019-11-19winbind: Fix CID 1455915 Resource leakVolker Lendecke1-0/+3
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2019-11-19s3:winbindd: Replace E_md5hash() with GnuTLS callsAndreas Schneider1-1/+22
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14195 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-06-04s3/winbdind: cppcheck: fix nullPointerArithmetic errorNoel Power1-2/+4
Fixes source3/winbindd/winbindd_cache.c:4386: error: nullPointerArithmetic: Pointer addition with NULL pointer. <--[cppcheck] source3/winbindd/winbindd_cache.c:4400: error: nullPointerArithmetic: Pointer addition with NULL pointer. <--[cppcheck] source3/winbindd/winbindd_cache.c:1569:24: warning: Dereference of null pointer <--[clang] Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
2019-04-18winbind: Use domain name from lsa query for sid_to_name cache entryChristof Schmitt1-2/+3
When winbindd is asked to map a name like realm.com\name to a SID ,that is sucessfully resolved through the lsa lookup name call. The same call also returns the short domain name (netbios name of the domain). Use that short domain name for the sid_to_name cache entry, so that subsequent sid_to_name queries return the expected netbiosname\name result and not realm.com\name. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13831 Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2019-04-18winbind: Return queried domain name from name_to_sidChristof Schmitt1-1/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13831 Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2018-12-20winbindd: Use dom_sid_str_bufVolker Lendecke1-5/+5
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2018-12-07winbindd_cache: Use dom_sid_str_bufVolker Lendecke1-17/+21
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-11-09winbind: Use dom_sid_str_bufVolker Lendecke1-27/+27
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-11-09winbind: Use dom_sid_str_bufVolker Lendecke1-2/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-11-01s3: winbind: Remove fstring from wb_acct_info structSamuel Cabrero1-4/+4
The group enumeration backend functions try to allocate an array of wb_acct_info structs with a number of elements equal to the number of groups. In domains with a large number of groups this allocation may fail due to the size of the chunk. Found while trying to enumerate the groups in a domain with more than 700k groups. Signed-off-by: Samuel Cabrero <scabrero@suse.de> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-10-16namemap_cache: Absorb the expired calculation into namemap_cache.cVolker Lendecke1-5/+8
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-10-16winbindd_cache: Fix timeout calculation for sid<->name cacheVolker Lendecke1-2/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-08-17lib: Pass mem_ctx to state_path()Volker Lendecke1-1/+1
Fix a confusing API: Many places TALLOC_FREE the path where it's not clear you have to do it. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2018-06-16winbindd: Use is_domain_offline() where appropriateVolker Lendecke1-2/+2
That if-condition is precisely covered by the helper routine Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-05-11winbind: Fix UPN handling in parse_domain_user()Andreas Schneider1-2/+3
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13369 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Andreas Schneider <asn@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>