summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2022-02-06 17:54:24 +0000
committerAndreas Kling <kling@serenityos.org>2022-02-14 11:44:09 +0100
commit72ef1d7c06ac4c951eaab85f504ec07ff360fd15 (patch)
treeba9d407ecc1cf232c5f44a79419c6cf0c451f65b /Userland/Services
parent37658e6fa6fbffa0b0a37ef23941095eaed4b37d (diff)
downloadserenity-72ef1d7c06ac4c951eaab85f504ec07ff360fd15.zip
SystemServer: Remove Socket.h header + use Core::System in some places
Various Core::System functions are still missing so not all raw syscalls were converted just yet.
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/SystemServer/Service.cpp44
1 files changed, 17 insertions, 27 deletions
diff --git a/Userland/Services/SystemServer/Service.cpp b/Userland/Services/SystemServer/Service.cpp
index c2821fdbee..df8b50b3e1 100644
--- a/Userland/Services/SystemServer/Service.cpp
+++ b/Userland/Services/SystemServer/Service.cpp
@@ -12,7 +12,8 @@
#include <AK/StringBuilder.h>
#include <LibCore/ConfigFile.h>
#include <LibCore/File.h>
-#include <LibCore/Socket.h>
+#include <LibCore/SocketAddress.h>
+#include <LibCore/System.h>
#include <fcntl.h>
#include <sched.h>
#include <stdio.h>
@@ -39,25 +40,17 @@ void Service::setup_socket(SocketDescriptor& socket)
// Note: we use SOCK_CLOEXEC here to make sure we don't leak every socket to
// all the clients. We'll make the one we do need to pass down !CLOEXEC later
// after forking off the process.
- int socket_fd = ::socket(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
- if (socket_fd < 0) {
- perror("socket");
- VERIFY_NOT_REACHED();
- }
+ int socket_fd = Core::System::socket(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0).release_value_but_fixme_should_propagate_errors();
socket.fd = socket_fd;
if (m_account.has_value()) {
auto& account = m_account.value();
- if (fchown(socket_fd, account.uid(), account.gid()) < 0) {
- perror("fchown");
- VERIFY_NOT_REACHED();
- }
+ // FIXME: Propagate errors
+ MUST(Core::System::fchown(socket_fd, account.uid(), account.gid()));
}
- if (fchmod(socket_fd, socket.permissions) < 0) {
- perror("fchmod");
- VERIFY_NOT_REACHED();
- }
+ // FIXME: Propagate errors
+ MUST(Core::System::fchmod(socket_fd, socket.permissions));
auto socket_address = Core::SocketAddress::local(socket.path);
auto un_optional = socket_address.to_sockaddr_un();
@@ -66,17 +59,11 @@ void Service::setup_socket(SocketDescriptor& socket)
VERIFY_NOT_REACHED();
}
auto un = un_optional.value();
- int rc = bind(socket_fd, (const sockaddr*)&un, sizeof(un));
- if (rc < 0) {
- perror("bind");
- VERIFY_NOT_REACHED();
- }
- rc = listen(socket_fd, 16);
- if (rc < 0) {
- perror("listen");
- VERIFY_NOT_REACHED();
- }
+ // FIXME: Propagate errors
+ MUST(Core::System::bind(socket_fd, (const sockaddr*)&un, sizeof(un)));
+ // FIXME: Propagate errors
+ MUST(Core::System::listen(socket_fd, 16));
}
void Service::setup_sockets()
@@ -105,11 +92,14 @@ void Service::handle_socket_connection()
int socket_fd = m_sockets[0].fd;
if (m_accept_socket_connections) {
- int accepted_fd = accept(socket_fd, nullptr, nullptr);
- if (accepted_fd < 0) {
- perror("accept");
+ // FIXME: Propagate errors
+ auto maybe_accepted_fd = Core::System::accept(socket_fd, nullptr, nullptr);
+ if (maybe_accepted_fd.is_error()) {
+ dbgln("accept: {}", maybe_accepted_fd.error());
return;
}
+
+ int accepted_fd = maybe_accepted_fd.release_value();
spawn(accepted_fd);
close(accepted_fd);
} else {