From 9bec63f4b9cb97c1ff1cf2ff448446ab1e59734d Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Wed, 24 Jun 2009 08:18:15 -0400 Subject: Implement resInit for monitor, NSS, PAM, DP and the backends --- server/monitor/monitor.c | 14 +++++++++++++- server/providers/data_provider.c | 19 +++++++++++++++++++ server/providers/data_provider_be.c | 19 +++++++++++++++++++ server/responder/nss/nsssrv.c | 20 ++++++++++++++++++++ server/responder/pam/pamsrv.c | 20 ++++++++++++++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c index 1247842f..11c35d0f 100644 --- a/server/monitor/monitor.c +++ b/server/monitor/monitor.c @@ -34,6 +34,12 @@ #include #include #include + +/* Needed for res_init() */ +#include +#include +#include + #include "util/util.h" #include "popt.h" #include "tevent.h" @@ -534,12 +540,18 @@ static int monitor_signal_reconf(struct config_file_ctx *file_ctx, } static int service_signal_dns_reload(struct mt_svc *svc); -int monitor_update_resolv(struct config_file_ctx *file_ctx, +static int monitor_update_resolv(struct config_file_ctx *file_ctx, const char *filename) { + int ret; struct mt_svc *cur_svc; DEBUG(2, ("Resolv.conf has been updated. Reloading.\n")); + ret = res_init(); + if(ret != 0) { + return EIO; + } + /* Signal all services to reload their DNS configuration */ for(cur_svc = file_ctx->mt_ctx->svc_list; cur_svc; cur_svc = cur_svc->next) { service_signal_dns_reload(cur_svc); diff --git a/server/providers/data_provider.c b/server/providers/data_provider.c index 677f677f..4dc9dfaa 100644 --- a/server/providers/data_provider.c +++ b/server/providers/data_provider.c @@ -31,6 +31,11 @@ #include #include +/* Needed for res_init() */ +#include +#include +#include + #include "popt.h" #include "util/util.h" #include "confdb/confdb.h" @@ -83,11 +88,13 @@ static int dp_frontend_destructor(void *ctx); static int service_identity(DBusMessage *message, struct sbus_conn_ctx *sconn); static int service_pong(DBusMessage *message, struct sbus_conn_ctx *sconn); static int service_reload(DBusMessage *message, struct sbus_conn_ctx *sconn); +static int service_res_init(DBusMessage *message, struct sbus_conn_ctx *sconn); struct sbus_method mon_sbus_methods[] = { { SERVICE_METHOD_IDENTITY, service_identity }, { SERVICE_METHOD_PING, service_pong }, { SERVICE_METHOD_RELOAD, service_reload }, + { SERVICE_METHOD_RES_INIT, service_res_init }, { NULL, NULL } }; @@ -174,6 +181,18 @@ static int service_reload(DBusMessage *message, struct sbus_conn_ctx *sconn) return service_pong(message, sconn); } +static int service_res_init(DBusMessage *message, struct sbus_conn_ctx *sconn) +{ + int ret; + + ret = res_init(); + if(ret != 0) { + return EIO; + } + + return service_pong(message, sconn); +} + static int dp_monitor_init(struct dp_ctx *dpctx) { int ret; diff --git a/server/providers/data_provider_be.c b/server/providers/data_provider_be.c index 24254d15..5cd59946 100644 --- a/server/providers/data_provider_be.c +++ b/server/providers/data_provider_be.c @@ -34,6 +34,11 @@ #include #include +/* Needed for res_init() */ +#include +#include +#include + #include "popt.h" #include "util/util.h" #include "confdb/confdb.h" @@ -51,10 +56,12 @@ static int service_identity(DBusMessage *message, struct sbus_conn_ctx *sconn); static int service_pong(DBusMessage *message, struct sbus_conn_ctx *sconn); +static int service_res_init(DBusMessage *message, struct sbus_conn_ctx *sconn); struct sbus_method mon_sbus_methods[] = { { SERVICE_METHOD_IDENTITY, service_identity }, { SERVICE_METHOD_PING, service_pong }, + { SERVICE_METHOD_RES_INIT, service_res_init }, { NULL, NULL } }; @@ -137,6 +144,18 @@ static int service_pong(DBusMessage *message, struct sbus_conn_ctx *sconn) return EOK; } +static int service_res_init(DBusMessage *message, struct sbus_conn_ctx *sconn) +{ + int ret; + + ret = res_init(); + if(ret != 0) { + return EIO; + } + + return service_pong(message, sconn); +} + static int be_identity(DBusMessage *message, struct sbus_conn_ctx *sconn) { dbus_uint16_t version = DATA_PROVIDER_VERSION; diff --git a/server/responder/nss/nsssrv.c b/server/responder/nss/nsssrv.c index e04a8c87..9a3d3c45 100644 --- a/server/responder/nss/nsssrv.c +++ b/server/responder/nss/nsssrv.c @@ -29,6 +29,12 @@ #include #include #include + +/* Needed for res_init() */ +#include +#include +#include + #include "popt.h" #include "util/util.h" #include "responder/nss/nsssrv.h" @@ -49,11 +55,13 @@ static int service_identity(DBusMessage *message, struct sbus_conn_ctx *sconn); static int service_pong(DBusMessage *message, struct sbus_conn_ctx *sconn); static int service_reload(DBusMessage *message, struct sbus_conn_ctx *sconn); +static int service_res_init(DBusMessage *message, struct sbus_conn_ctx *sconn); struct sbus_method nss_sbus_methods[] = { {SERVICE_METHOD_IDENTITY, service_identity}, {SERVICE_METHOD_PING, service_pong}, {SERVICE_METHOD_RELOAD, service_reload}, + {SERVICE_METHOD_RES_INIT, service_res_init}, {NULL, NULL} }; @@ -118,6 +126,18 @@ static int service_reload(DBusMessage *message, struct sbus_conn_ctx *sconn) return service_pong(message, sconn); } +static int service_res_init(DBusMessage *message, struct sbus_conn_ctx *sconn) +{ + int ret; + + ret = res_init(); + if(ret != 0) { + return EIO; + } + + return service_pong(message, sconn); +} + static int nss_get_config(struct nss_ctx *nctx, struct resp_ctx *rctx, struct confdb_ctx *cdb) diff --git a/server/responder/pam/pamsrv.c b/server/responder/pam/pamsrv.c index e4ddc432..ef01e972 100644 --- a/server/responder/pam/pamsrv.c +++ b/server/responder/pam/pamsrv.c @@ -30,6 +30,12 @@ #include #include #include + +/* Needed for res_init() */ +#include +#include +#include + #include "popt.h" #include "util/util.h" #include "db/sysdb.h" @@ -52,11 +58,13 @@ static int service_identity(DBusMessage *message, struct sbus_conn_ctx *sconn); static int service_pong(DBusMessage *message, struct sbus_conn_ctx *sconn); static int service_reload(DBusMessage *message, struct sbus_conn_ctx *sconn); +static int service_res_init(DBusMessage *message, struct sbus_conn_ctx *sconn); struct sbus_method sss_sbus_methods[] = { {SERVICE_METHOD_IDENTITY, service_identity}, {SERVICE_METHOD_PING, service_pong}, {SERVICE_METHOD_RELOAD, service_reload}, + {SERVICE_METHOD_RES_INIT, service_res_init}, {NULL, NULL} }; @@ -108,6 +116,18 @@ static int service_pong(DBusMessage *message, struct sbus_conn_ctx *sconn) return EOK; } +static int service_res_init(DBusMessage *message, struct sbus_conn_ctx *sconn) +{ + int ret; + + ret = res_init(); + if(ret != 0) { + return EIO; + } + + return service_pong(message, sconn); +} + static void pam_shutdown(struct resp_ctx *ctx); static int service_reload(DBusMessage *message, struct sbus_conn_ctx *sconn) { -- cgit