Kernel: The superuser is allowed to utime() on any file

Before this patch, root was not able to "touch" someone else's file.
This commit is contained in:
Andreas Kling 2020-01-03 04:14:41 +01:00
parent 3f74e66e82
commit 889ecd1375
Notes: sideshowbarker 2024-07-19 10:24:06 +09:00

View file

@ -163,7 +163,7 @@ KResult VFS::utime(StringView path, Custody& base, time_t atime, time_t mtime)
auto& inode = *descriptor_or_error.value()->inode();
if (inode.fs().is_readonly())
return KResult(-EROFS);
if (inode.metadata().uid != current->process().euid())
if (!current->process().is_superuser() && inode.metadata().uid != current->process().euid())
return KResult(-EACCES);
int error = inode.set_atime(atime);