mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 17:15:08 +00:00
FileSystem: Route chown() and fchown() through VFS for access control.
This commit is contained in:
parent
aa35c08633
commit
e67bfdb7f6
3 changed files with 13 additions and 8 deletions
|
@ -329,5 +329,5 @@ KResult FileDescriptor::chown(uid_t uid, gid_t gid)
|
||||||
{
|
{
|
||||||
if (!m_inode)
|
if (!m_inode)
|
||||||
return KResult(-EINVAL);
|
return KResult(-EINVAL);
|
||||||
return m_inode->chown(uid, gid);
|
return VFS::the().chown(*m_inode, uid, gid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,14 +402,8 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base)
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult VFS::chown(StringView path, uid_t a_uid, gid_t a_gid, Custody& base)
|
KResult VFS::chown(Inode& inode, uid_t a_uid, gid_t a_gid)
|
||||||
{
|
{
|
||||||
auto custody_or_error = resolve_path(path, base);
|
|
||||||
if (custody_or_error.is_error())
|
|
||||||
return custody_or_error.error();
|
|
||||||
auto& custody = *custody_or_error.value();
|
|
||||||
auto& inode = custody.inode();
|
|
||||||
|
|
||||||
if (inode.fs().is_readonly())
|
if (inode.fs().is_readonly())
|
||||||
return KResult(-EROFS);
|
return KResult(-EROFS);
|
||||||
|
|
||||||
|
@ -436,6 +430,16 @@ KResult VFS::chown(StringView path, uid_t a_uid, gid_t a_gid, Custody& base)
|
||||||
return inode.chown(new_uid, new_gid);
|
return inode.chown(new_uid, new_gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KResult VFS::chown(StringView path, uid_t a_uid, gid_t a_gid, Custody& base)
|
||||||
|
{
|
||||||
|
auto custody_or_error = resolve_path(path, base);
|
||||||
|
if (custody_or_error.is_error())
|
||||||
|
return custody_or_error.error();
|
||||||
|
auto& custody = *custody_or_error.value();
|
||||||
|
auto& inode = custody.inode();
|
||||||
|
return chown(inode, a_uid, a_gid);
|
||||||
|
}
|
||||||
|
|
||||||
KResult VFS::link(StringView old_path, StringView new_path, Custody& base)
|
KResult VFS::link(StringView old_path, StringView new_path, Custody& base)
|
||||||
{
|
{
|
||||||
auto old_custody_or_error = resolve_path(old_path, base);
|
auto old_custody_or_error = resolve_path(old_path, base);
|
||||||
|
|
|
@ -70,6 +70,7 @@ public:
|
||||||
KResult chmod(StringView path, mode_t, Custody& base);
|
KResult chmod(StringView path, mode_t, Custody& base);
|
||||||
KResult fchmod(Inode&, mode_t);
|
KResult fchmod(Inode&, mode_t);
|
||||||
KResult chown(StringView path, uid_t, gid_t, Custody& base);
|
KResult chown(StringView path, uid_t, gid_t, Custody& base);
|
||||||
|
KResult chown(Inode&, uid_t, gid_t);
|
||||||
KResult access(StringView path, int mode, Custody& base);
|
KResult access(StringView path, int mode, Custody& base);
|
||||||
KResult stat(StringView path, int options, Custody& base, struct stat&);
|
KResult stat(StringView path, int options, Custody& base, struct stat&);
|
||||||
KResult utime(StringView path, Custody& base, time_t atime, time_t mtime);
|
KResult utime(StringView path, Custody& base, time_t atime, time_t mtime);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue