summaryrefslogtreecommitdiff
path: root/Kernel/Net/Socket.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-06 18:38:36 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-06 18:38:36 +0100
commit23e802518d6508a9e4a38d727655e5a7e668306e (patch)
treed88058c0bc020b8ba72d266b7f25c6140110ff0e /Kernel/Net/Socket.h
parent6e6e0b9de8cfdf1c3866ba14621d39f0cff194d6 (diff)
downloadserenity-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.h')
-rw-r--r--Kernel/Net/Socket.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h
index c297aa8e7b..6a1a21334d 100644
--- a/Kernel/Net/Socket.h
+++ b/Kernel/Net/Socket.h
@@ -77,10 +77,14 @@ public:
virtual ssize_t recvfrom(FileDescription&, void*, size_t, int flags, sockaddr*, socklen_t*) = 0;
virtual KResult setsockopt(int level, int option, const void*, socklen_t);
- virtual KResult getsockopt(int level, int option, void*, socklen_t*);
+ virtual KResult getsockopt(FileDescription&, int level, int option, void*, socklen_t*);
- pid_t origin_pid() const { return m_origin_pid; }
- pid_t acceptor_pid() const { return m_acceptor_pid; }
+ 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; }
+ 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; }
timeval receive_deadline() const { return m_receive_deadline; }
timeval send_deadline() const { return m_send_deadline; }
@@ -107,12 +111,15 @@ protected:
Role m_role { Role::None };
+protected:
+ ucred m_origin { 0, 0, 0 };
+ ucred m_acceptor { 0, 0, 0 };
+
private:
virtual bool is_socket() const final { return true; }
Lock m_lock { "Socket" };
- pid_t m_origin_pid { 0 };
- pid_t m_acceptor_pid { 0 };
+
int m_domain { 0 };
int m_type { 0 };
int m_protocol { 0 };