diff options
author | kib <kib@FreeBSD.org> | 2014-06-24 08:21:43 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2014-06-24 08:21:43 +0000 |
commit | 3b207676966493f5897b60f1575ca81297373eb4 (patch) | |
tree | 245675f195f5eed0fb417672371ef12b73f813c6 /sys/kern/vfs_vnops.c | |
parent | cf140f008f5d28d6463422c17af1c4a6013dd0d6 (diff) | |
download | FreeBSD-src-3b207676966493f5897b60f1575ca81297373eb4.zip FreeBSD-src-3b207676966493f5897b60f1575ca81297373eb4.tar.gz |
MFC r267564:
In msdosfs_setattr(), add a check for result of the utimes(2) permissions test.
Refactor the permission checks for utimes(2).
Diffstat (limited to 'sys/kern/vfs_vnops.c')
-rw-r--r-- | sys/kern/vfs_vnops.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index ec995c7..fdc52c3 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2085,3 +2085,27 @@ drop: foffset_unlock(fp, offset, error != 0 ? FOF_NOUPDATE : 0); return (error); } + +int +vn_utimes_perm(struct vnode *vp, struct vattr *vap, struct ucred *cred, + struct thread *td) +{ + int error; + + error = VOP_ACCESSX(vp, VWRITE_ATTRIBUTES, cred, td); + + /* + * From utimes(2): + * Grant permission if the caller is the owner of the file or + * the super-user. If the time pointer is null, then write + * permission on the file is also sufficient. + * + * From NFSv4.1, draft 21, 6.2.1.3.1, Discussion of Mask Attributes: + * A user having ACL_WRITE_DATA or ACL_WRITE_ATTRIBUTES + * will be allowed to set the times [..] to the current + * server time. + */ + if (error != 0 && (vap->va_vaflags & VA_UTIMES_NULL) != 0) + error = VOP_ACCESS(vp, VWRITE, cred, td); + return (error); +} |