[SSSD] [PATCH] BE: Handle SIGUSR2

Jakub Hrozek jhrozek at redhat.com
Wed Aug 13 11:42:55 UTC 2014


On Tue, Aug 12, 2014 at 12:09:41PM -0400, Dan Lavu wrote:
> Made some changes to the man page, ack. 

Thanks a lot Dan. I'm attaching the patch I'm going to push given that
Lukas acked the code and Dan acked the man page.
-------------- next part --------------
>From d4dd7402b1087f25bd77218594e5c99382837c22 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Wed, 13 Aug 2014 13:38:26 +0200
Subject: [PATCH] BE: Handle SIGUSR2

It was possible to send SIGUSR1 and to both sssd and sssd_be processes,
but only possible to send SIGUSR2 to sssd. This patches fixes the
dichotomy by making the sssd_be process handle SIGUSR2 as well.
---
 src/man/sssd.8.xml               | 12 ++++++++----
 src/providers/data_provider_be.c | 20 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/man/sssd.8.xml b/src/man/sssd.8.xml
index 0e584cd2648826ff516eb85665fdb8e46c91a4eb..923da6824907f0d2d140d9ca83f87338e7664f83 100644
--- a/src/man/sssd.8.xml
+++ b/src/man/sssd.8.xml
@@ -170,8 +170,11 @@
                 <term>SIGUSR1</term>
                 <listitem>
                     <para>
-                        Tells the SSSD to simulate offline operation for one
-                        minute. This is mostly useful for testing purposes.
+                        Tells the SSSD to simulate offline operation for the
+                        duration of the <quote>offline_timeout</quote>
+                        parameter. This is useful for testing. The signal
+                        can be sent to either the sssd process or any sssd_be
+                        process directly.
                     </para>
                 </listitem>
             </varlistentry>
@@ -179,8 +182,9 @@
                 <term>SIGUSR2</term>
                 <listitem>
                     <para>
-                        Tells the SSSD to go online immediately. This is mostly
-                        useful for testing purposes.
+                        Tells the SSSD to go online immediately. This is
+                        useful for testing. The signal can be sent to either
+                        the sssd process or any sssd_be process directly.
                     </para>
                 </listitem>
             </varlistentry>
diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c
index 37d1e28c4ca9ae1733496d9bf2b4a955c1896b3a..a8cfab6d766a4868894dc39cdf50d245bbbe7ac8 100644
--- a/src/providers/data_provider_be.c
+++ b/src/providers/data_provider_be.c
@@ -2478,6 +2478,17 @@ static void signal_be_offline(struct tevent_context *ev,
     be_mark_offline(ctx);
 }
 
+static void signal_be_reset_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);
+    check_if_online(ctx);
+}
+
 int be_process_init_sudo(struct be_ctx *be_ctx)
 {
     TALLOC_CTX *tmp_ctx = NULL;
@@ -2766,6 +2777,15 @@ int be_process_init(TALLOC_CTX *mem_ctx,
         goto fail;
     }
 
+    /* Handle SIGUSR2 to force going online */
+    BlockSignals(false, SIGUSR2);
+    tes = tevent_add_signal(ctx->ev, ctx, SIGUSR2, 0,
+                            signal_be_reset_offline, ctx);
+    if (tes == NULL) {
+        ret = EIO;
+        goto fail;
+    }
+
     return EOK;
 
 fail:
-- 
1.9.3



More information about the sssd-devel mailing list