diff options
author | Andreas Schneider <asn@samba.org> | 2011-08-19 17:36:53 +0200 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2011-08-21 09:08:25 -0400 |
commit | 1152aa8e0354ed2446397725b75e905bef3c4afb (patch) | |
tree | 7cc257f9e159257c869eb226d3f61ea0d9a2bc8d /source3/passdb | |
parent | 61ada700a6ad010846b132d866c66220e6379054 (diff) | |
download | samba-1152aa8e0354ed2446397725b75e905bef3c4afb.tar.gz samba-1152aa8e0354ed2446397725b75e905bef3c4afb.tar.bz2 samba-1152aa8e0354ed2446397725b75e905bef3c4afb.zip |
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 <idra@samba.org>
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/pdb_interface.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index 738b12fc27..301fda6ffe 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -24,6 +24,7 @@ #include "system/passwd.h" #include "passdb.h" #include "secrets.h" +#include "messages.h" #include "../librpc/gen_ndr/samr.h" #include "../librpc/gen_ndr/drsblobs.h" #include "../librpc/gen_ndr/ndr_drsblobs.h" @@ -608,6 +609,8 @@ NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, struct samu *sam_acct) { struct pdb_methods *pdb = pdb_get_methods(); uid_t uid = -1; + NTSTATUS status; + char *msg_data; /* sanity check to make sure we don't delete root */ @@ -619,7 +622,26 @@ NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, struct samu *sam_acct) return NT_STATUS_ACCESS_DENIED; } - return pdb->delete_user(pdb, mem_ctx, sam_acct); + status = pdb->delete_user(pdb, mem_ctx, sam_acct); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + msg_data = talloc_asprintf(mem_ctx, "USER %s", + pdb_get_username(sam_acct)); + if (!msg_data) { + /* not fatal, and too late to rollback, + * just return */ + return status; + } + message_send_all(server_messaging_context(), + ID_CACHE_DELETE, + msg_data, + strlen(msg_data) + 1, + NULL); + + TALLOC_FREE(msg_data); + return status; } NTSTATUS pdb_add_sam_account(struct samu *sam_acct) |