Linux-HA Logo

Getting Core Dumps

It can be difficult to get core dumps for Heartbeat[1] - because the code is security conscious and switches user ids back and forth to make it difficult to exploit the code to get root permissions. We have made progress on this, and so have the OS vendors, so these descriptions have several parts depending on what version and OS you're running.

  1. General Core Dump Enabling

    1. If your version of Heartbeat[1] supports a coredumps[2] directive, you should enable it.

    2. If your version does not support the coredumps[2] directive, then you should start Heartbeat[1] from a shell where you've executed this command:

      ulimit -c unlimited
      
      otherwise all core dumps will likely be prohibited.
  2. Enabling unique core files

    If your kernel has the /proc file /proc/sys/kernel/core_uses_pid, then you should execute this command: echo 1 > /proc/sys/kernel/core_uses_pid. If your kernel doesn't support this, then it's probably not a problem, but enable it if you can.

  3. Enabling core dumps for setuid processes

    1. Release 2[3] should not need this step (if seems to need this, please let us know).

    2. If you're running a kernel which has the file /proc/sys/kernel/suid_dumpable, then you should execute this command: echo 2 > /proc/sys/kernel/suid_dumpable.

    3. If you're not running release 2[3], and your kernel does not support the suid_dumpable capability and the process which is dying and should produce a core dump isn't, then you will likely have to make a source change to Heartbeat[1] and recompile.

      The source file you want to change is lib/clplumbing/uids.c. This file ought to start with a section of code that looks about like this:

      int     /* Become nobody - and remember our original privileges */
      drop_privs(uid_t uid, gid_t gid)
      {
              int     rc;
              gid_t   curgid = getgid();
      
              if (!anysaveduid) {
                      poweruid=getuid();
                      powergid=curgid;
              }
      

      We need to make this code into a no-op, so inserting a return after the declarations ought to do it.

      int     /* Become nobody - and remember our original privileges */
      drop_privs(uid_t uid, gid_t gid)
      {
              int     rc;
              gid_t   curgid = getgid();
      
              return; /* Disable security precautions DON'T LEAVE THIS IN HERE FOREVER! */
      
              if (!anysaveduid) {
                      poweruid=getuid();
                      powergid=curgid;
              }
      

      Now, recompile and reinstall Heartbeat[1].

  4. Core dump locations. Heartbeat[1] core dumps should show up in one of these two locations - depending on the release of Heartbeat[1] you're using:

    • /etc/ha.d

    • /var/lib/heartbeat/cores/*

Now, you should get core dumps when a Heartbeat[1] process ought to core dump.

See Also

coredumps directive[2], suid_dumpable patch[4]


References

[1]http://www.linux-ha.org/Heartbeat
[2]http://www.linux-ha.org/ha.cf/CoredumpsDirective
[3]http://www.linux-ha.org/v2
[4]http://lwn.net/Articles/104341/


This information provided courtesy of the Linux-HA project at http://linux-ha.org/