mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
Kernel: Strongly typed user & group ID's
Prior to this change, both uid_t and gid_t were typedef'ed to `u32`. This made it easy to use them interchangeably. Let's not allow that. This patch adds UserID and GroupID using the AK::DistinctNumeric mechanism we've already been employing for pid_t/ProcessID.
This commit is contained in:
parent
59335bd8ea
commit
ae197deb6b
44 changed files with 172 additions and 169 deletions
|
@ -63,7 +63,7 @@ KResultOr<SocketPair> LocalSocket::create_connected_pair(int type)
|
|||
memcpy(socket->m_address.sun_path, "[socketpair]", 13);
|
||||
|
||||
auto& process = Process::current();
|
||||
socket->m_acceptor = { process.pid().value(), process.uid(), process.gid() };
|
||||
socket->m_acceptor = { process.pid().value(), process.uid().value(), process.gid().value() };
|
||||
|
||||
socket->set_connected(true);
|
||||
socket->set_connect_side_role(Role::Connected);
|
||||
|
@ -456,7 +456,7 @@ KResult LocalSocket::chmod(FileDescription&, mode_t mode)
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
KResult LocalSocket::chown(FileDescription&, uid_t uid, gid_t gid)
|
||||
KResult LocalSocket::chown(FileDescription&, UserID uid, GroupID gid)
|
||||
{
|
||||
if (m_file)
|
||||
return m_file->chown(uid, gid);
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
virtual KResultOr<size_t> recvfrom(FileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, Time&) override;
|
||||
virtual KResult getsockopt(FileDescription&, int level, int option, Userspace<void*>, Userspace<socklen_t*>) override;
|
||||
virtual KResult ioctl(FileDescription&, unsigned request, Userspace<void*> arg) override;
|
||||
virtual KResult chown(FileDescription&, uid_t, gid_t) override;
|
||||
virtual KResult chown(FileDescription&, UserID, GroupID) override;
|
||||
virtual KResult chmod(FileDescription&, mode_t) override;
|
||||
|
||||
private:
|
||||
|
@ -72,8 +72,8 @@ private:
|
|||
// An open socket file on the filesystem.
|
||||
RefPtr<FileDescription> m_file;
|
||||
|
||||
uid_t m_prebind_uid { 0 };
|
||||
gid_t m_prebind_gid { 0 };
|
||||
UserID m_prebind_uid { 0 };
|
||||
GroupID m_prebind_gid { 0 };
|
||||
mode_t m_prebind_mode { 0 };
|
||||
|
||||
// A single LocalSocket is shared between two file descriptions
|
||||
|
|
|
@ -35,7 +35,7 @@ Socket::Socket(int domain, int type, int protocol)
|
|||
, m_protocol(protocol)
|
||||
{
|
||||
auto& process = Process::current();
|
||||
m_origin = { process.pid().value(), process.uid(), process.gid() };
|
||||
m_origin = { process.pid().value(), process.uid().value(), process.gid().value() };
|
||||
}
|
||||
|
||||
Socket::~Socket()
|
||||
|
@ -58,7 +58,7 @@ RefPtr<Socket> Socket::accept()
|
|||
auto client = m_pending.take_first();
|
||||
VERIFY(!client->is_connected());
|
||||
auto& process = Process::current();
|
||||
client->m_acceptor = { process.pid().value(), process.uid(), process.gid() };
|
||||
client->m_acceptor = { process.pid().value(), process.uid().value(), process.gid().value() };
|
||||
client->m_connected = true;
|
||||
client->m_role = Role::Accepted;
|
||||
if (!m_pending.is_empty())
|
||||
|
|
|
@ -92,11 +92,11 @@ public:
|
|||
virtual KResult getsockopt(FileDescription&, int level, int option, Userspace<void*>, Userspace<socklen_t*>);
|
||||
|
||||
pid_t origin_pid() const { return m_origin.pid; }
|
||||
uid_t origin_uid() const { return m_origin.uid; }
|
||||
gid_t origin_gid() const { return m_origin.gid; }
|
||||
UserID origin_uid() const { return m_origin.uid; }
|
||||
GroupID origin_gid() const { return m_origin.gid; }
|
||||
pid_t acceptor_pid() const { return m_acceptor.pid; }
|
||||
uid_t acceptor_uid() const { return m_acceptor.uid; }
|
||||
gid_t acceptor_gid() const { return m_acceptor.gid; }
|
||||
UserID acceptor_uid() const { return m_acceptor.uid; }
|
||||
GroupID acceptor_gid() const { return m_acceptor.gid; }
|
||||
const RefPtr<NetworkAdapter> bound_interface() const { return m_bound_interface; }
|
||||
|
||||
Mutex& lock() { return m_lock; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue