diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2010-01-26 09:37:32 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-02-01 08:50:57 -0500 |
commit | 3994ec2219ab7c7d5afbea4dad189d6920f94bbc (patch) | |
tree | 0a3067bd3b2ffee161722c472050165bcd07905c /server/providers/data_provider_be.c | |
parent | 4db27bb50ae891e6a9d99cce5f80ff73fd9d618f (diff) | |
download | sssd-3994ec2219ab7c7d5afbea4dad189d6920f94bbc.tar.gz sssd-3994ec2219ab7c7d5afbea4dad189d6920f94bbc.tar.bz2 sssd-3994ec2219ab7c7d5afbea4dad189d6920f94bbc.zip |
Force offline operation with SIGUSR1
If the monitor receives SIGUSR1, it will instruct all providers to
enter offline operation. If any individual provider receives
SIGUSR1, it alone will enter offline operation.
Diffstat (limited to 'server/providers/data_provider_be.c')
-rw-r--r-- | server/providers/data_provider_be.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/server/providers/data_provider_be.c b/server/providers/data_provider_be.c index fa26c145..c0e7e4b0 100644 --- a/server/providers/data_provider_be.c +++ b/server/providers/data_provider_be.c @@ -53,10 +53,13 @@ static int data_provider_res_init(DBusMessage *message, struct sbus_connection *conn); +static int data_provider_go_offline(DBusMessage *message, + struct sbus_connection *conn); struct sbus_method monitor_be_methods[] = { { MON_CLI_METHOD_PING, monitor_common_pong }, { MON_CLI_METHOD_RES_INIT, data_provider_res_init }, + { MON_CLI_METHOD_OFFLINE, data_provider_go_offline }, { NULL, NULL } }; @@ -1018,12 +1021,24 @@ done: return ret; } +static void signal_be_offline(struct tevent_context *ev, + struct tevent_signal *se, + int signum, + int count, + void *siginfo, + void *private_data) +{ + struct be_ctx *ctx = talloc_get_type(private_data, struct be_ctx); + be_mark_offline(ctx); +} + int be_process_init(TALLOC_CTX *mem_ctx, const char *be_domain, struct tevent_context *ev, struct confdb_ctx *cdb) { struct be_ctx *ctx; + struct tevent_signal *tes; int ret; ctx = talloc_zero(mem_ctx, struct be_ctx); @@ -1118,6 +1133,14 @@ int be_process_init(TALLOC_CTX *mem_ctx, "from provider [%s].\n", ctx->bet_info[BET_CHPASS].mod_name)); } + /* Handle SIGUSR1 to force offline behavior */ + BlockSignals(false, SIGUSR1); + tes = tevent_add_signal(ctx->ev, ctx, SIGUSR1, 0, + signal_be_offline, ctx); + if (tes == NULL) { + return EIO; + } + return EOK; } @@ -1205,3 +1228,12 @@ static int data_provider_res_init(DBusMessage *message, return monitor_common_res_init(message, conn); } + +static int data_provider_go_offline(DBusMessage *message, + struct sbus_connection *conn) +{ + struct be_ctx *be_ctx; + be_ctx = talloc_get_type(sbus_conn_get_private_data(conn), struct be_ctx); + be_mark_offline(be_ctx); + return monitor_common_pong(message, conn); +} |