mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 01:59:14 +03:00
sed: Fix unveil
error for every run
`FileSystem::absolute_path()` does `stat` the file, this commit runs all `absolute_path` calls before touching the veil to make sure this works as intended.
This commit is contained in:
parent
3ee908df27
commit
a14dc9b569
Notes:
sideshowbarker
2024-07-18 03:23:00 +09:00
Author: https://github.com/fdellwing Commit: https://github.com/SerenityOS/serenity/commit/a14dc9b569 Pull-request: https://github.com/SerenityOS/serenity/pull/19504 Issue: https://github.com/SerenityOS/serenity/issues/19364 Reviewed-by: https://github.com/trflynn89
@ -953,20 +953,21 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
||||
pos_args.remove(0);
|
||||
}
|
||||
|
||||
HashMap<String, String> paths_to_unveil;
|
||||
|
||||
for (auto const& input_filename : TRY(script.input_filenames())) {
|
||||
TRY(Core::System::unveil(TRY(FileSystem::absolute_path(input_filename)), edit_in_place ? "rwc"sv : "r"sv));
|
||||
TRY(paths_to_unveil.try_set(TRY(FileSystem::absolute_path(input_filename)), edit_in_place ? "rwc"_short_string : "r"_short_string));
|
||||
}
|
||||
for (auto const& output_filename : TRY(script.output_filenames())) {
|
||||
TRY(Core::System::unveil(TRY(FileSystem::absolute_path(output_filename)), "w"sv));
|
||||
TRY(paths_to_unveil.try_set(TRY(FileSystem::absolute_path(output_filename)), "w"_short_string));
|
||||
}
|
||||
TRY(Core::System::unveil("/tmp"sv, "rwc"sv));
|
||||
|
||||
Vector<File> inputs;
|
||||
for (auto const& filename : pos_args) {
|
||||
if (filename == "-"sv) {
|
||||
inputs.empend(TRY(File::create_from_stdin()));
|
||||
} else {
|
||||
TRY(Core::System::unveil(TRY(FileSystem::absolute_path(filename)), edit_in_place ? "rwc"sv : "r"sv));
|
||||
TRY(paths_to_unveil.try_set(TRY(FileSystem::absolute_path(filename)), edit_in_place ? "rwc"_short_string : "r"_short_string));
|
||||
auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Read));
|
||||
if (edit_in_place)
|
||||
inputs.empend(TRY(File::create_with_output_file(LexicalPath { filename }, move(file))));
|
||||
@ -974,6 +975,11 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
||||
inputs.empend(TRY(File::create(LexicalPath { filename }, move(file))));
|
||||
}
|
||||
}
|
||||
|
||||
for (auto const& bucket : paths_to_unveil) {
|
||||
TRY(Core::System::unveil(bucket.key, bucket.value));
|
||||
}
|
||||
TRY(Core::System::unveil("/tmp"sv, "rwc"sv));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
if (inputs.is_empty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user