s3: add functions to remove entries from idmap memcache
authorGregor Beck <gbeck@sernet.de>
Fri, 18 Feb 2011 13:45:14 +0000 (14:45 +0100)
committerMichael Adam <obnox@samba.org>
Mon, 28 Feb 2011 13:23:33 +0000 (14:23 +0100)
source3/include/proto.h
source3/passdb/lookup_sid.c

index a508252fff95a8a68a8bc1c86027f7bbe73ba2b2..050e4d64b1dfdc2d2901ca08994e4b408841f8ed 100644 (file)
@@ -3638,6 +3638,9 @@ NTSTATUS get_primary_group_sid(TALLOC_CTX *mem_ctx,
                                const char *username,
                                struct passwd **_pwd,
                                struct dom_sid **_group_sid);
+bool delete_uid_cache(uid_t uid);
+bool delete_gid_cache(gid_t gid);
+bool delete_sid_cache(const struct dom_sid* psid);
 void flush_uid_cache(void);
 void flush_gid_cache(void);
 
index f16af0636d864a442e5c5c8752954a46cbfb6695..1dbbbd65365fb65e0934f786760188f44d83d707 100644 (file)
@@ -1643,6 +1643,58 @@ done:
        return NT_STATUS_OK;
 }
 
+bool delete_uid_cache(uid_t puid)
+{
+       DATA_BLOB uid = data_blob_const(&puid, sizeof(puid));
+       DATA_BLOB sid;
+
+       if (!memcache_lookup(NULL, UID_SID_CACHE, uid, &sid)) {
+               DEBUG(3, ("UID %d is not memcached!\n", (int)puid));
+               return false;
+       }
+       DEBUG(3, ("Delete mapping UID %d <-> %s from memcache\n", (int)puid,
+                 sid_string_dbg((struct dom_sid*)sid.data)));
+       memcache_delete(NULL, SID_UID_CACHE, sid);
+       memcache_delete(NULL, UID_SID_CACHE, uid);
+       return true;
+}
+
+bool delete_gid_cache(gid_t pgid)
+{
+       DATA_BLOB gid = data_blob_const(&pgid, sizeof(pgid));
+       DATA_BLOB sid;
+       if (!memcache_lookup(NULL, GID_SID_CACHE, gid, &sid)) {
+               DEBUG(3, ("GID %d is not memcached!\n", (int)pgid));
+               return false;
+       }
+       DEBUG(3, ("Delete mapping GID %d <-> %s from memcache\n", (int)pgid,
+                 sid_string_dbg((struct dom_sid*)sid.data)));
+       memcache_delete(NULL, SID_GID_CACHE, sid);
+       memcache_delete(NULL, GID_SID_CACHE, gid);
+       return true;
+}
+
+bool delete_sid_cache(const struct dom_sid* psid)
+{
+       DATA_BLOB sid = data_blob_const(psid, ndr_size_dom_sid(psid, 0));
+       DATA_BLOB id;
+       if (memcache_lookup(NULL, SID_GID_CACHE, sid, &id)) {
+               DEBUG(3, ("Delete mapping %s <-> GID %d from memcache\n",
+                         sid_string_dbg(psid), *(int*)id.data));
+               memcache_delete(NULL, SID_GID_CACHE, sid);
+               memcache_delete(NULL, GID_SID_CACHE, id);
+       } else if (memcache_lookup(NULL, SID_UID_CACHE, sid, &id)) {
+               DEBUG(3, ("Delete mapping %s <-> UID %d from memcache\n",
+                         sid_string_dbg(psid), *(int*)id.data));
+               memcache_delete(NULL, SID_UID_CACHE, sid);
+               memcache_delete(NULL, UID_SID_CACHE, id);
+       } else {
+               DEBUG(3, ("SID %s is not memcached!\n", sid_string_dbg(psid)));
+               return false;
+       }
+       return true;
+}
+
 void flush_gid_cache(void)
 {
        DEBUG(3, ("Flush GID <-> SID memcache\n"));