Subject: Re: core vs seteuid()
To: Jorgen Lundman <lundman@lundman.net>
From: David Maxwell <david@vex.net>
List: netbsd-users
Date: 05/30/2003 01:38:19
On Fri, May 30, 2003 at 11:17:23AM +0900, Jorgen Lundman wrote:
> Program calls seteuid() a fair bit, but if it ever dies I need the core to 
> remove any bugs. I know it may be undesirable to have core files from 
> seteuid programs in a multi user machine, but since these are dedicated 
> development machines that is not a concern.
> 
> Are there easy ways to make sure it dumps core, _always_? Even if I have to 
> force them into a special directory or whatever. I would rather not have to 
> hack at kernel sources and rebuild the kernel too :)

That's what you'll need to do...

/usr/src/sys/kern/kern_sig.c

/*
 * Dump core, into a file named "progname.core" or "core" (depending on
the
 * value of shortcorename), unless the process was setuid/setgid.
 */
int
coredump(struct proc *p)
{
        struct vnode            *vp;
        struct vmspace          *vm;
        struct ucred            *cred;
        struct nameidata        nd;
        struct vattr            vattr;
        int                     error, error1;
        char                    name[MAXPATHLEN];

        vm = p->p_vmspace;
        cred = p->p_cred->pc_ucred;

        /*
         * Make sure the process has not set-id, to prevent data leaks.
         */
        if (p->p_flag & P_SUGID)
                return (EPERM);


So... Comment out those last two lines - build a kernel, and you're all
set.

						David