Compare commits

...

2 Commits

Author SHA1 Message Date
e7d361ca51
startui: Remove /tmp/launch.sock as root
All checks were successful
Build and test / build (push) Successful in 1m51s
Fixes #47.
This avoids permission errors.
2024-09-07 17:33:38 +02:00
bb6759986e
libos/LocalServer: Clean up socket file on exit
This doesn't work if the process is killed by an unhandled signal.
2024-09-07 17:33:01 +02:00
3 changed files with 6 additions and 0 deletions

View File

@ -136,6 +136,7 @@ namespace os
~LocalServer(); ~LocalServer();
private: private:
StringView m_path;
int m_fd; int m_fd;
bool m_blocking; bool m_blocking;
}; };

View File

@ -43,6 +43,7 @@ namespace os
fcntl(sockfd, F_SETFD, FD_CLOEXEC); fcntl(sockfd, F_SETFD, FD_CLOEXEC);
server->m_fd = sockfd; server->m_fd = sockfd;
server->m_path = path;
return server; return server;
} }
@ -63,6 +64,7 @@ namespace os
LocalServer::~LocalServer() LocalServer::~LocalServer()
{ {
close(m_fd); close(m_fd);
os::FileSystem::remove(m_path);
} }
LocalServer::Client::Client(Client&& other) : m_fd(other.m_fd) LocalServer::Client::Client(Client&& other) : m_fd(other.m_fd)

View File

@ -95,6 +95,8 @@ Result<int> luna_main(int argc, char** argv)
setsid(); setsid();
// First of all, start the display server, in case we haven't been started by loginui. // First of all, start the display server, in case we haven't been started by loginui.
// FIXME: What if we're started after a wind process has previously run but exited, so we think there's a wind
// process when there isn't.
if (!os::FileSystem::exists("/tmp/wind.sock")) if (!os::FileSystem::exists("/tmp/wind.sock"))
{ {
// We need to wait for this one, since its sockets are required later. // We need to wait for this one, since its sockets are required later.
@ -121,6 +123,7 @@ Result<int> luna_main(int argc, char** argv)
// We also need to wait for this one, since taskbar requires launch.sock. // We also need to wait for this one, since taskbar requires launch.sock.
bool success = os::IPC::Notifier::run_and_wait( bool success = os::IPC::Notifier::run_and_wait(
[&] { [&] {
(void)os::FileSystem::remove("/tmp/launch.sock");
StringView launch_command[] = { "/usr/bin/launch" }; StringView launch_command[] = { "/usr/bin/launch" };
spawn_process_as_user(Slice<StringView>(launch_command, 1), pw->pw_uid, pw->pw_gid, groups.slice()); spawn_process_as_user(Slice<StringView>(launch_command, 1), pw->pw_uid, pw->pw_gid, groups.slice());
}, },