From 4f869bbeffb24f9c4b3f4a975277f526e506a349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Tigeot?= Date: Sun, 29 Jul 2012 18:23:31 +0200 Subject: [PATCH 1/2] kernel: remove O_ROOTCRED * This flag was DragonFly-specific and effectively unused * Removing it frees up flag space for interacting with the rest of the world * Partially fixes issue #2357 --- sys/kern/kern_fp.c | 11 ++++------- sys/sys/fcntl.h | 4 ---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/sys/kern/kern_fp.c b/sys/kern/kern_fp.c index 710c62d..13916fb 100644 --- a/sys/kern/kern_fp.c +++ b/sys/kern/kern_fp.c @@ -85,8 +85,7 @@ typedef struct file *file_t; * * Open a file as specified. Use O_* flags for flags. * - * NOTE! O_ROOTCRED not quite working yet, vn_open() asserts that the - * cred must match the process's cred. XXX + * vn_open() asserts that the cred must match the process's cred. * * NOTE! when fp_open() is called from a pure thread, root creds are * used. @@ -103,10 +102,8 @@ fp_open(const char *path, int flags, int mode, file_t *fpp) return (error); fp = *fpp; td = curthread; - if (td->td_proc) { - if ((flags & O_ROOTCRED) == 0) - fsetcred(fp, td->td_proc->p_ucred); - } + if (td->td_proc) + fsetcred(fp, td->td_proc->p_ucred); error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_LOCKVP); flags = FFLAGS(flags); if (error == 0) @@ -177,7 +174,7 @@ fp_vpopen(struct vnode *vp, int flags, file_t *fpp) if ((error = falloc(NULL, fpp, NULL)) != 0) goto bad2; fp = *fpp; - if ((flags & O_ROOTCRED) == 0 && td->td_proc) + if (td->td_proc) fsetcred(fp, td->td_proc->p_ucred); error = VOP_OPEN(vp, flags, td->td_proc->p_ucred, fp); diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h index 353ab9b..2733b37 100644 --- a/sys/sys/fcntl.h +++ b/sys/sys/fcntl.h @@ -97,10 +97,6 @@ /* Attempt to bypass the buffer cache */ #define O_DIRECT 0x00010000 -#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) -#define O_ROOTCRED 0x00020000 /* fp_open */ -#endif - #define O_FBLOCKING 0x00040000 /* force blocking I/O */ #define O_FNONBLOCKING 0x00080000 /* force non-blocking I/O */ #define O_FAPPEND 0x00100000 /* force append mode for write */ -- 1.7.10.5