1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:44:58 +00:00

zip: Add unveil and pledge promises

This commit is contained in:
David Lindbom 2022-01-17 22:26:48 +01:00 committed by Andreas Kling
parent 9d7a862509
commit 2ed4e47300

View file

@ -11,6 +11,7 @@
#include <LibCore/DirIterator.h>
#include <LibCore/File.h>
#include <LibCore/FileStream.h>
#include <LibCore/System.h>
#include <LibCrypto/Checksum/CRC32.h>
ErrorOr<int> serenity_main(Main::Arguments arguments)
@ -27,6 +28,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_option(force, "Overwrite existing zip file", "force", 'f');
args_parser.parse(arguments);
TRY(Core::System::pledge("stdio rpath wpath cpath"));
auto cwd = TRY(Core::System::getcwd());
TRY(Core::System::unveil(LexicalPath::absolute_path(cwd, zip_path), "wc"));
for (auto const& source_path : source_paths) {
TRY(Core::System::unveil(LexicalPath::absolute_path(cwd, source_path), "r"));
}
TRY(Core::System::unveil(nullptr, nullptr));
String zip_file_path { zip_path };
if (Core::File::exists(zip_file_path)) {
if (force) {