File 0001-Revert-Fix-service-lib-avoid-call-pattern-leading-to.patch of Package pacemaker

From 60c3bcbcebd8b619b2124dfed9585182b97eb385 Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Thu, 11 Apr 2019 17:08:41 +0200
Subject: [PATCH 1/2] Revert "Fix: service-lib: avoid call-pattern leading to
 use-after-free"

This reverts commit e5a1d5dd751effe674e57a2f834e75650ad210c1.
---
 include/crm/services.h          |  8 +-------
 lib/fencing/st_client.c         | 18 +++---------------
 lib/services/services.c         | 13 +------------
 lib/services/services_linux.c   |  5 -----
 lib/services/services_private.h |  1 -
 5 files changed, 5 insertions(+), 40 deletions(-)

diff --git a/include/crm/services.h b/include/crm/services.h
index 4bdd21a34..c13fc0f04 100644
--- a/include/crm/services.h
+++ b/include/crm/services.h
@@ -305,17 +305,11 @@ gboolean services_action_kick(const char *name, const char *action,
  *
  * \param[in] op services action data
  * \param[in] action_callback callback for when the action completes
- * \param[in] action_fork_callback callback for when action forked successfully
  *
  * \retval TRUE succesfully started execution
  * \retval FALSE failed to start execution, no callback will be received
  */
-    gboolean services_action_async_fork_notify(svc_action_t * op,
-        void (*action_callback) (svc_action_t *),
-        void (*action_fork_callback) (svc_action_t *));
-
-    gboolean services_action_async(svc_action_t * op,
-                                   void (*action_callback) (svc_action_t *));
+    gboolean services_action_async(svc_action_t * op, void (*action_callback) (svc_action_t *));
 
 gboolean services_action_cancel(const char *name, const char *action,
                                 guint interval_ms);
diff --git a/lib/fencing/st_client.c b/lib/fencing/st_client.c
index f4b7addc2..0f2c33012 100644
--- a/lib/fencing/st_client.c
+++ b/lib/fencing/st_client.c
@@ -720,18 +720,6 @@ stonith_action_async_done(svc_action_t *svc_action)
     stonith__destroy_action(action);
 }
 
-static void
-stonith_action_async_forked(svc_action_t *svc_action)
-{
-    stonith_action_t *action = (stonith_action_t *) svc_action->cb_data;
-
-    action->pid = svc_action->pid;
-    action->svc_action = svc_action;
-
-    crm_trace("Child process %d performing action '%s' successfully forked",
-              action->pid, action->action);
-}
-
 static int
 internal_stonith_action_execute(stonith_action_t * action)
 {
@@ -778,12 +766,12 @@ internal_stonith_action_execute(stonith_action_t * action)
 
     if (action->async) {
         /* async */
-        if(services_action_async_fork_notify(svc_action,
-            &stonith_action_async_done,
-            &stonith_action_async_forked) == FALSE) {
+        if(services_action_async(svc_action, &stonith_action_async_done) == FALSE) {
             services_action_free(svc_action);
             svc_action = NULL;
         } else {
+            action->pid = svc_action->pid;
+            action->svc_action = svc_action;
             rc = 0;
         }
 
diff --git a/lib/services/services.c b/lib/services/services.c
index 313567f58..fa1e0dbe8 100644
--- a/lib/services/services.c
+++ b/lib/services/services.c
@@ -766,17 +766,12 @@ services_untrack_op(svc_action_t *op)
 }
 
 gboolean
-services_action_async_fork_notify(svc_action_t * op,
-                                  void (*action_callback) (svc_action_t *),
-                                  void (*action_fork_callback) (svc_action_t *))
+services_action_async(svc_action_t * op, void (*action_callback) (svc_action_t *))
 {
     op->synchronous = false;
     if (action_callback) {
         op->opaque->callback = action_callback;
     }
-    if (action_fork_callback) {
-        op->opaque->fork_callback = action_fork_callback;
-    }
 
     if (op->interval_ms > 0) {
         init_recurring_actions();
@@ -796,12 +791,6 @@ services_action_async_fork_notify(svc_action_t * op,
     return action_exec_helper(op);
 }
 
-gboolean
-services_action_async(svc_action_t * op,
-                      void (*action_callback) (svc_action_t *))
-{
-    return services_action_async_fork_notify(op, action_callback, NULL);
-}
 
 static gboolean processing_blocked_ops = FALSE;
 
diff --git a/lib/services/services_linux.c b/lib/services/services_linux.c
index 8686f2947..66f0fbfc7 100644
--- a/lib/services/services_linux.c
+++ b/lib/services/services_linux.c
@@ -888,11 +888,6 @@ services_os_action_execute(svc_action_t * op)
         op->opaque->stdin_fd = -1;
     }
 
-    // after fds are setup properly and before we plug anything into mainloop
-    if (op->opaque->fork_callback) {
-        op->opaque->fork_callback(op);
-    }
-
     if (op->synchronous) {
         action_synced_wait(op, pmask);
         sigchld_cleanup();
diff --git a/lib/services/services_private.h b/lib/services/services_private.h
index 660a35b67..bb4a7b6a3 100644
--- a/lib/services/services_private.h
+++ b/lib/services/services_private.h
@@ -25,7 +25,6 @@ struct svc_action_private_s {
 
     guint repeat_timer;
     void (*callback) (svc_action_t * op);
-    void (*fork_callback) (svc_action_t * op);
 
     int stderr_fd;
     mainloop_io_t *stderr_gsource;
-- 
2.16.4
openSUSE Build Service is sponsored by