mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +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
2 changed files with 15 additions and 16 deletions
|
@ -314,22 +314,8 @@ EventLoop::~EventLoop()
|
||||||
|
|
||||||
bool EventLoop::start_rpc_server()
|
bool EventLoop::start_rpc_server()
|
||||||
{
|
{
|
||||||
// Create /tmp/rpc if it doesn't exist.
|
auto rpc_path = String::formatted("/tmp/rpc/{}", getpid());
|
||||||
int rc = mkdir("/tmp/rpc", 0777);
|
auto rc = unlink(rpc_path.characters());
|
||||||
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());
|
|
||||||
if (rc < 0 && errno != ENOENT) {
|
if (rc < 0 && errno != ENOENT) {
|
||||||
perror("unlink");
|
perror("unlink");
|
||||||
return false;
|
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**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
prepare_devfs();
|
prepare_devfs();
|
||||||
|
@ -190,6 +202,7 @@ int main(int, char**)
|
||||||
}
|
}
|
||||||
|
|
||||||
mount_all_filesystems();
|
mount_all_filesystems();
|
||||||
|
create_tmp_rpc_directory();
|
||||||
parse_boot_mode();
|
parse_boot_mode();
|
||||||
|
|
||||||
Core::EventLoop event_loop;
|
Core::EventLoop event_loop;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue