Skip to content

Commit

Permalink
sbus: replace sssd.nss.MemoryCache methods with signals
Browse files Browse the repository at this point in the history
  • Loading branch information
lamabro23 committed Jul 22, 2022
1 parent 768785e commit dbe2421
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 284 deletions.
49 changes: 4 additions & 45 deletions src/providers/data_provider/dp_resp_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ void dp_sbus_reset_groups_ncache(struct data_provider *provider,

void dp_sbus_reset_users_memcache(struct data_provider *provider)
{
struct tevent_req *subreq;

if (provider == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "No provider pointer\n");
return;
Expand All @@ -187,22 +185,12 @@ void dp_sbus_reset_users_memcache(struct data_provider *provider)
DEBUG(SSSDBG_TRACE_FUNC,
"Ordering NSS responder to invalidate the users\n");

subreq = sbus_call_nss_memcache_InvalidateAllUsers_send(provider,
provider->sbus_conn, SSS_BUS_NSS, SSS_BUS_PATH);
if (subreq == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create subrequest!\n");
return;
}

tevent_req_set_callback(subreq, sbus_unwanted_reply, NULL);

sbus_emit_nss_memcache_InvalidateAllUsers(provider->sbus_conn, SSS_BUS_PATH);
return;
}

void dp_sbus_reset_groups_memcache(struct data_provider *provider)
{
struct tevent_req *subreq;

if (provider == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "No provider pointer\n");
return;
Expand All @@ -211,22 +199,12 @@ void dp_sbus_reset_groups_memcache(struct data_provider *provider)
DEBUG(SSSDBG_TRACE_FUNC,
"Ordering NSS responder to invalidate the groups\n");

subreq = sbus_call_nss_memcache_InvalidateAllGroups_send(provider,
provider->sbus_conn, SSS_BUS_NSS, SSS_BUS_PATH);
if (subreq == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create subrequest!\n");
return;
}

tevent_req_set_callback(subreq, sbus_unwanted_reply, NULL);

sbus_emit_nss_memcache_InvalidateAllGroups(provider->sbus_conn, SSS_BUS_PATH);
return;
}

void dp_sbus_reset_initgr_memcache(struct data_provider *provider)
{
struct tevent_req *subreq;

if (provider == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "No provider pointer\n");
return;
Expand All @@ -235,23 +213,13 @@ void dp_sbus_reset_initgr_memcache(struct data_provider *provider)
DEBUG(SSSDBG_TRACE_FUNC,
"Ordering NSS responder to invalidate the initgroups\n");

subreq = sbus_call_nss_memcache_InvalidateAllInitgroups_send(provider,
provider->sbus_conn, SSS_BUS_NSS, SSS_BUS_PATH);
if (subreq == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create subrequest!\n");
return;
}

tevent_req_set_callback(subreq, sbus_unwanted_reply, NULL);

sbus_emit_nss_memcache_InvalidateAllInitgroups(provider->sbus_conn, SSS_BUS_PATH);
return;
}

void dp_sbus_invalidate_group_memcache(struct data_provider *provider,
gid_t gid)
{
struct tevent_req *subreq;

if (provider == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "No provider pointer\n");
return;
Expand All @@ -261,15 +229,6 @@ void dp_sbus_invalidate_group_memcache(struct data_provider *provider,
"Ordering NSS responder to invalidate the group %"PRIu32" \n",
gid);

subreq = sbus_call_nss_memcache_InvalidateGroupById_send(provider,
provider->sbus_conn, SSS_BUS_NSS, SSS_BUS_PATH,
(uint32_t)gid);
if (subreq == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create subrequest!\n");
return;
}

tevent_req_set_callback(subreq, sbus_unwanted_reply, NULL);

sbus_emit_nss_memcache_InvalidateGroupById(provider->sbus_conn, SSS_BUS_PATH, (uint32_t)gid);
return;
}
31 changes: 25 additions & 6 deletions src/responder/nss/nss_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,15 @@ sss_nss_register_backend_iface(struct sbus_connection *conn,
SBUS_INTERFACE(iface,
sssd_nss_MemoryCache,
SBUS_METHODS(
SBUS_SYNC(METHOD, sssd_nss_MemoryCache, UpdateInitgroups, sss_nss_memorycache_update_initgroups, nss_ctx),
SBUS_SYNC(METHOD, sssd_nss_MemoryCache, InvalidateAllUsers, sss_nss_memorycache_invalidate_users, nss_ctx),
SBUS_SYNC(METHOD, sssd_nss_MemoryCache, InvalidateAllGroups, sss_nss_memorycache_invalidate_groups, nss_ctx),
SBUS_SYNC(METHOD, sssd_nss_MemoryCache, InvalidateAllInitgroups, sss_nss_memorycache_invalidate_initgroups, nss_ctx),
SBUS_SYNC(METHOD, sssd_nss_MemoryCache, InvalidateGroupById, sss_nss_memorycache_invalidate_group_by_id, nss_ctx)
SBUS_SYNC(METHOD, sssd_nss_MemoryCache, UpdateInitgroups,
sss_nss_memorycache_update_initgroups, nss_ctx)
),
SBUS_SIGNALS(
SBUS_EMITS(sssd_nss_MemoryCache, InvalidateAllUsers),
SBUS_EMITS(sssd_nss_MemoryCache, InvalidateAllGroups),
SBUS_EMITS(sssd_nss_MemoryCache, InvalidateAllInitgroups),
SBUS_EMITS(sssd_nss_MemoryCache, InvalidateGroupById)
),
SBUS_SIGNALS(SBUS_NO_SIGNALS),
SBUS_PROPERTIES(SBUS_NO_PROPERTIES)
);

Expand All @@ -238,5 +240,22 @@ sss_nss_register_backend_iface(struct sbus_connection *conn,
"[%d]: %s\n", ret, sss_strerror(ret));
}

struct sbus_listener listeners[] = SBUS_LISTENERS(
SBUS_LISTEN_SYNC(sssd_nss_MemoryCache, InvalidateAllUsers,
SSS_BUS_PATH, sss_nss_memorycache_invalidate_users, nss_ctx),
SBUS_LISTEN_SYNC(sssd_nss_MemoryCache, InvalidateAllGroups,
SSS_BUS_PATH, sss_nss_memorycache_invalidate_groups, nss_ctx),
SBUS_LISTEN_SYNC(sssd_nss_MemoryCache, InvalidateAllInitgroups,
SSS_BUS_PATH, sss_nss_memorycache_invalidate_initgroups, nss_ctx),
SBUS_LISTEN_SYNC(sssd_nss_MemoryCache, InvalidateGroupById,
SSS_BUS_PATH, sss_nss_memorycache_invalidate_group_by_id, nss_ctx)
);

ret = sbus_router_listen_map(conn, listeners);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "Unable to add listeners [%d]: %s\n",
ret, sss_strerror(ret));
}

return ret;
}
136 changes: 63 additions & 73 deletions src/sss_iface/sbus_sss_client_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -2324,79 +2324,6 @@ sbus_call_monitor_RegisterService_recv
return sbus_method_in_sqq_out_q_recv(req, _monitor_version);
}

struct tevent_req *
sbus_call_nss_memcache_InvalidateAllGroups_send
(TALLOC_CTX *mem_ctx,
struct sbus_connection *conn,
const char *busname,
const char *object_path)
{
return sbus_method_in__out__send(mem_ctx, conn, _sbus_sss_key_,
busname, object_path, "sssd.nss.MemoryCache", "InvalidateAllGroups");
}

errno_t
sbus_call_nss_memcache_InvalidateAllGroups_recv
(struct tevent_req *req)
{
return sbus_method_in__out__recv(req);
}

struct tevent_req *
sbus_call_nss_memcache_InvalidateAllInitgroups_send
(TALLOC_CTX *mem_ctx,
struct sbus_connection *conn,
const char *busname,
const char *object_path)
{
return sbus_method_in__out__send(mem_ctx, conn, _sbus_sss_key_,
busname, object_path, "sssd.nss.MemoryCache", "InvalidateAllInitgroups");
}

errno_t
sbus_call_nss_memcache_InvalidateAllInitgroups_recv
(struct tevent_req *req)
{
return sbus_method_in__out__recv(req);
}

struct tevent_req *
sbus_call_nss_memcache_InvalidateAllUsers_send
(TALLOC_CTX *mem_ctx,
struct sbus_connection *conn,
const char *busname,
const char *object_path)
{
return sbus_method_in__out__send(mem_ctx, conn, _sbus_sss_key_,
busname, object_path, "sssd.nss.MemoryCache", "InvalidateAllUsers");
}

errno_t
sbus_call_nss_memcache_InvalidateAllUsers_recv
(struct tevent_req *req)
{
return sbus_method_in__out__recv(req);
}

struct tevent_req *
sbus_call_nss_memcache_InvalidateGroupById_send
(TALLOC_CTX *mem_ctx,
struct sbus_connection *conn,
const char *busname,
const char *object_path,
uint32_t arg_gid)
{
return sbus_method_in_u_out__send(mem_ctx, conn, _sbus_sss_key_u_0,
busname, object_path, "sssd.nss.MemoryCache", "InvalidateGroupById", arg_gid);
}

