diff options
-rw-r--r-- | Libraries/LibCore/EventLoop.cpp | 18 | ||||
-rw-r--r-- | Services/SystemServer/main.cpp | 13 |
2 files changed, 15 insertions, 16 deletions
diff --git a/Libraries/LibCore/EventLoop.cpp b/Libraries/LibCore/EventLoop.cpp index 656bfae152..31aa8fb118 100644 --- a/Libraries/LibCore/EventLoop.cpp +++ b/Libraries/LibCore/EventLoop.cpp @@ -314,22 +314,8 @@ EventLoop::~EventLoop() bool EventLoop::start_rpc_server() { - // Create /tmp/rpc if it doesn't exist. - int rc = mkdir("/tmp/rpc", 0777); - if (rc == 0) { - // Ensure it gets created as 0777 despite our umask. - rc = chmod("/tmp/rpc", 0777); - if (rc < 0) { - perror("chmod /tmp/rpc"); - // Continue further. - } - } else if (errno != EEXIST) { - perror("mkdir /tmp/rpc"); - return false; - } - - auto rpc_path = String::format("/tmp/rpc/%d", getpid()); - rc = unlink(rpc_path.characters()); + auto rpc_path = String::formatted("/tmp/rpc/{}", getpid()); + auto rc = unlink(rpc_path.characters()); if (rc < 0 && errno != ENOENT) { perror("unlink"); return false; diff --git a/Services/SystemServer/main.cpp b/Services/SystemServer/main.cpp index 56179e86b5..19cf7b2895 100644 --- a/Services/SystemServer/main.cpp +++ b/Services/SystemServer/main.cpp @@ -180,6 +180,18 @@ static void mount_all_filesystems() } } +static void create_tmp_rpc_directory() +{ + dbgln("Creating /tmp/rpc directory"); + auto old_umask = umask(0); + auto rc = mkdir("/tmp/rpc", 01777); + if (rc < 0) { + perror("mkdir(/tmp/rpc)"); + ASSERT_NOT_REACHED(); + } + umask(old_umask); +} + int main(int, char**) { prepare_devfs(); @@ -190,6 +202,7 @@ int main(int, char**) } mount_all_filesystems(); + create_tmp_rpc_directory(); parse_boot_mode(); Core::EventLoop event_loop; |