sed: Correctly unveil all paths

- The veil was never closed.
- unveil() only works with absolute paths.
- Files from the regular input list weren't unveiled.
This commit is contained in:
kleines Filmröllchen 2023-05-04 22:17:14 +02:00 committed by Ali Mohammad Pur
parent 95c571ca53
commit 34f8147385
Notes: sideshowbarker 2024-07-16 20:41:14 +09:00

View File

@ -877,10 +877,10 @@ ErrorOr<int> serenity_main(Main::Arguments args)
}
for (auto const& input_filename : TRY(script.input_filenames())) {
TRY(Core::System::unveil(input_filename, "r"sv));
TRY(Core::System::unveil(TRY(FileSystem::absolute_path(input_filename)), "r"sv));
}
for (auto const& output_filename : TRY(script.output_filenames())) {
TRY(Core::System::unveil(output_filename, "w"sv));
TRY(Core::System::unveil(TRY(FileSystem::absolute_path(output_filename)), "w"sv));
}
Vector<InputFile> inputs;
@ -888,10 +888,13 @@ ErrorOr<int> serenity_main(Main::Arguments args)
if (filename == "-"sv) {
inputs.empend(TRY(InputFile::create_from_stdin()));
} else {
TRY(Core::System::unveil(TRY(FileSystem::absolute_path(filename)), edit_in_place ? "rwc"sv : "r"sv));
auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Read));
inputs.empend(TRY(InputFile::create(move(file))));
}
}
TRY(Core::System::unveil(nullptr, nullptr));
if (inputs.is_empty()) {
inputs.empend(TRY(InputFile::create_from_stdin()));
}