| 414 | } |
| 415 | |
| 416 | static Subprocess launchTaskSubprocess( |
| 417 | const CommandInfo& command, |
| 418 | const string& launcherDir, |
| 419 | const Environment& environment, |
| 420 | const Option<string>& user, |
| 421 | const Option<string>& rootfs, |
| 422 | const Option<string>& sandboxDirectory, |
| 423 | const Option<string>& workingDirectory, |
| 424 | const Option<CapabilityInfo>& effectiveCapabilities, |
| 425 | const Option<CapabilityInfo>& boundingCapabilities, |
| 426 | const Option<string>& ttySlavePath, |
| 427 | const Option<ContainerLaunchInfo>& taskLaunchInfo, |
| 428 | const Option<vector<gid_t>>& taskSupplementaryGroups) |
| 429 | { |
| 430 | // Prepare the flags to pass to the launch process. |
| 431 | slave::MesosContainerizerLaunch::Flags launchFlags; |
| 432 | |
| 433 | ContainerLaunchInfo launchInfo; |
| 434 | launchInfo.mutable_command()->CopyFrom(command); |
| 435 | |
| 436 | #ifndef __WINDOWS__ |
| 437 | if (rootfs.isSome()) { |
| 438 | // The command executor is responsible for chrooting into the |
| 439 | // root filesystem and changing the user before exec-ing the |
| 440 | // user process. |
| 441 | #ifdef __linux__ |
| 442 | if (geteuid() != 0) { |
| 443 | ABORT("The command executor requires root with rootfs"); |
| 444 | } |
| 445 | |
| 446 | // Ensure that mount namespace of the executor is not affected by |
| 447 | // changes in its task's namespace induced by calling `pivot_root` |
| 448 | // as part of the task setup in mesos-containerizer binary. |
| 449 | launchFlags.unshare_namespace_mnt = true; |
| 450 | #else |
| 451 | ABORT("Not expecting root volume with non-linux platform"); |
| 452 | #endif // __linux__ |
| 453 | |
| 454 | launchInfo.set_rootfs(rootfs.get()); |
| 455 | |
| 456 | CHECK_SOME(sandboxDirectory); |
| 457 | |
| 458 | launchInfo.set_working_directory(workingDirectory.isSome() |
| 459 | ? workingDirectory.get() |
| 460 | : sandboxDirectory.get()); |
| 461 | |
| 462 | // TODO(jieyu): If the task has a rootfs, the executor itself will |
| 463 | // be running as root. Its sandbox is owned by root as well. In |
| 464 | // order for the task to be able to access to its sandbox, we need |
| 465 | // to make sure the owner of the sandbox is 'user'. However, this |
| 466 | // is still a workaround. The owner of the files downloaded by the |
| 467 | // fetcher is still not correct (i.e., root). |
| 468 | if (user.isSome()) { |
| 469 | // NOTE: We only chown the sandbox directory (non-recursively). |
| 470 | Try<Nothing> chown = os::chown(user.get(), os::getcwd(), false); |
| 471 | if (chown.isError()) { |
| 472 | ABORT("Failed to chown sandbox to user " + |
| 473 | user.get() + ": " + chown.error()); |
nothing calls this directly
no test coverage detected