From: Michael Tremer Date: Wed, 3 Aug 2022 09:32:17 +0000 (+0000) Subject: build: Replace pakfire_execute_script with new jail functions X-Git-Tag: 0.9.28~603 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=830f5d18ecbeb260897c5a71c8acde469a9d89d2;p=pakfire.git build: Replace pakfire_execute_script with new jail functions Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index c4094f49c..91f11cd11 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -621,6 +621,7 @@ ERROR: } static int pakfire_build_stage(struct pakfire* pakfire, struct pakfire_parser* makefile, const char* stage) { + struct pakfire_jail* jail = NULL; char template[1024]; // Prepare template for this stage @@ -640,12 +641,27 @@ static int pakfire_build_stage(struct pakfire* pakfire, struct pakfire_parser* m INFO(pakfire, "Running build stage '%s'\n", stage); - r = pakfire_execute_script(pakfire, script, strlen(script), NULL, envp, 0, NULL, NULL); + // Create a new jail + jail = pakfire_build_make_jail(pakfire); + if (!jail) + goto ERROR; + + // Import environment + r = pakfire_jail_import_env(jail, (const char**)envp); + if (r) { + ERROR(pakfire, "Could not import environment: %m\n"); + goto ERROR; + } + + // Run the script + r = pakfire_jail_exec_script(jail, script, strlen(script), NULL); if (r) { ERROR(pakfire, "Build stage '%s' failed with status %d\n", stage, r); } ERROR: + if (jail) + pakfire_jail_unref(jail); if (envp) { for (char** e = envp; *e; e++) free(*e);