diff options
author | Andreas Kling <kling@serenityos.org> | 2022-08-21 16:35:03 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-08-21 16:35:03 +0200 |
commit | 8997c6a4d1f1047e53d640982568e1e45ed8f171 (patch) | |
tree | ab4ce0fd48cc69947772d08ba17688fd58bcaa33 /Kernel | |
parent | 51318d51a4836753ea61e595c8e845858569ddc4 (diff) | |
download | serenity-8997c6a4d1f1047e53d640982568e1e45ed8f171.zip |
Kernel: Make Socket::connect() take credentials as input
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Net/IPv4Socket.cpp | 2 | ||||
-rw-r--r-- | Kernel/Net/IPv4Socket.h | 2 | ||||
-rw-r--r-- | Kernel/Net/LocalSocket.cpp | 4 | ||||
-rw-r--r-- | Kernel/Net/LocalSocket.h | 2 | ||||
-rw-r--r-- | Kernel/Net/Socket.h | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/socket.cpp | 2 |
6 files changed, 7 insertions, 7 deletions
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 439cc89e37..1a1aa8750d 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -138,7 +138,7 @@ ErrorOr<void> IPv4Socket::listen(size_t backlog) return protocol_listen(result.did_allocate); } -ErrorOr<void> IPv4Socket::connect(OpenFileDescription& description, Userspace<sockaddr const*> address, socklen_t address_size) +ErrorOr<void> IPv4Socket::connect(Credentials const&, OpenFileDescription& description, Userspace<sockaddr const*> address, socklen_t address_size) { if (address_size != sizeof(sockaddr_in)) return set_so_error(EINVAL); diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h index 1376944f03..fa3a7c9e59 100644 --- a/Kernel/Net/IPv4Socket.h +++ b/Kernel/Net/IPv4Socket.h @@ -33,7 +33,7 @@ public: virtual ErrorOr<void> close() override; virtual ErrorOr<void> bind(Credentials const&, Userspace<sockaddr const*>, socklen_t) override; - virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<sockaddr const*>, socklen_t) override; + virtual ErrorOr<void> connect(Credentials const&, OpenFileDescription&, Userspace<sockaddr const*>, socklen_t) override; virtual ErrorOr<void> listen(size_t) override; virtual void get_local_address(sockaddr*, socklen_t*) override; virtual void get_peer_address(sockaddr*, socklen_t*) override; diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index 9415bb7ab1..d5820aad41 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -160,7 +160,7 @@ ErrorOr<void> LocalSocket::bind(Credentials const& credentials, Userspace<sockad return {}; } -ErrorOr<void> LocalSocket::connect(OpenFileDescription& description, Userspace<sockaddr const*> user_address, socklen_t address_size) +ErrorOr<void> LocalSocket::connect(Credentials const& credentials, OpenFileDescription& description, Userspace<sockaddr const*> user_address, socklen_t address_size) { VERIFY(!m_bound); @@ -179,7 +179,7 @@ ErrorOr<void> LocalSocket::connect(OpenFileDescription& description, Userspace<s auto path = SOCKET_TRY(KString::try_create(StringView { address.sun_path, strnlen(address.sun_path, sizeof(address.sun_path)) })); dbgln_if(LOCAL_SOCKET_DEBUG, "LocalSocket({}) connect({})", this, *path); - auto file = SOCKET_TRY(VirtualFileSystem::the().open(Process::current().credentials(), path->view(), O_RDWR, 0, Process::current().current_directory())); + auto file = SOCKET_TRY(VirtualFileSystem::the().open(credentials, path->view(), O_RDWR, 0, Process::current().current_directory())); auto inode = file->inode(); m_inode = inode; diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h index 9b112aeca4..8174b235fd 100644 --- a/Kernel/Net/LocalSocket.h +++ b/Kernel/Net/LocalSocket.h @@ -37,7 +37,7 @@ public: // ^Socket virtual ErrorOr<void> bind(Credentials const&, Userspace<sockaddr const*>, socklen_t) override; - virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<sockaddr const*>, socklen_t) override; + virtual ErrorOr<void> connect(Credentials const&, OpenFileDescription&, Userspace<sockaddr const*>, socklen_t) override; virtual ErrorOr<void> listen(size_t) override; virtual void get_local_address(sockaddr*, socklen_t*) override; virtual void get_peer_address(sockaddr*, socklen_t*) override; diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h index 22fc939346..4e0de6ec11 100644 --- a/Kernel/Net/Socket.h +++ b/Kernel/Net/Socket.h @@ -73,7 +73,7 @@ public: ErrorOr<void> shutdown(int how); virtual ErrorOr<void> bind(Credentials const&, Userspace<sockaddr const*>, socklen_t) = 0; - virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<sockaddr const*>, socklen_t) = 0; + virtual ErrorOr<void> connect(Credentials const&, OpenFileDescription&, Userspace<sockaddr const*>, socklen_t) = 0; virtual ErrorOr<void> listen(size_t) = 0; virtual void get_local_address(sockaddr*, socklen_t*) = 0; virtual void get_peer_address(sockaddr*, socklen_t*) = 0; diff --git a/Kernel/Syscalls/socket.cpp b/Kernel/Syscalls/socket.cpp index bd45d54e7b..70eded6dc4 100644 --- a/Kernel/Syscalls/socket.cpp +++ b/Kernel/Syscalls/socket.cpp @@ -152,7 +152,7 @@ ErrorOr<FlatPtr> Process::sys$connect(int sockfd, Userspace<sockaddr const*> use return ENOTSOCK; auto& socket = *description->socket(); REQUIRE_PROMISE_FOR_SOCKET_DOMAIN(socket.domain()); - TRY(socket.connect(*description, user_address, user_address_size)); + TRY(socket.connect(credentials(), *description, user_address, user_address_size)); return 0; } |