int error, flags;
context.vc_proc = p;
- context.vc_ucred = proc_ucred(p);
+ context.vc_ucred = kauth_cred_proc_ref(p);
flags = FREAD|FWRITE;
if (in_kernel) {
/* vn_open gives both long- and short-term references */
error = vn_open(&nd, flags, 0);
if (error) {
- if (error != EACCES && error != EPERM && error != EROFS)
+ if (error != EACCES && error != EPERM && error != EROFS) {
+ kauth_cred_unref(&context.vc_ucred);
return (error);
+ }
flags &= ~FWRITE;
if (in_kernel) {
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE32,
vniop->vn_file, &context);
}
error = vn_open(&nd, flags, 0);
- if (error)
+ if (error) {
+ kauth_cred_unref(&context.vc_ucred);
return (error);
+ }
}
if (nd.ni_vp->v_type != VREG) {
error = EINVAL;
error = vnode_size(nd.ni_vp, &file_size, &context);
}
if (error != 0) {
- (void) vn_close(nd.ni_vp, flags, proc_ucred(p), p);
+ (void) vn_close(nd.ni_vp, flags, context.vc_ucred, p);
vnode_put(nd.ni_vp);
+ kauth_cred_unref(&context.vc_ucred);
return (error);
}
cred = kauth_cred_proc_ref(p);
nd.ni_vp->v_flag |= VNOCACHE_DATA;
error = setcred(nd.ni_vp, p, cred);
if (error) {
- (void)vn_close(nd.ni_vp, flags, proc_ucred(p), p);
+ (void)vn_close(nd.ni_vp, flags, context.vc_ucred, p);
vnode_put(nd.ni_vp);
- kauth_cred_rele(cred);
+ kauth_cred_unref(&cred);
+ kauth_cred_unref(&context.vc_ucred);
return(error);
}
vn->sc_secsize = DEV_BSIZE;
vn->sc_flags |= VNF_READONLY;
/* lose the short-term reference */
vnode_put(nd.ni_vp);
+ kauth_cred_unref(&context.vc_ucred);
return(0);
}
off_t file_size;
context.vc_proc = p;
- context.vc_ucred = proc_ucred(p);
+ context.vc_ucred = kauth_cred_proc_ref(p);
flags = FREAD|FWRITE;
if (in_kernel) {
error = vn_open(&nd, flags, 0);
if (error) {
/* shadow MUST be writable! */
+ kauth_cred_unref(&context.vc_ucred);
return (error);
}
if (nd.ni_vp->v_type != VREG
|| (error = vnode_size(nd.ni_vp, &file_size, &context))) {
- (void)vn_close(nd.ni_vp, flags, proc_ucred(p), p);
+ (void)vn_close(nd.ni_vp, flags, context.vc_ucred, p);
vnode_put(nd.ni_vp);
+ kauth_cred_unref(&context.vc_ucred);
return (error ? error : EINVAL);
}
map = shadow_map_create(vn->sc_fsize, file_size,
0, vn->sc_secsize);
if (map == NULL) {
- (void)vn_close(nd.ni_vp, flags, proc_ucred(p), p);
+ (void)vn_close(nd.ni_vp, flags, context.vc_ucred, p);
vnode_put(nd.ni_vp);
vn->sc_shadow_vp = NULL;
+ kauth_cred_unref(&context.vc_ucred);
return (ENOMEM);
}
vn->sc_shadow_vp = nd.ni_vp;
/* lose the short-term reference */
vnode_put(nd.ni_vp);
+ kauth_cred_unref(&context.vc_ucred);
return(0);
}
}
vn->sc_flags &= ~(VNF_INITED | VNF_READONLY);
if (vn->sc_cred) {
- kauth_cred_rele(vn->sc_cred);
- vn->sc_cred = NULL;
+ kauth_cred_unref(&vn->sc_cred);
}
vn->sc_size = 0;
vn->sc_fsize = 0;