envp[environ_length] = NULL;
// Execute command
- int r = pakfire_execute(self->pakfire, argv[0], argv, 0);
+ int r = pakfire_execute(self->pakfire, argv[0], argv, (const char**)envp, 0);
// Cleanup
for (unsigned int i = 0; envp[i]; i++)
const char* root;
const char* command;
const char** argv;
- char* envp[20];
+ const char** envp;
};
static int pakfire_execute_fork(Pakfire pakfire, struct pakfire_execute_env* env) {
}
// exec() command
- r = execve(env->command, (char**)env->argv, env->envp);
+ r = execve(env->command, (char**)env->argv, (char**)env->envp);
// We should not get here
return errno;
}
-PAKFIRE_EXPORT int pakfire_execute(Pakfire pakfire, const char* command, const char** argv, int flags) {
+PAKFIRE_EXPORT int pakfire_execute(Pakfire pakfire, const char* command, const char** argv,
+ const char** envp, int flags) {
struct pakfire_execute_env env;
// Setup environment
env.command = command;
env.argv = argv;
-
- // Reset environnment
- env.envp[0] = NULL;
+ env.envp = envp;
// Fork this process
pid_t pid = fork();
#include <pakfire/types.h>
-int pakfire_execute(Pakfire pakfire, const char* command, const char** argv, int flags);
+int pakfire_execute(Pakfire pakfire, const char* command, const char** argv,
+ const char** envp, int flags);
#endif /* PAKFIRE_EXECUTE_H */
command = pakfire_path_relpath(root, path);
// Run the script
- r = pakfire_execute(step->pakfire, command, NULL, 0);
+ r = pakfire_execute(step->pakfire, command, NULL, NULL, 0);
if (r) {
DEBUG(step->pakfire, "Script return code: %d\n", r);
}
const char* path = pakfire_get_path(step->pakfire);
if (pakfire_access(step->pakfire, path, ldconfig + 1, X_OK) == 0) {
- r = pakfire_execute(step->pakfire, ldconfig, NULL, 0);
+ r = pakfire_execute(step->pakfire, ldconfig, NULL, NULL, 0);
DEBUG(step->pakfire, "ldconfig returned %d\n", r);
}
int test_does_not_exist(const test_t* t) {
const char* cmd = "/usr/bin/does-not-exist";
- int r = pakfire_execute(t->pakfire, cmd, NULL, 0);
+ int r = pakfire_execute(t->pakfire, cmd, NULL, NULL, 0);
assert_return(r != 0, EXIT_FAILURE);
return EXIT_SUCCESS;