Skip to content

Commit

Permalink
HBSD: Inherit global environment state
Browse files Browse the repository at this point in the history
A soon-to-be landed change in HardenedBSD will make it so that consumers
of the posix_spawn(3) API will need to explicitly state their intentions
with regards to the environment. If a NULL environment variable pointer
is passed, then the spawned process will enherit an empty environment.

This change ensures that the filter programs inherit the process'
environment variables.

Signed-off-by:	Shawn Webb <[email protected]>
See-Also:	https://git.hardenedbsd.org/hardenedbsd/HardenedBSD/-/issues/106
  • Loading branch information
lattera committed Oct 8, 2024
1 parent 64cc56a commit 4d2d669
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libarchive/filter_fork_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
# include <unistd.h>
#endif

#if defined(HAVE_POSIX_SPAWNP)
extern char *const environ[];
#endif

#include "archive.h"
#include "archive_cmdline_private.h"

Expand Down Expand Up @@ -137,7 +141,7 @@ __archive_create_child(const char *cmd, int *child_stdin, int *child_stdout,
goto actions_inited;
}
r = posix_spawnp(&child, cmdline->path, &actions, NULL,
cmdline->argv, NULL);
cmdline->argv, environ);
if (r != 0)
goto actions_inited;
posix_spawn_file_actions_destroy(&actions);
Expand Down

0 comments on commit 4d2d669

Please sign in to comment.