mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
Kernel: Make File::{chown,chmod} take credentials as input
...instead of getting them from Process::current(). :^)
This commit is contained in:
parent
c3351d4b9f
commit
006f753647
10 changed files with 26 additions and 23 deletions
|
@ -445,8 +445,10 @@ ErrorOr<void> LocalSocket::ioctl(OpenFileDescription& description, unsigned requ
|
|||
return EINVAL;
|
||||
}
|
||||
|
||||
ErrorOr<void> LocalSocket::chmod(OpenFileDescription&, mode_t mode)
|
||||
ErrorOr<void> LocalSocket::chmod(Credentials const&, OpenFileDescription&, mode_t mode)
|
||||
{
|
||||
// FIXME: Use the credentials.
|
||||
|
||||
auto inode = m_inode.strong_ref();
|
||||
if (inode)
|
||||
return inode->chmod(mode);
|
||||
|
@ -455,14 +457,15 @@ ErrorOr<void> LocalSocket::chmod(OpenFileDescription&, mode_t mode)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> LocalSocket::chown(OpenFileDescription&, UserID uid, GroupID gid)
|
||||
ErrorOr<void> LocalSocket::chown(Credentials const& credentials, OpenFileDescription&, UserID uid, GroupID gid)
|
||||
{
|
||||
// FIXME: Use the credentials.
|
||||
|
||||
auto inode = m_inode.strong_ref();
|
||||
if (inode)
|
||||
return inode->chown(uid, gid);
|
||||
|
||||
auto& current_process = Process::current();
|
||||
if (!current_process.is_superuser() && (current_process.euid() != uid || !current_process.in_group(gid)))
|
||||
if (!credentials.is_superuser() && (credentials.euid() != uid || !credentials.in_group(gid)))
|
||||
return set_so_error(EPERM);
|
||||
|
||||
m_prebind_uid = uid;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue