diff options
Diffstat (limited to 'server/responder')
-rw-r--r-- | server/responder/common/responder.h | 2 | ||||
-rw-r--r-- | server/responder/common/responder_common.c | 16 | ||||
-rw-r--r-- | server/responder/nss/nsssrv.c | 79 | ||||
-rw-r--r-- | server/responder/pam/pamsrv.c | 77 |
4 files changed, 24 insertions, 150 deletions
diff --git a/server/responder/common/responder.h b/server/responder/common/responder.h index 0f0908317..f41876508 100644 --- a/server/responder/common/responder.h +++ b/server/responder/common/responder.h @@ -102,6 +102,8 @@ int sss_process_init(TALLOC_CTX *mem_ctx, const char *sss_pipe_name, const char *sss_priv_pipe_name, const char *confdb_service_path, + const char *svc_name, + uint16_t svc_version, struct sbus_interface *dp_intf, struct sbus_interface *monitor_intf, struct resp_ctx **responder_ctx); diff --git a/server/responder/common/responder_common.c b/server/responder/common/responder_common.c index f3df7c65c..75e721030 100644 --- a/server/responder/common/responder_common.c +++ b/server/responder/common/responder_common.c @@ -286,7 +286,9 @@ static void accept_fd_handler(struct tevent_context *ev, } static int sss_monitor_init(struct resp_ctx *rctx, - struct sbus_interface *intf) + struct sbus_interface *intf, + const char *svc_name, + uint16_t svc_version) { char *sbus_address; int ret; @@ -306,8 +308,12 @@ static int sss_monitor_init(struct resp_ctx *rctx, return ret; } - /* Set up NSS-specific listeners */ - /* None currently used */ + /* Identify ourselves to the monitor */ + ret = monitor_common_send_id(rctx->mon_conn, svc_name, svc_version); + if (ret != EOK) { + DEBUG(0, ("Failed to identify to the monitor!\n")); + return ret; + } return EOK; } @@ -447,6 +453,8 @@ int sss_process_init(TALLOC_CTX *mem_ctx, const char *sss_pipe_name, const char *sss_priv_pipe_name, const char *confdb_service_path, + const char *svc_name, + uint16_t svc_version, struct sbus_interface *dp_intf, struct sbus_interface *monitor_intf, struct resp_ctx **responder_ctx) @@ -472,7 +480,7 @@ int sss_process_init(TALLOC_CTX *mem_ctx, return ret; } - ret = sss_monitor_init(rctx, monitor_intf); + ret = sss_monitor_init(rctx, monitor_intf, svc_name, svc_version); if (ret != EOK) { DEBUG(0, ("fatal error setting up message bus\n")); return ret; diff --git a/server/responder/nss/nsssrv.c b/server/responder/nss/nsssrv.c index 418e2f9f6..e4b121bf2 100644 --- a/server/responder/nss/nsssrv.c +++ b/server/responder/nss/nsssrv.c @@ -30,11 +30,6 @@ #include <sys/time.h> #include <errno.h> -/* Needed for res_init() */ -#include <netinet/in.h> -#include <arpa/nameser.h> -#include <resolv.h> - #include "popt.h" #include "util/util.h" #include "responder/nss/nsssrv.h" @@ -52,16 +47,12 @@ #define SSS_NSS_PIPE_NAME "nss" -static int service_identity(DBusMessage *message, struct sbus_connection *conn); -static int service_pong(DBusMessage *message, struct sbus_connection *conn); static int service_reload(DBusMessage *message, struct sbus_connection *conn); -static int service_res_init(DBusMessage *message, struct sbus_connection *conn); struct sbus_method monitor_nss_methods[] = { - { MON_CLI_METHOD_IDENTITY, service_identity }, - { MON_CLI_METHOD_PING, service_pong }, + { MON_CLI_METHOD_PING, monitor_common_pong }, { MON_CLI_METHOD_RELOAD, service_reload }, - { MON_CLI_METHOD_RES_INIT, service_res_init }, + { MON_CLI_METHOD_RES_INIT, monitor_common_res_init }, { NULL, NULL } }; @@ -73,56 +64,6 @@ struct sbus_interface monitor_nss_interface = { NULL }; -static int service_identity(DBusMessage *message, struct sbus_connection *conn) -{ - dbus_uint16_t version = NSS_SBUS_SERVICE_VERSION; - const char *name = NSS_SBUS_SERVICE_NAME; - DBusMessage *reply; - dbus_bool_t ret; - - DEBUG(4,("Sending ID reply: (%s,%d)\n", - name, version)); - - reply = dbus_message_new_method_return(message); - if (!reply) return ENOMEM; - - ret = dbus_message_append_args(reply, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_UINT16, &version, - DBUS_TYPE_INVALID); - if (!ret) { - dbus_message_unref(reply); - return EIO; - } - - /* send reply back */ - sbus_conn_send_reply(conn, reply); - dbus_message_unref(reply); - - return EOK; -} - -static int service_pong(DBusMessage *message, struct sbus_connection *conn) -{ - DBusMessage *reply; - dbus_bool_t ret; - - reply = dbus_message_new_method_return(message); - if (!reply) return ENOMEM; - - ret = dbus_message_append_args(reply, DBUS_TYPE_INVALID); - if (!ret) { - dbus_message_unref(reply); - return EIO; - } - - /* send reply back */ - sbus_conn_send_reply(conn, reply); - dbus_message_unref(reply); - - return EOK; -} - static int service_reload(DBusMessage *message, struct sbus_connection *conn) { /* Monitor calls this function when we need to reload @@ -131,19 +72,7 @@ static int service_reload(DBusMessage *message, struct sbus_connection *conn) */ /* Send an empty reply to acknowledge receipt */ - return service_pong(message, conn); -} - -static int service_res_init(DBusMessage *message, struct sbus_connection *conn) -{ - int ret; - - ret = res_init(); - if(ret != 0) { - return EIO; - } - - return service_pong(message, conn); + return monitor_common_pong(message, conn); } static int nss_get_config(struct nss_ctx *nctx, @@ -303,6 +232,8 @@ int nss_process_init(TALLOC_CTX *mem_ctx, nss_cmds, SSS_NSS_SOCKET_NAME, NULL, NSS_SRV_CONFIG, + NSS_SBUS_SERVICE_NAME, + NSS_SBUS_SERVICE_VERSION, nss_dp_interface, &monitor_nss_interface, &nctx->rctx); diff --git a/server/responder/pam/pamsrv.c b/server/responder/pam/pamsrv.c index bff2f7cc9..c0f0ca40e 100644 --- a/server/responder/pam/pamsrv.c +++ b/server/responder/pam/pamsrv.c @@ -31,11 +31,6 @@ #include <sys/time.h> #include <errno.h> -/* Needed for res_init() */ -#include <netinet/in.h> -#include <arpa/nameser.h> -#include <resolv.h> - #include "popt.h" #include "util/util.h" #include "db/sysdb.h" @@ -54,16 +49,12 @@ #define PAM_SBUS_SERVICE_NAME "pam" #define PAM_SRV_CONFIG "config/services/pam" -static int service_identity(DBusMessage *message, struct sbus_connection *conn); -static int service_pong(DBusMessage *message, struct sbus_connection *conn); static int service_reload(DBusMessage *message, struct sbus_connection *conn); -static int service_res_init(DBusMessage *message, struct sbus_connection *conn); struct sbus_method monitor_pam_methods[] = { - { MON_CLI_METHOD_IDENTITY, service_identity }, - { MON_CLI_METHOD_PING, service_pong }, + { MON_CLI_METHOD_PING, monitor_common_pong }, { MON_CLI_METHOD_RELOAD, service_reload }, - { MON_CLI_METHOD_RES_INIT, service_res_init }, + { MON_CLI_METHOD_RES_INIT, monitor_common_res_init }, { NULL, NULL } }; @@ -75,66 +66,6 @@ struct sbus_interface monitor_pam_interface = { NULL }; -static int service_identity(DBusMessage *message, struct sbus_connection *conn) -{ - dbus_uint16_t version = PAM_SBUS_SERVICE_VERSION; - const char *name = PAM_SBUS_SERVICE_NAME; - DBusMessage *reply; - dbus_bool_t ret; - - DEBUG(4,("Sending ID reply: (%s,%d)\n", name, version)); - - reply = dbus_message_new_method_return(message); - if (!reply) return ENOMEM; - - ret = dbus_message_append_args(reply, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_UINT16, &version, - DBUS_TYPE_INVALID); - if (!ret) { - dbus_message_unref(reply); - return EIO; - } - - /* send reply back */ - sbus_conn_send_reply(conn, reply); - dbus_message_unref(reply); - - return EOK; -} - -static int service_pong(DBusMessage *message, struct sbus_connection *conn) -{ - DBusMessage *reply; - dbus_bool_t ret; - - reply = dbus_message_new_method_return(message); - if (!reply) return ENOMEM; - - ret = dbus_message_append_args(reply, DBUS_TYPE_INVALID); - if (!ret) { - return EIO; - } - - /* send reply back */ - sbus_conn_send_reply(conn, reply); - dbus_message_unref(reply); - - return EOK; -} - -static int service_res_init(DBusMessage *message, struct sbus_connection *conn) -{ - int ret; - - ret = res_init(); - if(ret != 0) { - return EIO; - } - - return service_pong(message, conn); -} - static void pam_shutdown(struct resp_ctx *ctx); static int service_reload(DBusMessage *message, struct sbus_connection *conn) { @@ -144,7 +75,7 @@ static int service_reload(DBusMessage *message, struct sbus_connection *conn) { */ /* Send an empty reply to acknowledge receipt */ - return service_pong(message, conn); + return monitor_common_pong(message, conn); } static void pam_dp_reconnect_init(struct sbus_connection *conn, int status, void *pvt) @@ -242,6 +173,8 @@ int main(int argc, const char *argv[]) SSS_PAM_SOCKET_NAME, SSS_PAM_PRIV_SOCKET_NAME, PAM_SRV_CONFIG, + PAM_SBUS_SERVICE_NAME, + PAM_SBUS_SERVICE_VERSION, pam_dp_interface, &monitor_pam_interface, &rctx); |