#include "strutils.h"
#include "pwdutils.h"
+#ifndef HAVE_ENVIRON_DECL
+extern char **environ;
+#endif
+
/* synchronize parent and child by pipe */
#define PIPE_SYNC_BYTE 0x06
fputs(USAGE_SEPARATOR, out);
fputs(_(" --monotonic <offset> set clock monotonic offset (seconds) in time namespaces\n"), out);
fputs(_(" --boottime <offset> set clock boottime offset (seconds) in time namespaces\n"), out);
+ fputs(_(" --clear-env do not inherit environment variables from the calling process\n"), out);
fputs(USAGE_SEPARATOR, out);
fprintf(out, USAGE_HELP_OPTIONS(27));
OPT_MAPSUBIDS,
OPT_OWNER,
OPT_FORWARD_SIGNALS,
+ OPT_CLEAR_ENV,
};
static const struct option longopts[] = {
{ "help", no_argument, NULL, 'h' },
{ "monotonic", required_argument, NULL, OPT_MONOTONIC },
{ "boottime", required_argument, NULL, OPT_BOOTTIME },
{ "load-interp", required_argument, NULL, 'l' },
+ { "clear-env", no_argument, NULL, OPT_CLEAR_ENV },
{ NULL, 0, NULL, 0 }
};
int64_t boottime = 0;
int force_monotonic = 0;
int force_boottime = 0;
+ int clear_env = 0;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
}
newinterp = optarg;
break;
-
+ case OPT_CLEAR_ENV:
+ clear_env = 1;
+ break;
case 'h':
usage();
case 'V':
if (keepcaps && (unshare_flags & CLONE_NEWUSER))
cap_permitted_to_ambient();
+ if (clear_env)
+#ifdef HAVE_CLEARENV
+ clearenv();
+#else
+ environ = NULL;
+#endif
+
if (optind < argc) {
execvp(argv[optind], argv + optind);
errexec(argv[optind]);