File bug-728579_pacemaker-stonith-dev-id.diff of Package pacemaker

commit 543b4337b42f64fa46e2c01b7eb466dc4bd7665b
Author: Gao,Yan <ygao@suse.com>
Date:   Fri Nov 11 14:03:56 2011 +0800

    Medium: stonith: Expose IDs of stonith resources to stonith agents through "$CRM_meta_st_device_id" environment variable

Index: pacemaker/fencing/commands.c
===================================================================
--- pacemaker.orig/fencing/commands.c
+++ pacemaker/fencing/commands.c
@@ -376,6 +376,8 @@ static stonith_device_t *build_device_fr
     device->agent = crm_element_value_copy(dev, "agent");
     device->namespace = crm_element_value_copy(dev, "namespace");
     device->params = xml2list(dev);
+    
+    g_hash_table_insert(device->params, crm_strdup(CRM_META "_" F_STONITH_DEVICE), crm_strdup(device->id));
     device->work = mainloop_add_trigger(G_PRIORITY_HIGH, stonith_device_dispatch, device);
     /* TODO: Hook up priority */
     
Index: pacemaker/lib/fencing/st_client.c
===================================================================
--- pacemaker.orig/lib/fencing/st_client.c
+++ pacemaker/lib/fencing/st_client.c
@@ -558,6 +558,8 @@ run_stonith_agent(const char *agent, con
 
     } else {
         /* child */
+        const char *st_dev_id_key = CRM_META "_" F_STONITH_DEVICE;
+        const char *st_dev_id_value = NULL;
 
         close(1);
         /* coverity[leaked_handle] False positive */
@@ -577,6 +579,11 @@ run_stonith_agent(const char *agent, con
         close(p_read_fd);
         close(p_write_fd);
 
+        st_dev_id_value = g_hash_table_lookup(device_args, st_dev_id_key);
+        if (st_dev_id_value) {
+            setenv(st_dev_id_key, st_dev_id_value, 1);
+        }
+
         execlp(agent, agent, NULL);
         exit(EXIT_FAILURE);
     }
openSUSE Build Service is sponsored by