@@ -1,5 +1,18 @@
1+diff --git a/3rdparty/stout/include/stout/os/posix/chown.hpp b/3rdparty/stout/include/stout/os/posix/chown.hpp
2+index c82e2e574..15d332107 100644
3+--- a/3rdparty/stout/include/stout/os/posix/chown.hpp
4++++ b/3rdparty/stout/include/stout/os/posix/chown.hpp
5+@@ -34,7 +34,7 @@ inline Try<Nothing> chown(
6+ // TODO(bmahler): Consider walking the file tree instead. We would need
7+ // to be careful to not miss dotfiles.
8+ std::string command =
9+- "chown -R " + stringify(uid) + ':' + stringify(gid) + " '" + path + "'";
10++ "@chown@ -R " + stringify(uid) + ':' + stringify(gid) + " '" + path + "'";
11+
12+ int status = os::system(command);
13+ if (status != 0) {
114diff --git a/3rdparty/stout/include/stout/os/posix/fork.hpp b/3rdparty/stout/include/stout/os/posix/fork.hpp
2−index a29967d..290b98b 100644
15+index a29967dcb..290b98b50 100644
316--- a/3rdparty/stout/include/stout/os/posix/fork.hpp
417+++ b/3rdparty/stout/include/stout/os/posix/fork.hpp
518@@ -369,7 +369,7 @@ private:
@@ -11,48 +24,97 @@ index a29967d..290b98b 100644
1124 EXIT(EXIT_FAILURE)
1225 << "Failed to execute '" << command << "': " << os::strerror(errno);
1326 } else if (wait.isSome()) {
14−diff --git a/3rdparty/stout/include/stout/os/posix/shell.hpp b/3rdparty/stout/include/stout/os/posix/shell.hpp
15−index 1d73ae5..9bf89b5 100644
16−--- a/3rdparty/stout/include/stout/os/posix/shell.hpp
17−+++ b/3rdparty/stout/include/stout/os/posix/shell.hpp
18−@@ -37,7 +37,7 @@ namespace Shell {
19− // received by the callee, usually the command name and `arg1` is the
20− // second command argument received by the callee.
21−
22−-constexpr const char* name = "sh";
23−+constexpr const char* name = "@sh@";
24− constexpr const char* arg0 = "sh";
25− constexpr const char* arg1 = "-c";
27+diff --git a/3rdparty/stout/include/stout/posix/os.hpp b/3rdparty/stout/include/stout/posix/os.hpp
28+index c37e64db6..d3d87b7f0 100644
29+--- a/3rdparty/stout/include/stout/posix/os.hpp
30++++ b/3rdparty/stout/include/stout/posix/os.hpp
31+@@ -375,7 +375,7 @@ inline Option<std::string> getenv(const std::string& key)
32+ inline Try<Nothing> tar(const std::string& path, const std::string& archive)
33+ {
34+ Try<std::string> tarOut =
35+- os::shell("tar %s %s %s", "-czf", archive.c_str(), path.c_str());
36++ os::shell("@tar@ %s %s %s", "-czf", archive.c_str(), path.c_str());
2637
38+ if (tarOut.isError()) {
39+ return Error("Failed to archive " + path + ": " + tarOut.error());
2740diff --git a/src/Makefile.am b/src/Makefile.am
28−index 28dd151..36fc6ec 100644
41+index 3bcc0f2df..e5cbc57e8 100644
2942--- a/src/Makefile.am
3043+++ b/src/Makefile.am
31−@@ -1528,7 +1528,8 @@ if HAS_JAVA
44+@@ -1545,7 +1545,7 @@ if HAS_JAVA
3245
3346 $(MESOS_JAR): $(MESOS_JAR_SOURCE) $(MESOS_JAR_GENERATED) java/mesos.pom
3447 @echo "Building mesos-$(PACKAGE_VERSION).jar ..."
3548- @cd $(abs_top_builddir)/src/java && $(MVN) -B -f mesos.pom clean package
3649+ @cd $(abs_top_builddir)/src/java && $(MVN) -B -f mesos.pom -Dmaven.repo.local=@mavenRepo@ clean package
37−+
3850
3951 # Convenience library for JNI bindings.
4052 # TODO(Charles Reiss): We really should be building the Java library
4153diff --git a/src/cli/mesos-scp b/src/cli/mesos-scp
42−index a71ab07..feed8c4 100755
54+index a71ab0708..1043d1b3c 100755
4355--- a/src/cli/mesos-scp
4456+++ b/src/cli/mesos-scp
45−@@ -19,7 +19,7 @@ if sys.version_info < (2,6,0):
57+@@ -19,7 +19,8 @@ if sys.version_info < (2,6,0):
4658
4759
4860 def scp(host, src, dst):
4961- cmd = 'scp -pr %s %s' % (src, host + ':' + dst)
5062+ cmd = '@scp@ -pr %s %s' % (src, host + ':' + dst)
63++
5164 try:
5265 process = subprocess.Popen(
5366 cmd,
67+diff --git a/src/common/command_utils.cpp b/src/common/command_utils.cpp
68+index 09e805140..90bf65896 100644
69+--- a/src/common/command_utils.cpp
70++++ b/src/common/command_utils.cpp
71+@@ -140,7 +140,7 @@ Future<Nothing> tar(
72+
73+ argv.emplace_back(input);
74+
75+- return launch("tar", argv)
76++ return launch("@tar@", argv)
77+ .then([]() { return Nothing(); });
78+ }
79+
80+@@ -162,7 +162,7 @@ Future<Nothing> untar(
81+ argv.emplace_back(directory.get());
82+ }
83+
84+- return launch("tar", argv)
85++ return launch("@tar@", argv)
86+ .then([]() { return Nothing(); });
87+ }
88+
89+@@ -170,7 +170,7 @@ Future<Nothing> untar(
90+ Future<string> sha512(const Path& input)
91+ {
92+ #ifdef __linux__
93+- const string cmd = "sha512sum";
94++ const string cmd = "@sha512sum@";
95+ vector<string> argv = {
96+ cmd,
97+ input // Input file to compute shasum.
98+@@ -206,7 +206,7 @@ Future<Nothing> gzip(const Path& input)
99+ input
100+ };
101+
102+- return launch("gzip", argv)
103++ return launch("@gzip@", argv)
104+ .then([]() { return Nothing(); });
105+ }
106+
107+@@ -219,7 +219,7 @@ Future<Nothing> decompress(const Path& input)
108+ input
109+ };
110+
111+- return launch("gzip", argv)
112++ return launch("@gzip@", argv)
113+ .then([]() { return Nothing(); });
114+ }
115+
54116diff --git a/src/launcher/fetcher.cpp b/src/launcher/fetcher.cpp
55−index 4456c28..e22c8fc 100644
117+index 4456c2813..e22c8fc03 100644
56118--- a/src/launcher/fetcher.cpp
57119+++ b/src/launcher/fetcher.cpp
58120@@ -68,13 +68,13 @@ static Try<bool> extract(
@@ -82,11 +144,11 @@ index 4456c28..e22c8fc 100644
82144 LOG(INFO) << "Copying resource with command:" << command;
83145
84146diff --git a/src/linux/perf.cpp b/src/linux/perf.cpp
85−index ea823b3..170f54d 100644
147+index aa31982eb..8b5331b17 100644
86148--- a/src/linux/perf.cpp
87149+++ b/src/linux/perf.cpp
88−@@ -125,7 +125,7 @@ private:
89− // NOTE: The watchdog process places perf in its own process group
150+@@ -127,7 +127,7 @@ private:
151+ // NOTE: The supervisor childhook places perf in its own process group
90152 // and will kill the perf process when the parent dies.
91153 Try<Subprocess> _perf = subprocess(
92154- "perf",
@@ -104,37 +166,51 @@ index ea823b3..170f54d 100644
104166 command << " --event " << event;
105167 }
106168diff --git a/src/linux/systemd.cpp b/src/linux/systemd.cpp
107−index 619aa27..c1cbfe4 100644
169+index 6318f48fc..394d88d47 100644
108170--- a/src/linux/systemd.cpp
109171+++ b/src/linux/systemd.cpp
110−@@ -196,12 +196,19 @@ bool exists()
172+@@ -196,13 +196,21 @@ bool exists()
111173 // This is static as the init system should not change while we are running.
112174 static const bool exists = []() -> bool {
113175 // (1) Test whether `/sbin/init` links to systemd.
114176- const Result<string> realpath = os::realpath("/sbin/init");
115177- if (realpath.isError() || realpath.isNone()) {
116178- LOG(WARNING) << "Failed to test /sbin/init for systemd environment: "
117−- << realpath.error();
179+- << (realpath.isError() ? realpath.error()
180+- : "does not exist");
118181-
119182- return false;
120−+ // cstrahan: first assume we're on NixOS, then try non-NixOS
183++ // cstrahan(nixos): first assume we're on NixOS, then try non-NixOS
121184+ Result<string> realpath = os::realpath("/run/current-system/systemd/lib/systemd/systemd");
122185+ Result<string> realpathNixOS = realpath;
123186+ if (realpathNixOS.isError() || realpathNixOS.isNone()) {
124187+ Result<string> realpathNonNixOS = realpath = os::realpath("/sbin/init");
125188+ if (realpathNonNixOS.isError() || realpathNonNixOS.isNone()) {
126189+ LOG(WARNING) << "Failed to test /run/current-system/systemd/lib/systemd/systemd for systemd environment: "
127−+ << realpathNixOS.error();
190++ << (realpathNixOS.isError() ? realpathNixOS.error()
191++ : "does not exist");
128192+ LOG(WARNING) << "Failed to test /sbin/init for systemd environment: "
129−+ << realpathNonNixOS.error();
193++ << (realpathNonNixOS.isError() ? realpathNonNixOS.error()
194++ : "does not exist");
130195+
131196+ return false;
132197+ }
133198 }
134199
135200 CHECK_SOME(realpath);
201+@@ -278,6 +286,10 @@ Path hierarchy()
202+
203+ Try<Nothing> daemonReload()
204+ {
205++ // cstrahan(nixos): should we patch these `systemctl`s?
206++ // probably don't want to hard-code a particular systemd store path here,
207++ // but if we use /run/current-system/sw/bin/systemctl,
208++ // we won't be able to support non-NixOS distros.
209+ Try<string> daemonReload = os::shell("systemctl daemon-reload");
210+ if (daemonReload.isError()) {
211+ return Error("Failed to reload systemd daemon: " + daemonReload.error());
136212diff --git a/src/python/cli/src/mesos/cli.py b/src/python/cli/src/mesos/cli.py
137−index f342992..354abf4 100644
213+index f342992e0..354abf443 100644
138214--- a/src/python/cli/src/mesos/cli.py
139215+++ b/src/python/cli/src/mesos/cli.py
140216@@ -40,7 +40,7 @@ def resolve(master):
@@ -146,11 +222,70 @@ index f342992..354abf4 100644
146222 stdin=None,
147223 stdout=subprocess.PIPE,
148224 stderr=subprocess.PIPE,
225+diff --git a/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp b/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
226+index af9f3736b..f8554d414 100644
227+--- a/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
228++++ b/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
229+@@ -499,7 +499,7 @@ Future<Option<ContainerLaunchInfo>> DockerVolumeIsolatorProcess::_prepare(
230+ // unsafe arbitrary commands).
231+ CommandInfo* command = launchInfo.add_pre_exec_commands();
232+ command->set_shell(false);
233+- command->set_value("mount");
234++ command->set_value("@mount@");
235+ command->add_arguments("mount");
236+ command->add_arguments("-n");
237+ command->add_arguments("--rbind");
238+diff --git a/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp b/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
239+index df16b8fee..4a17475bd 100644
240+--- a/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
241++++ b/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
242+@@ -159,9 +159,9 @@ Try<Isolator*> LinuxFilesystemIsolatorProcess::create(const Flags& flags)
243+ // here because 'create' will only be invoked during
244+ // initialization.
245+ Try<string> mount = os::shell(
246+- "mount --bind %s %s && "
247+- "mount --make-private %s && "
248+- "mount --make-shared %s",
249++ "@mount@ --bind %s %s && "
250++ "@mount@ --make-private %s && "
251++ "@mount@ --make-shared %s",
252+ workDir->c_str(),
253+ workDir->c_str(),
254+ workDir->c_str(),
255+@@ -180,8 +180,8 @@ Try<Isolator*> LinuxFilesystemIsolatorProcess::create(const Flags& flags)
256+ LOG(INFO) << "Making '" << workDir.get() << "' a shared mount";
257+
258+ Try<string> mount = os::shell(
259+- "mount --make-private %s && "
260+- "mount --make-shared %s",
261++ "@mount@ --make-private %s && "
262++ "@mount@ --make-shared %s",
263+ workDir->c_str(),
264+ workDir->c_str());
265+
266+@@ -404,7 +404,7 @@ Try<vector<CommandInfo>> LinuxFilesystemIsolatorProcess::getPreExecCommands(
267+
268+ CommandInfo command;
269+ command.set_shell(false);
270+- command.set_value("mount");
271++ command.set_value("@mount@");
272+ command.add_arguments("mount");
273+ command.add_arguments("-n");
274+ command.add_arguments("--rbind");
275+@@ -569,7 +569,7 @@ Try<vector<CommandInfo>> LinuxFilesystemIsolatorProcess::getPreExecCommands(
276+ // TODO(jieyu): Consider the mode in the volume.
277+ CommandInfo command;
278+ command.set_shell(false);
279+- command.set_value("mount");
280++ command.set_value("@mount@");
281+ command.add_arguments("mount");
282+ command.add_arguments("-n");
283+ command.add_arguments("--rbind");
149284diff --git a/src/slave/containerizer/mesos/isolators/filesystem/shared.cpp b/src/slave/containerizer/mesos/isolators/filesystem/shared.cpp
150−index 51d1518..783adb5 100644
285+index a1283e5ee..a918427bf 100644
151286--- a/src/slave/containerizer/mesos/isolators/filesystem/shared.cpp
152287+++ b/src/slave/containerizer/mesos/isolators/filesystem/shared.cpp
153−@@ -204,7 +204,7 @@ Future<Option<ContainerLaunchInfo>> SharedFilesystemIsolatorProcess::prepare(
288+@@ -207,7 +207,7 @@ Future<Option<ContainerLaunchInfo>> SharedFilesystemIsolatorProcess::prepare(
154289 }
155290
156291 launchInfo.add_pre_exec_commands()->set_value(
@@ -159,36 +294,148 @@ index 51d1518..783adb5 100644
159294 }
160295
161296 return launchInfo;
297+diff --git a/src/slave/containerizer/mesos/isolators/gpu/isolator.cpp b/src/slave/containerizer/mesos/isolators/gpu/isolator.cpp
298+index e3756c920..cfe458b59 100644
299+--- a/src/slave/containerizer/mesos/isolators/gpu/isolator.cpp
300++++ b/src/slave/containerizer/mesos/isolators/gpu/isolator.cpp
301+@@ -355,7 +355,7 @@ Future<Option<ContainerLaunchInfo>> NvidiaGpuIsolatorProcess::_prepare(
302+ }
303+
304+ launchInfo.add_pre_exec_commands()->set_value(
305+- "mount --no-mtab --rbind --read-only " +
306++ "@mount@ --no-mtab --rbind --read-only " +
307+ volume.HOST_PATH() + " " + target);
308+ }
309+
310+diff --git a/src/slave/containerizer/mesos/isolators/gpu/volume.cpp b/src/slave/containerizer/mesos/isolators/gpu/volume.cpp
311+index 478752f37..ab527f0cd 100644
312+--- a/src/slave/containerizer/mesos/isolators/gpu/volume.cpp
313++++ b/src/slave/containerizer/mesos/isolators/gpu/volume.cpp
314+@@ -281,7 +281,7 @@ Try<NvidiaVolume> NvidiaVolume::create()
315+ string path = path::join(hostPath, "bin", binary);
316+
317+ if (!os::exists(path)) {
318+- string command = "which " + binary;
319++ string command = "@which@ " + binary;
320+ Try<string> which = os::shell(command);
321+
322+ if (which.isSome()) {
323+@@ -295,7 +295,7 @@ Try<NvidiaVolume> NvidiaVolume::create()
324+ : "No such file or directory"));
325+ }
326+
327+- command = "cp " + realpath.get() + " " + path;
328++ command = "@cp@ " + realpath.get() + " " + path;
329+ Try<string> cp = os::shell(command);
330+ if (cp.isError()) {
331+ return Error("Failed to os::shell '" + command + "': " + cp.error());
332+@@ -367,7 +367,7 @@ Try<NvidiaVolume> NvidiaVolume::create()
333+ Path(realpath.get()).basename());
334+
335+ if (!os::exists(libraryPath)) {
336+- string command = "cp " + realpath.get() + " " + libraryPath;
337++ string command = "@cp@ " + realpath.get() + " " + libraryPath;
338+ Try<string> cp = os::shell(command);
339+ if (cp.isError()) {
340+ return Error("Failed to os::shell '" + command + "':"
162341diff --git a/src/slave/containerizer/mesos/isolators/namespaces/pid.cpp b/src/slave/containerizer/mesos/isolators/namespaces/pid.cpp
163−index b41e266..e07c163 100644
342+index 0d9ec57d9..a177e4476 100644
164343--- a/src/slave/containerizer/mesos/isolators/namespaces/pid.cpp
165344+++ b/src/slave/containerizer/mesos/isolators/namespaces/pid.cpp
166−@@ -163,7 +163,7 @@ Future<Option<ContainerLaunchInfo>> NamespacesPidIsolatorProcess::prepare(
167− // containers cannot see the namespace bind mount of other
168− // containers.
169− launchInfo.add_pre_exec_commands()->set_value(
170−- "mount -n --bind " + string(PID_NS_BIND_MOUNT_MASK_DIR) +
171−+ "@mount@ -n --bind " + string(PID_NS_BIND_MOUNT_MASK_DIR) +
172− " " + string(PID_NS_BIND_MOUNT_ROOT));
173−
174− // Mount /proc for the container's pid namespace to show the
175−@@ -176,9 +176,9 @@ Future<Option<ContainerLaunchInfo>> NamespacesPidIsolatorProcess::prepare(
176− // -n flag so the mount is not added to the mtab where it will not
177− // be correctly removed with the namespace terminates.
178− launchInfo.add_pre_exec_commands()->set_value(
179−- "mount none /proc --make-private -o rec");
180−+ "@mount@ none /proc --make-private -o rec");
345+@@ -94,7 +94,7 @@ Future<Option<ContainerLaunchInfo>> NamespacesPidIsolatorProcess::prepare(
346+ //
347+ // TOOD(jieyu): Consider unmount the existing /proc.
181348 launchInfo.add_pre_exec_commands()->set_value(
182349- "mount -n -t proc proc /proc -o nosuid,noexec,nodev");
183350+ "@mount@ -n -t proc proc /proc -o nosuid,noexec,nodev");
184351
185352 return launchInfo;
186353 }
354+diff --git a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
355+index c87e6715a..6601cd1b3 100644
356+--- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
357++++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
358+@@ -262,9 +262,9 @@ Try<Isolator*> NetworkCniIsolatorProcess::create(const Flags& flags)
359+ // here because 'create' will only be invoked during
360+ // initialization.
361+ Try<string> mount = os::shell(
362+- "mount --bind %s %s && "
363+- "mount --make-private %s && "
364+- "mount --make-shared %s",
365++ "@mount@ --bind %s %s && "
366++ "@mount@ --make-private %s && "
367++ "@mount@ --make-shared %s",
368+ rootDir->c_str(),
369+ rootDir->c_str(),
370+ rootDir->c_str(),
371+@@ -284,8 +284,8 @@ Try<Isolator*> NetworkCniIsolatorProcess::create(const Flags& flags)
372+ LOG(INFO) << "Making '" << rootDir.get() << "' a shared mount";
373+
374+ Try<string> mount = os::shell(
375+- "mount --make-private %s && "
376+- "mount --make-shared %s",
377++ "@mount@ --make-private %s && "
378++ "@mount@ --make-shared %s",
379+ rootDir->c_str(),
380+ rootDir->c_str());
381+
382+diff --git a/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp b/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
383+index b470f0c82..6110a43ee 100644
384+--- a/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
385++++ b/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
386+@@ -303,7 +303,7 @@ Try<Nothing> PortMapper::addPortMapping(
387+ # Check if the `chain` exists in the iptable. If it does not
388+ # exist go ahead and install the chain in the iptables NAT
389+ # table.
390+- iptables -w -t nat --list %s
391++ @iptables@ -w -t nat --list %s
392+ if [ $? -ne 0 ]; then
393+ # NOTE: When we create the chain, there is a possibility of a
394+ # race due to which a container launch can fail. This can
395+@@ -317,25 +317,25 @@ Try<Nothing> PortMapper::addPortMapping(
396+ # since it can happen only when the chain is created the first
397+ # time and two commands for creation of the chain are executed
398+ # simultaneously.
399+- (iptables -w -t nat -N %s || exit 1)
400++ (@iptables@ -w -t nat -N %s || exit 1)
401+
402+ # Once the chain has been installed add a rule in the PREROUTING
403+ # chain to jump to this chain for any packets that are
404+ # destined to a local address.
405+- (iptables -w -t nat -A PREROUTING \
406++ (@iptables@ -w -t nat -A PREROUTING \
407+ -m addrtype --dst-type LOCAL -j %s || exit 1)
408+
409+ # For locally generated packets we need a rule in the OUTPUT
410+ # chain as well, since locally generated packets directly hit
411+ # the output CHAIN, bypassing PREROUTING.
412+- (iptables -w -t nat -A OUTPUT \
413++ (@iptables@ -w -t nat -A OUTPUT \
414+ ! -d 127.0.0.0/8 -m addrtype \
415+ --dst-type LOCAL -j %s || exit 1)
416+ fi
417+
418+ # Within the `chain` go ahead and install the DNAT rule, if it
419+ # does not exist.
420+- (iptables -w -t nat -C %s || iptables -t nat -A %s))~",
421++ (@iptables@ -w -t nat -C %s || @iptables@ -t nat -A %s))~",
422+ chain,
423+ chain,
424+ chain,
425+@@ -362,7 +362,7 @@ Try<Nothing> PortMapper::delPortMapping()
426+ # The iptables command searches for the DNAT rules with tag
427+ # "container_id: <CNI_CONTAINERID>", and if it exists goes ahead
428+ # and deletes it.
429+- iptables -w -t nat -S %s | sed "/%s/ s/-A/iptables -w -t nat -D/e")~",
430++ @iptables@ -w -t nat -S %s | sed "/%s/ s/-A/@iptables@ -w -t nat -D/e")~",
431+ chain,
432+ getIptablesRuleTag()).get();
433+
187434diff --git a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
188−index 79ee960..d55a353 100644
435+index 20fb6ab35..46c160977 100644
189436--- a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
190437+++ b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
191−@@ -1392,19 +1392,19 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
438+@@ -1393,19 +1393,19 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
192439 // Check the availability of a few Linux commands that we will use.
193440 // We use the blocking os::shell here because 'create' will only be
194441 // invoked during initialization.
@@ -211,7 +458,7 @@ index 79ee960..d55a353 100644
211458 if (checkCommandIp.isError()) {
212459 return Error("Check command 'ip' failed: " + checkCommandIp.error());
213460 }
214−@@ -1924,9 +1924,9 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
461+@@ -1925,9 +1925,9 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
215462 // visible. It's OK to use the blocking os::shell here because
216463 // 'create' will only be invoked during initialization.
217464 Try<string> mount = os::shell(
@@ -224,7 +471,7 @@ index 79ee960..d55a353 100644
224471 bindMountRoot->c_str(),
225472 bindMountRoot->c_str(),
226473 bindMountRoot->c_str(),
227−@@ -1943,8 +1943,8 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
474+@@ -1944,8 +1944,8 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
228475 // shared mount yet (possibly due to slave crash while preparing
229476 // the work directory mount). It's safe to re-do the following.
230477 Try<string> mount = os::shell(
@@ -235,7 +482,7 @@ index 79ee960..d55a353 100644
235482 bindMountRoot->c_str(),
236483 bindMountRoot->c_str());
237484
238−@@ -1963,8 +1963,8 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
485+@@ -1964,8 +1964,8 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
239486 // so that they are in different peer groups.
240487 if (entry.shared() == bindMountEntry->shared()) {
241488 Try<string> mount = os::shell(
@@ -246,14 +493,16 @@ index 79ee960..d55a353 100644
246493 bindMountRoot->c_str(),
247494 bindMountRoot->c_str());
248495
249−@@ -3916,13 +3916,13 @@ string PortMappingIsolatorProcess::scripts(Info* info)
496+@@ -3911,6 +3911,8 @@ Try<Nothing> PortMappingIsolatorProcess::removeHostIPFilters(
497+ // TODO(jieyu): Use the Subcommand abstraction to remove most of the
498+ // logic here. Completely remove this function once we can assume a
499+ // newer kernel where 'setns' works for mount namespaces.
500++// cstrahan(nixos): this is executed in the container,
501++// so we don't want to substitute paths here.
502+ string PortMappingIsolatorProcess::scripts(Info* info)
250503 {
251504 ostringstream script;
252−
253−- script << "#!/bin/sh\n";
254−+ script << "#!@sh@\n";
255− script << "set -xe\n";
256−
505+@@ -3921,7 +3923,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
257506 // Mark the mount point PORT_MAPPING_BIND_MOUNT_ROOT() as slave
258507 // mount so that changes in the container will not be propagated to
259508 // the host.
@@ -262,7 +511,7 @@ index 79ee960..d55a353 100644
262511
263512 // Disable IPv6 when IPv6 module is loaded as IPv6 packets won't be
264513 // forwarded anyway.
265−@@ -3930,7 +3930,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
514+@@ -3929,7 +3931,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
266515 << " echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6\n";
267516
268517 // Configure lo and eth0.
@@ -271,7 +520,7 @@ index 79ee960..d55a353 100644
271520 << " mtu " << hostEth0MTU << " up\n";
272521
273522 // NOTE: This is mostly a kernel issue: in veth_xmit() the kernel
274−@@ -3939,12 +3939,12 @@ string PortMappingIsolatorProcess::scripts(Info* info)
523+@@ -3938,12 +3940,12 @@ string PortMappingIsolatorProcess::scripts(Info* info)
275524 // when we receive a packet with a bad checksum. Disabling rx
276525 // checksum offloading ensures the TCP layer will checksum and drop
277526 // it.
@@ -288,7 +537,7 @@ index 79ee960..d55a353 100644
288537
289538 // Restrict the ephemeral ports that can be used by the container.
290539 script << "echo " << info->ephemeralPorts.lower() << " "
291−@@ -3973,19 +3973,19 @@ string PortMappingIsolatorProcess::scripts(Info* info)
540+@@ -3972,19 +3974,19 @@ string PortMappingIsolatorProcess::scripts(Info* info)
292541 }
293542
294543 // Set up filters on lo and eth0.
@@ -312,7 +561,7 @@ index 79ee960..d55a353 100644
312561 << " protocol ip"
313562 << " prio " << Priority(IP_FILTER_PRIORITY, NORMAL).get() << " u32"
314563 << " flowid ffff:0"
315−@@ -3996,7 +3996,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
564+@@ -3995,7 +3997,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
316565 foreach (const PortRange& range,
317566 getPortRanges(info->nonEphemeralPorts + info->ephemeralPorts)) {
318567 // Local traffic inside a container will not be redirected to eth0.
@@ -321,7 +570,7 @@ index 79ee960..d55a353 100644
321570 << " protocol ip"
322571 << " prio " << Priority(IP_FILTER_PRIORITY, HIGH).get() << " u32"
323572 << " flowid ffff:0"
324−@@ -4005,7 +4005,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
573+@@ -4004,7 +4006,7 @@ string PortMappingIsolatorProcess::scripts(Info* info)
325574
326575 // Traffic going to host loopback IP and ports assigned to this
327576 // container will be redirected to lo.
@@ -330,7 +579,7 @@ index 79ee960..d55a353 100644
330579 << " protocol ip"
331580 << " prio " << Priority(IP_FILTER_PRIORITY, NORMAL).get() << " u32"
332581 << " flowid ffff:0"
333−@@ -4017,14 +4017,14 @@ string PortMappingIsolatorProcess::scripts(Info* info)
582+@@ -4016,14 +4018,14 @@ string PortMappingIsolatorProcess::scripts(Info* info)
334583 }
335584
336585 // Do not forward the ICMP packet if the destination IP is self.
@@ -347,7 +596,7 @@ index 79ee960..d55a353 100644
347596 << " protocol ip"
348597 << " prio " << Priority(ICMP_FILTER_PRIORITY, NORMAL).get() << " u32"
349598 << " flowid ffff:0"
350−@@ -4033,9 +4033,9 @@ string PortMappingIsolatorProcess::scripts(Info* info)
599+@@ -4032,9 +4034,9 @@ string PortMappingIsolatorProcess::scripts(Info* info)
351600 << net::IPNetwork::LOOPBACK_V4().address() << "\n";
352601
353602 // Display the filters created on eth0 and lo.
@@ -359,7 +608,7 @@ index 79ee960..d55a353 100644
359608 << " parent " << ingress::HANDLE << "\n";
360609
361610 // If throughput limit for container egress traffic exists, use HTB
362−@@ -4047,9 +4047,9 @@ string PortMappingIsolatorProcess::scripts(Info* info)
611+@@ -4046,9 +4048,9 @@ string PortMappingIsolatorProcess::scripts(Info* info)
363612 // throughput. TBF requires other parameters such as 'burst' that
364613 // HTB already has default values for.
365614 if (egressRateLimitPerContainer.isSome()) {
@@ -371,12 +620,12 @@ index 79ee960..d55a353 100644
371620 << CONTAINER_TX_HTB_HANDLE << " classid "
372621 << CONTAINER_TX_HTB_CLASS_ID << " htb rate "
373622 << egressRateLimitPerContainer.get().bytes() * 8 << "bit\n";
374−@@ -4060,12 +4060,12 @@ string PortMappingIsolatorProcess::scripts(Info* info)
623+@@ -4059,12 +4061,12 @@ string PortMappingIsolatorProcess::scripts(Info* info)
375624 // fq_codel, which has a larger buffer and better control on
376625 // buffer bloat.
377626 // TODO(cwang): Verity that fq_codel qdisc is available.
378627- script << "tc qdisc add dev " << eth0
379−+ script << "@tC@ qdisc add dev " << eth0
628++ script << "@tc@ qdisc add dev " << eth0
380629 << " parent " << CONTAINER_TX_HTB_CLASS_ID << " fq_codel\n";
381630
382631 // Display the htb qdisc and class created on eth0.
@@ -388,11 +637,11 @@ index 79ee960..d55a353 100644
388637
389638 return script.str();
390639diff --git a/src/slave/containerizer/mesos/isolators/posix/disk.cpp b/src/slave/containerizer/mesos/isolators/posix/disk.cpp
391−index 3dfe7ad..4288666 100644
640+index db0583386..542586370 100644
392641--- a/src/slave/containerizer/mesos/isolators/posix/disk.cpp
393642+++ b/src/slave/containerizer/mesos/isolators/posix/disk.cpp
394−@@ -492,7 +492,7 @@ private:
395− // NOTE: The monitor watchdog will watch the parent process and kill
643+@@ -540,7 +540,7 @@ private:
644+ // NOTE: The supervisor childhook will watch the parent process and kill
396645 // the 'du' process in case that the parent die.
397646 Try<Subprocess> s = subprocess(
398647- "du",
@@ -400,11 +649,37 @@ index 3dfe7ad..4288666 100644
400649 command,
401650 Subprocess::PATH("/dev/null"),
402651 Subprocess::PIPE(),
652+diff --git a/src/slave/containerizer/mesos/isolators/volume/image.cpp b/src/slave/containerizer/mesos/isolators/volume/image.cpp
653+index 210e67ad0..60b3a15e4 100644
654+--- a/src/slave/containerizer/mesos/isolators/volume/image.cpp
655++++ b/src/slave/containerizer/mesos/isolators/volume/image.cpp
656+@@ -214,7 +214,7 @@ Future<Option<ContainerLaunchInfo>> VolumeImageIsolatorProcess::_prepare(
657+
658+ CommandInfo* command = launchInfo.add_pre_exec_commands();
659+ command->set_shell(false);
660+- command->set_value("mount");
661++ command->set_value("@mount@");
662+ command->add_arguments("mount");
663+ command->add_arguments("-n");
664+ command->add_arguments("--rbind");
665+diff --git a/src/slave/containerizer/mesos/isolators/volume/sandbox_path.cpp b/src/slave/containerizer/mesos/isolators/volume/sandbox_path.cpp
666+index 7b976d292..474dcd486 100644
667+--- a/src/slave/containerizer/mesos/isolators/volume/sandbox_path.cpp
668++++ b/src/slave/containerizer/mesos/isolators/volume/sandbox_path.cpp
669+@@ -240,7 +240,7 @@ Future<Option<ContainerLaunchInfo>> VolumeSandboxPathIsolatorProcess::prepare(
670+
671+ CommandInfo* command = launchInfo.add_pre_exec_commands();
672+ command->set_shell(false);
673+- command->set_value("mount");
674++ command->set_value("@mount@");
675+ command->add_arguments("mount");
676+ command->add_arguments("-n");
677+ command->add_arguments("--rbind");
403678diff --git a/src/slave/containerizer/mesos/provisioner/backends/copy.cpp b/src/slave/containerizer/mesos/provisioner/backends/copy.cpp
404−index b9f6d7a..0fcf455 100644
679+index 9c5354e5f..a73a9692e 100644
405680--- a/src/slave/containerizer/mesos/provisioner/backends/copy.cpp
406681+++ b/src/slave/containerizer/mesos/provisioner/backends/copy.cpp
407−@@ -141,7 +141,7 @@ Future<Nothing> CopyBackendProcess::_provision(
682+@@ -147,7 +147,7 @@ Future<Nothing> CopyBackendProcess::_provision(
408683 #endif // __APPLE__ || __FreeBSD__
409684
410685 Try<Subprocess> s = subprocess(
@@ -413,11 +688,20 @@ index b9f6d7a..0fcf455 100644
413688 args,
414689 Subprocess::PATH("/dev/null"),
415690 Subprocess::PATH("/dev/null"),
691+@@ -180,7 +180,7 @@ Future<bool> CopyBackendProcess::destroy(const string& rootfs)
692+ vector<string> argv{"rm", "-rf", rootfs};
693+
694+ Try<Subprocess> s = subprocess(
695+- "rm",
696++ "@rm@",
697+ argv,
698+ Subprocess::PATH("/dev/null"),
699+ Subprocess::FD(STDOUT_FILENO),
416700diff --git a/src/uri/fetchers/copy.cpp b/src/uri/fetchers/copy.cpp
417−index f095ad6..ee0c2a7 100644
701+index 2cfef5ab0..8a62f7699 100644
418702--- a/src/uri/fetchers/copy.cpp
419703+++ b/src/uri/fetchers/copy.cpp
420−@@ -88,7 +88,7 @@ Future<Nothing> CopyFetcherPlugin::fetch(
704+@@ -97,7 +97,7 @@ Future<Nothing> CopyFetcherPlugin::fetch(
421705 const vector<string> argv = {"cp", "-a", uri.path(), directory};
422706
423707 Try<Subprocess> s = subprocess(
@@ -427,10 +711,10 @@ index f095ad6..ee0c2a7 100644
427711 Subprocess::PATH("/dev/null"),
428712 Subprocess::PIPE(),
429713diff --git a/src/uri/fetchers/curl.cpp b/src/uri/fetchers/curl.cpp
430−index cc3f9ee..691d2d9 100644
714+index 7b746d619..12bbb04df 100644
431715--- a/src/uri/fetchers/curl.cpp
432716+++ b/src/uri/fetchers/curl.cpp
433−@@ -98,7 +98,7 @@ Future<Nothing> CurlFetcherPlugin::fetch(
717+@@ -107,7 +107,7 @@ Future<Nothing> CurlFetcherPlugin::fetch(
434718 };
435719
436720 Try<Subprocess> s = subprocess(
@@ -440,10 +724,10 @@ index cc3f9ee..691d2d9 100644
440724 Subprocess::PATH("/dev/null"),
441725 Subprocess::PIPE(),
442726diff --git a/src/uri/fetchers/docker.cpp b/src/uri/fetchers/docker.cpp
443−index 211be6f..d7e3771 100644
727+index 3f38dddfb..fd991ee74 100644
444728--- a/src/uri/fetchers/docker.cpp
445729+++ b/src/uri/fetchers/docker.cpp
446−@@ -113,7 +113,7 @@ static Future<http::Response> curl(
730+@@ -114,7 +114,7 @@ static Future<http::Response> curl(
447731
448732 // TODO(jieyu): Kill the process if discard is called.
449733 Try<Subprocess> s = subprocess(
@@ -452,7 +736,7 @@ index 211be6f..d7e3771 100644
452736 argv,
453737 Subprocess::PATH("/dev/null"),
454738 Subprocess::PIPE(),
455−@@ -212,7 +212,7 @@ static Future<int> download(
739+@@ -213,7 +213,7 @@ static Future<int> download(
456740
457741 // TODO(jieyu): Kill the process if discard is called.
458742 Try<Subprocess> s = subprocess(