From 777a32c86509533074c7be935c4c055b2067f28b Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 1 Sep 1999 00:29:56 +0000 Subject: General cleanup of core-dumping code. Submitted by: Sean Fagan, --- sys/kern/imgact_aout.c | 44 +++++++------------------------------------- 1 file changed, 7 insertions(+), 37 deletions(-) (limited to 'sys/kern/imgact_aout.c') 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; } /* -- cgit v1.1