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/ufs/ufs | |
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/ufs/ufs')
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 56e24a3..3504f0e 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -635,35 +635,8 @@ ufs_setattr(ap) return (EROFS); if ((ip->i_flags & SF_SNAPSHOT) != 0) return (EPERM); - /* - * From utimes(2): - * If times is NULL, ... The caller must be the owner of - * the file, have permission to write the file, or be the - * super-user. - * If times is non-NULL, ... The caller must be the owner of - * the file or be the super-user. - * - * Possibly for historical reasons, try to use VADMIN in - * preference to VWRITE for a NULL timestamp. This means we - * will return EACCES in preference to EPERM if neither - * check succeeds. - */ - if (vap->va_vaflags & VA_UTIMES_NULL) { - /* - * 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." - * - * XXX: Calling it four times seems a little excessive. - */ - error = VOP_ACCESSX(vp, VWRITE_ATTRIBUTES, cred, td); - if (error) - error = VOP_ACCESS(vp, VWRITE, cred, td); - } else - error = VOP_ACCESSX(vp, VWRITE_ATTRIBUTES, cred, td); - if (error) + error = vn_utimes_perm(vp, vap, cred, td); + if (error != 0) return (error); if (vap->va_atime.tv_sec != VNOVAL) ip->i_flag |= IN_ACCESS; |