| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: tmpfs_vnops.c,v 1.58 2009/04/15 11:41:25 yamt Exp $ */ | | 1 | /* $NetBSD: tmpfs_vnops.c,v 1.59 2009/04/29 11:01:50 pooka Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Julio M. Merino Vidal, developed as part of Google's Summer of Code | | 8 | * by Julio M. Merino Vidal, developed as part of Google's Summer of Code |
9 | * 2005 program. | | 9 | * 2005 program. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -25,27 +25,27 @@ | | | @@ -25,27 +25,27 @@ |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30 | * POSSIBILITY OF SUCH DAMAGE. | | 30 | * POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | /* | | 33 | /* |
34 | * tmpfs vnode interface. | | 34 | * tmpfs vnode interface. |
35 | */ | | 35 | */ |
36 | | | 36 | |
37 | #include <sys/cdefs.h> | | 37 | #include <sys/cdefs.h> |
38 | __KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.58 2009/04/15 11:41:25 yamt Exp $"); | | 38 | __KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.59 2009/04/29 11:01:50 pooka Exp $"); |
39 | | | 39 | |
40 | #include <sys/param.h> | | 40 | #include <sys/param.h> |
41 | #include <sys/dirent.h> | | 41 | #include <sys/dirent.h> |
42 | #include <sys/fcntl.h> | | 42 | #include <sys/fcntl.h> |
43 | #include <sys/event.h> | | 43 | #include <sys/event.h> |
44 | #include <sys/malloc.h> | | 44 | #include <sys/malloc.h> |
45 | #include <sys/namei.h> | | 45 | #include <sys/namei.h> |
46 | #include <sys/proc.h> | | 46 | #include <sys/proc.h> |
47 | #include <sys/stat.h> | | 47 | #include <sys/stat.h> |
48 | #include <sys/uio.h> | | 48 | #include <sys/uio.h> |
49 | #include <sys/unistd.h> | | 49 | #include <sys/unistd.h> |
50 | #include <sys/vnode.h> | | 50 | #include <sys/vnode.h> |
51 | #include <sys/lockf.h> | | 51 | #include <sys/lockf.h> |
| @@ -194,29 +194,27 @@ tmpfs_lookup(void *v) | | | @@ -194,29 +194,27 @@ tmpfs_lookup(void *v) |
194 | tnode = de->td_node; | | 194 | tnode = de->td_node; |
195 | | | 195 | |
196 | /* If we are not at the last path component and | | 196 | /* If we are not at the last path component and |
197 | * found a non-directory or non-link entry (which | | 197 | * found a non-directory or non-link entry (which |
198 | * may itself be pointing to a directory), raise | | 198 | * may itself be pointing to a directory), raise |
199 | * an error. */ | | 199 | * an error. */ |
200 | if ((tnode->tn_type != VDIR && | | 200 | if ((tnode->tn_type != VDIR && |
201 | tnode->tn_type != VLNK) && | | 201 | tnode->tn_type != VLNK) && |
202 | !(cnp->cn_flags & ISLASTCN)) { | | 202 | !(cnp->cn_flags & ISLASTCN)) { |
203 | error = ENOTDIR; | | 203 | error = ENOTDIR; |
204 | goto out; | | 204 | goto out; |
205 | } | | 205 | } |
206 | | | 206 | |
207 | /* If we are deleting or renaming the entry, keep | | 207 | /* Check permissions */ |
208 | * track of its tmpfs_dirent so that it can be | | | |
209 | * easily deleted later. */ | | | |
210 | if ((cnp->cn_flags & ISLASTCN) && | | 208 | if ((cnp->cn_flags & ISLASTCN) && |
211 | (cnp->cn_nameiop == DELETE || | | 209 | (cnp->cn_nameiop == DELETE || |
212 | cnp->cn_nameiop == RENAME)) { | | 210 | cnp->cn_nameiop == RENAME)) { |
213 | if ((dnode->tn_mode & S_ISTXT) != 0 && | | 211 | if ((dnode->tn_mode & S_ISTXT) != 0 && |
214 | kauth_authorize_generic(cnp->cn_cred, | | 212 | kauth_authorize_generic(cnp->cn_cred, |
215 | KAUTH_GENERIC_ISSUSER, NULL) != 0 && | | 213 | KAUTH_GENERIC_ISSUSER, NULL) != 0 && |
216 | kauth_cred_geteuid(cnp->cn_cred) != dnode->tn_uid && | | 214 | kauth_cred_geteuid(cnp->cn_cred) != dnode->tn_uid && |
217 | kauth_cred_geteuid(cnp->cn_cred) != tnode->tn_uid) | | 215 | kauth_cred_geteuid(cnp->cn_cred) != tnode->tn_uid) |
218 | return EPERM; | | 216 | return EPERM; |
219 | error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred); | | 217 | error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred); |
220 | if (error != 0) | | 218 | if (error != 0) |
221 | goto out; | | 219 | goto out; |
222 | cnp->cn_flags |= SAVENAME; | | 220 | cnp->cn_flags |= SAVENAME; |