Operating System - HP-UX
1830136 Members
2950 Online
109999 Solutions
New Discussion

Can't get core dump from apache

 
Tony Abo
Occasional Advisor

Can't get core dump from apache

I am finding that in HP-UX 11.00 and 11.11, any program that calls setgid() will fail to produce a core dump, which is contrary to the documentation

I am trying to debug a problem in an apache module that is ocassionally leading to a segmentation fault. I have tried using the CoreDumpDirectory directive to dump into a world writable place (/tmp), but still no luck. On further investigation, it looks like the problem may be with HP-UX.

According to the signal(5) (HP-UX 11.11) manual page:

B If following conditions are met, generate a core image file (see core(4)) in the current working directory of the receiving process:

o The effective user ID and the real user ID of the receiving process are equal.
o The effective group ID and the real group ID of the receiving process are equal.
o A regular file named core does not exist and can be created, or exists and is writable.

When the USER and GROUP directives are used, apache uses setgid() and setuid() to morph itself into the specified user. Even though this sets all of the effective, real and saved user and group IDs, it seems to prevent core dumps from the process.

I can demonstrate this using the following simple program. Note that I run this as root. User www is defined in /etc/passwd as uid=30, group=1 (other). I run the program from /tmp to ensure world writability and delete any core file from /tmp beforehand.

#include
#include
#include

void causeabort(void);

int main(int argc, char **argv)
{

struct rlimit rlp;
gid_t egid, rgid, sgid;
uid_t euid, ruid, suid;

if (setgid(1) == -1) perror("setgid");
if (initgroups("www", 1) == -1) perror("initgroups");
if (setuid(30) == -1) perror("setuid");
getresgid (&rgid, &egid, &sgid);
getresuid (&ruid, &euid, &suid);
printf("euid = %d, ruid = %d, suid = %d\n", euid, ruid, suid);
printf("egid = %d, rgid = %d, sgid = %d\n", egid, rgid, sgid);

getrlimit(RLIMIT_CORE, &rlp);
printf("Core dump limit is %d (max %d)\n", rlp.rlim_cur, rlp.rlim_max);

causeabort();
}

void causeabort(void)
{
char *p = (char *) 123;

*p = 0;
}

This program outputs:

euid = 30, ruid = 30, suid = 30
egid = 1, rgid = 1, sgid = 1
Core dump limit is 2147483646 (max 2147483647)
Bus error

No dump is produced.

If I comment out the line that does setgid(), the group remains 3 (sys), and I get this:

euid = 30, ruid = 30, suid = 30
egid = 3, rgid = 3, sgid = 3
Core dump limit is 2147483646 (max 2147483647)
Bus error(coredump)

What am I missing?
2 REPLIES 2
Tony Abo
Occasional Advisor

Re: Can't get core dump from apache

So, am I just out of luck here?
Dennis Handly
Acclaimed Contributor

Re: Can't get core dump from apache

This works fine on 11.31 but fails on 11.23. I get:
# a.out
euid = 30, ruid = 30, suid = 30
egid = 1, rgid = 1, sgid = 1
Core dump limit is 2147483646 (max 2147483647)
Memory fault(coredump)