errno_t
sbus_call_nss_memcache_InvalidateGroupById_recv
(struct tevent_req *req)
{
return sbus_method_in_u_out__recv(req);
}

struct tevent_req *
sbus_call_nss_memcache_UpdateInitgroups_send
(TALLOC_CTX *mem_ctx,
Expand Down Expand Up @@ -2561,3 +2488,66 @@ sbus_call_service_sysbusReconnect_recv
{
return sbus_method_in__out__recv(req);
}

static void
sbus_emit_signal_
(struct sbus_connection *conn,
const char *path,
const char *iface,
const char *signal_name)
{
sbus_call_signal_send(conn, NULL, NULL, path, iface, signal_name, NULL);
}

static void
sbus_emit_signal_u
(struct sbus_connection *conn,
const char *path,
const char *iface,
const char *signal_name,
uint32_t arg0)
{
struct _sbus_sss_invoker_args_u args;

args.arg0 = arg0;

sbus_call_signal_send(conn, NULL, (sbus_invoker_writer_fn)_sbus_sss_invoker_write_u,
path, iface, signal_name, &args);
}

void
sbus_emit_nss_memcache_InvalidateAllGroups
(struct sbus_connection *conn,
const char *object_path)
{
sbus_emit_signal_(conn, object_path,
"sssd.nss.MemoryCache", "InvalidateAllGroups");
}

void
sbus_emit_nss_memcache_InvalidateAllInitgroups
(struct sbus_connection *conn,
const char *object_path)
{
sbus_emit_signal_(conn, object_path,
"sssd.nss.MemoryCache", "InvalidateAllInitgroups");
}

void
sbus_emit_nss_memcache_InvalidateAllUsers
(struct sbus_connection *conn,
const char *object_path)
{
sbus_emit_signal_(conn, object_path,
"sssd.nss.MemoryCache", "InvalidateAllUsers");
}

void
sbus_emit_nss_memcache_InvalidateGroupById
(struct sbus_connection *conn,
const char *object_path,
uint32_t arg_gid)
{
sbus_emit_signal_u(conn, object_path,
"sssd.nss.MemoryCache", "InvalidateGroupById", arg_gid);
}
66 changes: 21 additions & 45 deletions src/sss_iface/sbus_sss_client_async.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,51 +373,6 @@ sbus_call_monitor_RegisterService_recv
(struct tevent_req *req,
uint16_t* _monitor_version);

struct tevent_req *
sbus_call_nss_memcache_InvalidateAllGroups_send
(TALLOC_CTX *mem_ctx,
struct sbus_connection *conn,
const char *busname,
const char *object_path);

errno_t
sbus_call_nss_memcache_InvalidateAllGroups_recv
(struct tevent_req *req);

struct tevent_req *
sbus_call_nss_memcache_InvalidateAllInitgroups_send
(TALLOC_CTX *mem_ctx,
struct sbus_connection *conn,
const char *busname,
const char *object_path);

errno_t
sbus_call_nss_memcache_InvalidateAllInitgroups_recv
(struct tevent_req *req);

struct tevent_req *
sbus_call_nss_memcache_InvalidateAllUsers_send
(TALLOC_CTX *mem_ctx,
struct sbus_connection *conn,
const char *busname,
const char *object_path);

errno_t
sbus_call_nss_memcache_InvalidateAllUsers_recv
(struct tevent_req *req);

struct tevent_req *
sbus_call_nss_memcache_InvalidateGroupById_send
(TALLOC_CTX *mem_ctx,
struct sbus_connection *conn,
const char *busname,
const char *object_path,
uint32_t arg_gid);

errno_t
sbus_call_nss_memcache_InvalidateGroupById_recv
(struct tevent_req *req);

struct tevent_req *
sbus_call_nss_memcache_UpdateInitgroups_send
(TALLOC_CTX *mem_ctx,
Expand Down Expand Up @@ -520,4 +475,25 @@ errno_t
sbus_call_service_sysbusReconnect_recv
(struct tevent_req *req);

void
sbus_emit_nss_memcache_InvalidateAllGroups
(struct sbus_connection *conn,
const char *object_path);

void
sbus_emit_nss_memcache_InvalidateAllInitgroups
(struct sbus_connection *conn,
const char *object_path);

void
sbus_emit_nss_memcache_InvalidateAllUsers
(struct sbus_connection *conn,
const char *object_path);

void
sbus_emit_nss_memcache_InvalidateGroupById
(struct sbus_connection *conn,
const char *object_path,
uint32_t arg_gid);

#endif /* _SBUS_SSS_CLIENT_ASYNC_H_ */
Loading

0 comments on commit dbe2421

Please sign in to comment.