summaryrefslogtreecommitdiffstats
path: root/sys/kern/imgact_aout.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1999-09-01 00:29:56 +0000
committerjulian <julian@FreeBSD.org>1999-09-01 00:29:56 +0000
commit777a32c86509533074c7be935c4c055b2067f28b (patch)
tree11e2d7c456bbdbd477715a2e2bc4aec73bfec435 /sys/kern/imgact_aout.c
parent938ff8b8dc85de738517655e95e7e31f276c899f (diff)
downloadFreeBSD-src-777a32c86509533074c7be935c4c055b2067f28b.zip
FreeBSD-src-777a32c86509533074c7be935c4c055b2067f28b.tar.gz
General cleanup of core-dumping code.
Submitted by: Sean Fagan,
Diffstat (limited to 'sys/kern/imgact_aout.c')
-rw-r--r--sys/kern/imgact_aout.c44
1 files changed, 7 insertions, 37 deletions
diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c
index 0b3cbf5..90f22dd 100644
--- a/sys/kern/imgact_aout.c
+++ b/sys/kern/imgact_aout.c
@@ -75,7 +75,7 @@ struct sysentvec aout_sysvec = {
aout_coredump
};
-static int
+int
exec_aout_imgact(imgp)
struct image_params *imgp;
{
@@ -244,44 +244,19 @@ exec_aout_imgact(imgp)
* expand_name(), unless the process was setuid/setgid.
*/
int
-aout_coredump(p)
+aout_coredump(p, vp, limit)
register struct proc *p;
-{
register struct vnode *vp;
+ off_t limit;
+{
register struct ucred *cred = p->p_cred->pc_ucred;
register struct vmspace *vm = p->p_vmspace;
- struct nameidata nd;
- struct vattr vattr;
- int error, error1;
- char *name; /* name of corefile */
+ int error = 0;
- STOPEVENT(p, S_CORE, 0);
- if (sugid_coredump == 0 && p->p_flag & P_SUGID)
- return (EFAULT);
if (ctob(UPAGES + vm->vm_dsize + vm->vm_ssize) >=
- p->p_rlimit[RLIMIT_CORE].rlim_cur)
+ limit)
return (EFAULT);
- name = expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid);
- if (name == NULL)
- return (EFAULT); /* XXX -- not the best error */
- NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p);
- error = vn_open(&nd, O_CREAT | FWRITE | O_NOFOLLOW, S_IRUSR | S_IWUSR);
- free(name, M_TEMP);
- if (error)
- return (error);
- vp = nd.ni_vp;
- /* Don't dump to non-regular files or files with links. */
- if (vp->v_type != VREG ||
- VOP_GETATTR(vp, &vattr, cred, p) || vattr.va_nlink != 1) {
- error = EFAULT;
- goto out;
- }
- VATTR_NULL(&vattr);
- vattr.va_size = 0;
- VOP_LEASE(vp, p, cred, LEASE_WRITE);
- VOP_SETATTR(vp, &vattr, cred, p);
- p->p_acflag |= ACORE;
bcopy(p, &p->p_addr->u_kproc.kp_proc, sizeof(struct proc));
fill_eproc(p, &p->p_addr->u_kproc.kp_eproc);
error = cpu_coredump(p, vp, cred);
@@ -295,12 +270,7 @@ aout_coredump(p)
round_page(ctob(vm->vm_ssize)),
(off_t)ctob(UPAGES) + ctob(vm->vm_dsize), UIO_USERSPACE,
IO_NODELOCKED|IO_UNIT, cred, (int *) NULL, p);
-out:
- VOP_UNLOCK(vp, 0, p);
- error1 = vn_close(vp, FWRITE, cred, p);
- if (error == 0)
- error = error1;
- return (error);
+ return error;
}
/*
OpenPOWER on IntegriCloud