From eb4ef94f244d28fe531d0b9f724a66ed3834b687 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 3 Mar 2005 16:52:44 +0000 Subject: [PATCH] r5647: Caches are good for performance, but you get a consistency problem. Fix bug # 2401. Volker --- source/auth/auth_util.c | 1 + source/groupdb/mapping.c | 2 ++ source/lib/util_pw.c | 14 ++++++++++++++ source/rpc_server/srv_samr_nt.c | 2 ++ 4 files changed, 19 insertions(+) diff --git a/source/auth/auth_util.c b/source/auth/auth_util.c index f3c01a58ca6..7cab3df99e4 100644 --- a/source/auth/auth_util.c +++ b/source/auth/auth_util.c @@ -50,6 +50,7 @@ static int smb_create_user(const char *domain, const char *unix_username, const if (homedir) all_string_sub(add_script, "%H", homedir, sizeof(pstring)); ret = smbrun(add_script,NULL); + flush_pwnam_cache(); DEBUG(ret ? 0 : 3,("smb_create_user: Running the command `%s' gave %d\n",add_script,ret)); return ret; } diff --git a/source/groupdb/mapping.c b/source/groupdb/mapping.c index 1c29cc77c42..5613240a121 100644 --- a/source/groupdb/mapping.c +++ b/source/groupdb/mapping.c @@ -1050,6 +1050,7 @@ int smb_set_primary_group(const char *unix_group, const char* unix_user) all_string_sub(add_script, "%g", unix_group, sizeof(add_script)); all_string_sub(add_script, "%u", unix_user, sizeof(add_script)); ret = smbrun(add_script,NULL); + flush_pwnam_cache(); DEBUG(ret ? 0 : 3,("smb_set_primary_group: " "Running the command `%s' gave %d\n",add_script,ret)); return ret; @@ -1060,6 +1061,7 @@ int smb_set_primary_group(const char *unix_group, const char* unix_user) if ( winbind_set_user_primary_group( unix_user, unix_group ) ) { DEBUG(3,("smb_delete_group: winbindd set the group (%s) as the primary group for user (%s)\n", unix_group, unix_user)); + flush_pwnam_cache(); return 0; } diff --git a/source/lib/util_pw.c b/source/lib/util_pw.c index 0d7ffe09e9b..13349bad34e 100644 --- a/source/lib/util_pw.c +++ b/source/lib/util_pw.c @@ -70,6 +70,20 @@ static void init_pwnam_cache(void) return; } +void flush_pwnam_cache(void) +{ + int i; + + init_pwnam_cache(); + + for (i=0; i