summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/vfs_syscalls.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 787399a..4c1d97c 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -3556,13 +3556,16 @@ kern_renameat(struct thread *td, int oldfd, char *old, int newfd, char *new,
goto out;
}
#ifdef CAPABILITIES
- /*
- * If the target already exists we require CAP_UNLINKAT
- * from 'newfd'.
- */
- error = cap_check(tond.ni_filecaps.fc_rights, CAP_UNLINKAT);
- if (error != 0)
- goto out;
+ if (newfd != AT_FDCWD) {
+ /*
+ * If the target already exists we require CAP_UNLINKAT
+ * from 'newfd'.
+ */
+ error = cap_check(tond.ni_filecaps.fc_rights,
+ CAP_UNLINKAT);
+ if (error != 0)
+ goto out;
+ }
#endif
}
if (fvp == tdvp) {
OpenPOWER on IntegriCloud