Commit 709c42f DP: Add dp_sbus_invalidate_group_memcache()

2 files Authored and Committed by fidencio a month ago
DP: Add dp_sbus_invalidate_group_memcache()

This function will be called from the data provider to the NSS
responder, which will invalidate a group in the memcache.

Related:
https://pagure.io/SSSD/sssd/issue/2653

Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>

    
1 @@ -179,6 +179,8 @@
2   void dp_sbus_reset_users_memcache(struct data_provider *provider);
3   void dp_sbus_reset_groups_memcache(struct data_provider *provider);
4   void dp_sbus_reset_initgr_memcache(struct data_provider *provider);
5 + void dp_sbus_invalidate_group_memcache(struct data_provider *provider,
6 +                                        gid_t gid);
7   
8   /*
9    * A dummy handler for DPM_ACCT_DOMAIN_HANDLER.
 1 @@ -189,3 +189,48 @@
 2       return dp_sbus_reset_memcache(provider,
 3                             IFACE_NSS_MEMORYCACHE_INVALIDATEALLINITGROUPS);
 4   }
 5 + 
 6 + void dp_sbus_invalidate_group_memcache(struct data_provider *provider,
 7 +                                        gid_t gid)
 8 + {
 9 +     struct dp_client *dp_cli;
10 +     DBusMessage *msg;
11 +     dbus_bool_t dbret;
12 + 
13 +     if (provider == NULL) {
14 +         DEBUG(SSSDBG_CRIT_FAILURE, "No provider pointer\n");
15 +         return;
16 +     }
17 + 
18 +     dp_cli = provider->clients[DPC_NSS];
19 +     if (dp_cli == NULL) {
20 +         return;
21 +     }
22 + 
23 +     msg = dbus_message_new_method_call(NULL,
24 +                                        NSS_MEMORYCACHE_PATH,
25 +                                        IFACE_NSS_MEMORYCACHE,
26 +                                        IFACE_NSS_MEMORYCACHE_INVALIDATEGROUPBYID);
27 +     if (msg == NULL) {
28 +         DEBUG(SSSDBG_CRIT_FAILURE, "Out of memory?!\n");
29 +         return;
30 +     }
31 + 
32 +     dbret = dbus_message_append_args(msg,
33 +                                      DBUS_TYPE_UINT32, &gid,
34 +                                      DBUS_TYPE_INVALID);
35 +     if (!dbret) {
36 +         DEBUG(SSSDBG_CRIT_FAILURE, "Out of memory?!\n");
37 +         dbus_message_unref(msg);
38 +         return;
39 +     }
40 + 
41 +     DEBUG(SSSDBG_TRACE_FUNC,
42 +           "Ordering NSS responder to invalidate the group %"PRIu32" \n",
43 +           gid);
44 + 
45 +     sbus_conn_send_reply(dp_client_conn(dp_cli), msg);
46 +     dbus_message_unref(msg);
47 + 
48 +     return;
49 + }