1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:07:46 +00:00

Kernel: Move m_uid and m_gid from the Device class to SlavePTY

No other device needs to store the UID/GID of the process that created
them, so only store these values within the SlavePTY class.
This commit is contained in:
Liav A 2023-08-30 20:54:04 +03:00 committed by Andrew Kaster
parent 8d81b08f6d
commit ed315dd950
5 changed files with 16 additions and 23 deletions

View file

@ -20,7 +20,8 @@ ErrorOr<NonnullLockRefPtr<MasterPTY>> MasterPTY::try_create(unsigned int index)
{
auto buffer = TRY(DoubleBuffer::try_create("MasterPTY: Buffer"sv));
auto master_pty = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) MasterPTY(index, move(buffer))));
auto slave_pty = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) SlavePTY(*master_pty, index)));
auto credentials = Process::current().credentials();
auto slave_pty = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) SlavePTY(*master_pty, credentials->uid(), credentials->gid(), index)));
master_pty->m_slave = slave_pty;
TRY(master_pty->after_inserting());
TRY(slave_pty->after_inserting());
@ -32,11 +33,6 @@ MasterPTY::MasterPTY(unsigned index, NonnullOwnPtr<DoubleBuffer> buffer)
, m_index(index)
, m_buffer(move(buffer))
{
auto& process = Process::current();
auto credentials = process.credentials();
set_uid(credentials->uid());
set_gid(credentials->gid());
m_buffer->set_unblock_callback([this]() {
if (m_slave)
evaluate_block_conditions();