From 1152aa8e0354ed2446397725b75e905bef3c4afb Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 19 Aug 2011 17:36:53 +0200 Subject: s3-passdb: Keep caches coherent When deleting a user send a message to all interested parties so they can purge their caches. Otherwise some processes may positively respond with a cached getpwnam, when the user have actully been removed. Without this some tests that remove and then immediately create users are flakey. Signed-off-by: Simo Sorce --- source3/lib/id_cache.c | 15 +++++++++++++++ source3/lib/id_cache.h | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/id_cache.c b/source3/lib/id_cache.c index f78064ea31..71693c1464 100644 --- a/source3/lib/id_cache.c +++ b/source3/lib/id_cache.c @@ -56,6 +56,10 @@ bool id_cache_ref_parse(const char* str, struct id_cache_ref* id) id->id.sid = sid; id->type = SID; return true; + } else if (strncmp(str, "USER ", 5) == 0) { + id->id.name = str + 5; + id->type = USERNAME; + return true; } return false; } @@ -112,6 +116,15 @@ static bool delete_sid_cache(const struct dom_sid* psid) return true; } +static bool delete_getpwnam_cache(const char *username) +{ + DATA_BLOB name = data_blob_string_const_null(username); + DEBUG(6, ("Delete passwd struct for %s from memcache\n", + username)); + memcache_delete(NULL, GETPWNAM_CACHE, name); + return true; +} + static void flush_gid_cache(void) { DEBUG(3, ("Flush GID <-> SID memcache\n")); @@ -140,6 +153,8 @@ static void delete_from_cache(const struct id_cache_ref* id) delete_sid_cache(&id->id.sid); idmap_cache_del_sid(&id->id.sid); break; + case USERNAME: + delete_getpwnam_cache(id->id.name); default: break; } diff --git a/source3/lib/id_cache.h b/source3/lib/id_cache.h index 9aa0e03586..208ce60e96 100644 --- a/source3/lib/id_cache.h +++ b/source3/lib/id_cache.h @@ -24,7 +24,7 @@ struct id_cache_ref { struct dom_sid sid; const char *name; } id; - enum {UID, GID, SID, NAME} type; + enum {UID, GID, SID, USERNAME} type; }; bool id_cache_ref_parse(const char* str, struct id_cache_ref* id); -- cgit