Menu

#1106 Coredumps are not generated when running as non root

4.7.FC
fixed
None
defect
nid
-
major
2015-08-25
2014-09-17
No

When running opensaf as non root; there are no coredumps generated during crash.
I have enabled coredumps in opensafd script.
Running kill -4 on any process running as opensaf does not generate coredump under /var/crash/opensaf
Checking running opensaf process limit

root@SC-1:/tmp# cat /proc/3657/limits 
Limit                     Soft Limit           Hard Limit           Units     
Max core file size        unlimited            unlimited            bytes

Running kill -4 on amfnd or smfnd which are running as root generates coredumps in correct way.

Related

Tickets: #1106

Discussion

  • Sirisha Alla

    Sirisha Alla - 2014-09-18
     
  • Adrian Szwej

    Adrian Szwej - 2014-10-01

    The following patch enable coredump after setuid.

    diff -r ead18326c13b osaf/libs/core/common/daemon.c
    --- a/osaf/libs/core/common/daemon.c    Fri Sep 26 08:53:42 2014 +0200
    +++ b/osaf/libs/core/common/daemon.c    Wed Oct 01 23:14:08 2014 +0000
    @@ -31,6 +31,7 @@
     #include <limits.h>
     #include <sys/stat.h>
     #include <sys/file.h>
    +#include <sys/prctl.h>
    
     #include <configmake.h>
    
    @@ -324,6 +325,7 @@
                    syslog(LOG_ERR, "setuid failed, uid=%d (%s)", pw->pw_uid, strerror(errno));
                    exit(EXIT_FAILURE);
                }
    +                        prctl(PR_SET_DUMPABLE, 1,0,0,0);
            } else {
                syslog(LOG_ERR, "invalid user name %s", __runas_username);
                exit(EXIT_FAILURE);
    diff -r ead18326c13b osaf/services/infrastructure/nid/scripts/opensafd.in
    --- a/osaf/services/infrastructure/nid/scripts/opensafd.in  Fri Sep 26 08:53:42 2014 +0200
    +++ b/osaf/services/infrastructure/nid/scripts/opensafd.in  Wed Oct 01 23:14:08 2014 +0000
    @@ -98,12 +98,19 @@
     }
    
     enable_coredump() {
    +        core_destination="/var/crash/opensaf"
        core_size="unlimited"
        core_pattern="/var/crash/opensaf/core_%t.%e.%p"
    
    -   if [ ! -d /var/crash/opensaf ]; then
    -       mkdir -p /var/crash/opensaf
    -   fi
    +        if [ ! -d ${core_destination} ]; then
    +                mkdir -p ${core_destination}
    +                if [ -n "$OPENSAF_GROUP" ]; then
    +                        getent group $OPENSAF_GROUP > /dev/null && chgrp $OPENSAF_GROUP ${core_destination}
    +                fi
    +                if [ -n "$OPENSAF_USER" ]; then
    +                        getent passwd $OPENSAF_USER > /dev/null && chown $OPENSAF_USER ${core_destination}
    +                fi
    +        fi
    
        if [ `ulimit -c` = 0 ]; then
            ulimit -c $core_size
    
     
  • Mathi Naickan

    Mathi Naickan - 2015-03-16
    • Milestone: 4.6.FC --> 4.7-Tentative
     
  • Hans Nordebäck

    Hans Nordebäck - 2015-04-28
    • status: unassigned --> fixed
    • assigned_to: hano
     
  • Hans Nordebäck

    Hans Nordebäck - 2015-04-28

    changeset: 6495:3f19d67c5fc6
    tag: tip
    user: Hans Nordeback hans.nordeback@ericsson.com
    date: Mon Apr 27 16:55:13 2015 +0200
    files: osaf/libs/core/common/daemon.c
    description:
    base: Coredumps are not generated when running as non root [#1106]

     

    Related

    Tickets: #1106


Log in to post a comment.