diff options
author | kib <kib@FreeBSD.org> | 2014-06-17 07:11:00 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2014-06-17 07:11:00 +0000 |
commit | f5cc3af6c833ade4f593ff2e037393c34d1963fd (patch) | |
tree | ec469bbb5e8853be1f7cf473cf17ddc041a3a6a9 /sys/kern/vfs_vnops.c | |
parent | dd6bed9dd2429560e92e1df21f020f745b3f7d64 (diff) | |
download | FreeBSD-src-f5cc3af6c833ade4f593ff2e037393c34d1963fd.zip FreeBSD-src-f5cc3af6c833ade4f593ff2e037393c34d1963fd.tar.gz |
In msdosfs_setattr(), add a check for result of the utimes(2)
permissions test, forgotten in r164033.
Refactor the permission checks for utimes(2) into vnode helper
function vn_utimes_perm(9), and simplify its code comparing with the
UFS origin, by writing the call to VOP_ACCESSX only once. Use the
helper for UFS(5), tmpfs(5), devfs(5) and msdosfs(5).
Reported by: bde
Reviewed by: bde, trasz
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
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 7d5cea0..d97e56f 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2170,3 +2170,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); +} |