forked from mirrors/nixpkgs
chrootenv: error on chrootenv-inside-chrootenv, resolves #32802
This commit is contained in:
parent
0234cd41b4
commit
710662be94
|
@ -155,7 +155,9 @@ int nftw_rm(const char *path, const struct stat *sb, int type,
|
|||
|
||||
#define REQUIREMENTS "Linux version >= 3.19 built with CONFIG_USER_NS option"
|
||||
|
||||
int main(int argc, char *argv[], char *envp[]) {
|
||||
extern char **environ;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s command [arguments...]\n"
|
||||
"Requires " REQUIREMENTS ".\n",
|
||||
|
@ -163,6 +165,12 @@ int main(int argc, char *argv[], char *envp[]) {
|
|||
exit(EX_USAGE);
|
||||
}
|
||||
|
||||
if (getenv("NIX_CHROOTENV") != NULL)
|
||||
errorf(EX_USAGE, "can't create chrootenv inside chrootenv");
|
||||
|
||||
if (setenv("NIX_CHROOTENV", "1", false) < 0)
|
||||
errorf(EX_IOERR, "setenv");
|
||||
|
||||
char tmpl[] = "/tmp/chrootenvXXXXXX";
|
||||
char *root = mkdtemp(tmpl);
|
||||
|
||||
|
@ -222,7 +230,7 @@ int main(int argc, char *argv[], char *envp[]) {
|
|||
|
||||
argv++;
|
||||
|
||||
if (execvpe(*argv, argv, env_filter(envp)) < 0)
|
||||
if (execvpe(*argv, argv, env_filter(environ)) < 0)
|
||||
errorf(EX_OSERR, "execvpe");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue