diff --git a/Userland/Libraries/LibCore/StandardPaths.cpp b/Userland/Libraries/LibCore/StandardPaths.cpp index f6dce7c023b..467572f8b58 100644 --- a/Userland/Libraries/LibCore/StandardPaths.cpp +++ b/Userland/Libraries/LibCore/StandardPaths.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -109,9 +110,22 @@ ErrorOr StandardPaths::runtime_directory() builder.append("/Library/Application Support"sv); #elif defined(AK_OS_HAIKU) builder.append("/boot/system/var/shared_memory"sv); -#else +#elif defined(AK_OS_LINUX) auto uid = getuid(); builder.appendff("/run/user/{}", uid); +#else + // Just create a directory in /tmp that's owned by us with 0700 + auto uid = getuid(); + builder.appendff("/tmp/runtime_{}", uid); + auto error_or_stat = System::stat(builder.string_view()); + if (error_or_stat.is_error()) { + MUST(System::mkdir(builder.string_view(), 0700)); + } else { + auto stat = error_or_stat.release_value(); + VERIFY(S_ISDIR(stat.st_mode)); + if ((stat.st_mode & 0777) != 0700) + warnln("{} has unexpected mode flags {}", builder.string_view(), stat.st_mode); + } #endif return LexicalPath::canonicalized_path(builder.to_byte_string());