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"
|
#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) {
|
if (argc < 2) {
|
||||||
fprintf(stderr, "Usage: %s command [arguments...]\n"
|
fprintf(stderr, "Usage: %s command [arguments...]\n"
|
||||||
"Requires " REQUIREMENTS ".\n",
|
"Requires " REQUIREMENTS ".\n",
|
||||||
@ -163,6 +165,12 @@ int main(int argc, char *argv[], char *envp[]) {
|
|||||||
exit(EX_USAGE);
|
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 tmpl[] = "/tmp/chrootenvXXXXXX";
|
||||||
char *root = mkdtemp(tmpl);
|
char *root = mkdtemp(tmpl);
|
||||||
|
|
||||||
@ -222,7 +230,7 @@ int main(int argc, char *argv[], char *envp[]) {
|
|||||||
|
|
||||||
argv++;
|
argv++;
|
||||||
|
|
||||||
if (execvpe(*argv, argv, env_filter(envp)) < 0)
|
if (execvpe(*argv, argv, env_filter(environ)) < 0)
|
||||||
errorf(EX_OSERR, "execvpe");
|
errorf(EX_OSERR, "execvpe");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user