Blame SOURCES/0028-DP-add-NULL-check-to-be_ptask_-enable-disable.patch

841ac7
From cb94d00f31d1d6b6fcaa69dbaa928031d2e7c092 Mon Sep 17 00:00:00 2001
841ac7
From: Sumit Bose <sbose@redhat.com>
841ac7
Date: Fri, 24 May 2019 09:18:25 +0200
841ac7
Subject: [PATCH 28/29] DP: add NULL check to be_ptask_{enable|disable}
841ac7
841ac7
Currently the files and the proxy provider do not provide a check online
841ac7
method (DPM_CHECK_ONLINE). The files provider because it can never go
841ac7
offline. The proxy provider because there is no generic way to check
841ac7
since the nature of the actual provider is unknown.
841ac7
841ac7
Since the method is missing check_if_online() jumps into the error
841ac7
handling block were we try to reset the offline state
841ac7
unconditionally. If there is no check_if_online_ptask, which never
841ac7
exists for the files provider and will not be available in the proxy
841ac7
provider as long as the backend is online, be_ptask_{enable|disable}
841ac7
will be called with a NULL pointer.
841ac7
841ac7
Related to https://pagure.io/SSSD/sssd/issue/4014
841ac7
841ac7
Reviewed-by: Tomas Halman <thalman@redhat.com>
841ac7
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
841ac7
(cherry picked from commit 2720d97ce2559a3a382caf8f669820f64d6097fe)
841ac7
---
841ac7
 src/providers/be_ptask.c | 29 +++++++++++++++++------------
841ac7
 1 file changed, 17 insertions(+), 12 deletions(-)
841ac7
841ac7
diff --git a/src/providers/be_ptask.c b/src/providers/be_ptask.c
841ac7
index dc3c57db5..c43351755 100644
841ac7
--- a/src/providers/be_ptask.c
841ac7
+++ b/src/providers/be_ptask.c
841ac7
@@ -352,26 +352,31 @@ done:
841ac7
 
841ac7
 void be_ptask_enable(struct be_ptask *task)
841ac7
 {
841ac7
-    if (task->enabled) {
841ac7
-        DEBUG(SSSDBG_MINOR_FAILURE, "Task [%s]: already enabled\n",
841ac7
-                                     task->name);
841ac7
-        return;
841ac7
-    }
841ac7
+    if (task != NULL) {
841ac7
+        if (task->enabled) {
841ac7
+            DEBUG(SSSDBG_MINOR_FAILURE, "Task [%s]: already enabled\n",
841ac7
+                                         task->name);
841ac7
+            return;
841ac7
+        }
841ac7
 
841ac7
-    DEBUG(SSSDBG_TRACE_FUNC, "Task [%s]: enabling task\n", task->name);
841ac7
+        DEBUG(SSSDBG_TRACE_FUNC, "Task [%s]: enabling task\n", task->name);
841ac7
 
841ac7
-    task->enabled = true;
841ac7
-    be_ptask_schedule(task, BE_PTASK_ENABLED_DELAY, BE_PTASK_SCHEDULE_FROM_NOW);
841ac7
+        task->enabled = true;
841ac7
+        be_ptask_schedule(task, BE_PTASK_ENABLED_DELAY,
841ac7
+                          BE_PTASK_SCHEDULE_FROM_NOW);
841ac7
+    }
841ac7
 }
841ac7
 
841ac7
 /* Disable the task, but if a request already in progress, let it finish. */
841ac7
 void be_ptask_disable(struct be_ptask *task)
841ac7
 {
841ac7
-    DEBUG(SSSDBG_TRACE_FUNC, "Task [%s]: disabling task\n", task->name);
841ac7
+    if (task != NULL) {
841ac7
+        DEBUG(SSSDBG_TRACE_FUNC, "Task [%s]: disabling task\n", task->name);
841ac7
 
841ac7
-    talloc_zfree(task->timer);
841ac7
-    task->enabled = false;
841ac7
-    task->period = task->orig_period;
841ac7
+        talloc_zfree(task->timer);
841ac7
+        task->enabled = false;
841ac7
+        task->period = task->orig_period;
841ac7
+    }
841ac7
 }
841ac7
 
841ac7
 void be_ptask_destroy(struct be_ptask **task)
841ac7
-- 
841ac7
2.20.1
841ac7