diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-12-06 18:38:36 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-12-06 18:38:36 +0100 |
commit | 23e802518d6508a9e4a38d727655e5a7e668306e (patch) | |
tree | d88058c0bc020b8ba72d266b7f25c6140110ff0e /Kernel/Net/Socket.cpp | |
parent | 6e6e0b9de8cfdf1c3866ba14621d39f0cff194d6 (diff) | |
download | serenity-23e802518d6508a9e4a38d727655e5a7e668306e.zip |
Kernel: Add getsockopt(SO_PEERCRED) for local sockets
This sockopt gives you a struct with the PID, UID and GID of a socket's
peer process.
Diffstat (limited to 'Kernel/Net/Socket.cpp')
-rw-r--r-- | Kernel/Net/Socket.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp index b174cba69b..e65507da82 100644 --- a/Kernel/Net/Socket.cpp +++ b/Kernel/Net/Socket.cpp @@ -27,7 +27,8 @@ Socket::Socket(int domain, int type, int protocol) , m_type(type) , m_protocol(protocol) { - m_origin_pid = current->pid(); + auto& process = current->process(); + m_origin = { process.pid(), process.uid(), process.gid() }; } Socket::~Socket() @@ -53,7 +54,8 @@ RefPtr<Socket> Socket::accept() #endif auto client = m_pending.take_first(); ASSERT(!client->is_connected()); - client->m_acceptor_pid = m_origin_pid; + auto& process = current->process(); + client->m_acceptor = { process.pid(), process.uid(), process.gid() }; client->m_connected = true; client->m_role = Role::Accepted; return client; @@ -91,7 +93,7 @@ KResult Socket::setsockopt(int level, int option, const void* value, socklen_t v } } -KResult Socket::getsockopt(int level, int option, void* value, socklen_t* value_size) +KResult Socket::getsockopt(FileDescription&, int level, int option, void* value, socklen_t* value_size) { ASSERT(level == SOL_SOCKET); switch (option) { |