Hi Zoran,

Reviewed and tested the patch.
Ack from me.

Best Regards,

Hung Nguyen - DEK Technologies


--------------------------------------------------------------------------------
From: Zoran Milinkovic [email protected]
Sent: Wednesday, September 23, 2015 2:08PM
To: Neelakanta Reddy
     [email protected]
Cc: Opensaf-devel
     [email protected]
Subject: [devel] [PATCH 1 of 1] imm: guard osafimmpbed by parent pid instead of 
parent name [#1496]


  osaf/services/saf/immsv/immpbed/immpbe.cc |  14 ++++++++------
  1 files changed, 8 insertions(+), 6 deletions(-)


The patch change the parent check from parent process name to parent pid.
This patch will allow to start osafimmnd with debugging tools (valgrind, etc.) 
when PBE is enabled.

diff --git a/osaf/services/saf/immsv/immpbed/immpbe.cc 
b/osaf/services/saf/immsv/immpbed/immpbe.cc
--- a/osaf/services/saf/immsv/immpbed/immpbe.cc
+++ b/osaf/services/saf/immsv/immpbed/immpbe.cc
@@ -27,6 +27,7 @@
  #include <assert.h>
  #include <libgen.h>
  #include <unistd.h>
+#include "configmake.h"
  
  #define XML_VERSION "1.0"
  
@@ -51,26 +52,27 @@ static const SaImmCallbacksT callbacks =
   * Check if osafimmpbe is executed by osafimmnd
   */
  static void checkParentProcess() {
-       char cmd[1024];
-       char *base;
+       const char *cmd = "cat " PKGPIDDIR "/osafimmnd.pid";
+       char buf[100];
        pid_t ppid = getppid();
+       pid_t immndpid;
  
-       sprintf(cmd, "cat /proc/%u/cmdline", ppid);
        FILE *f = popen(cmd, "r");
        if(!f)
                goto fail;
  
-       if(!fgets(cmd, 1024, f)) {
+       if(!fgets(buf, 100, f)) {
                pclose(f);
                goto fail;
        }
  
        pclose(f);
  
-       base = basename(cmd);
+       immndpid = strtol(buf, NULL, 10);
  
-       if(strncmp(base, "osafimmnd", strlen("osafimmnd")))
+       if(immndpid != ppid) {
                goto fail;
+       }
  
        return;
  

------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel



------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to