summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_vnops.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/vfs_vnops.c')
-rw-r--r--sys/kern/vfs_vnops.c24
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);
+}
OpenPOWER on IntegriCloud