mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
SystemServer+LibCore: Move /tmp/rpc/ directory creation to SystemServer
This doesn't solve half of the problems with /tmp/rpc, but this way we can at least make it sticky instead of having it fully world-writable and owned by whoever was the first to bind an RPC socket.
This commit is contained in:
parent
795bccbf69
commit
d38b9916c9
Notes:
sideshowbarker
2024-07-18 23:58:09 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d38b9916c99
2 changed files with 15 additions and 16 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue