aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Kay <james@hadean.com>2021-09-15 16:50:45 +0100
committerhappyCoder92 <wiktor.garbacz@gmail.com>2021-10-11 15:46:16 +0200
commite09610e78956cf7e3ef7387bd99cc406f5acb327 (patch)
treee137b096f19233e7eed802678d0948bb27b58f2d
parent246d4721b1ba790d3fa1059818c7b2596e79fff3 (diff)
downloadnsjail-e09610e78956cf7e3ef7387bd99cc406f5acb327.tar.gz
Allow mount options to contain colons.
This is particularly important for overlayfs, which allows multiple layers to be given to `lowerdir` separated by colons: see <https://www.kernel.org/doc/Documentation/filesystems/overlayfs.txt>, section ‘Multiple lower layers’.
-rw-r--r--cmdline.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/cmdline.cc b/cmdline.cc
index 0e98cd0..9aa1aba 100644
--- a/cmdline.cc
+++ b/cmdline.cc
@@ -43,6 +43,7 @@
#include <unistd.h>
#include <memory>
+#include <sstream>
#include <string>
#include <vector>
@@ -777,7 +778,12 @@ std::unique_ptr<nsjconf_t> parseArgs(int argc, char* argv[]) {
dst = src;
}
std::string fs_type = argFromVec(subopts, 2);
- std::string options = argFromVec(subopts, 3);
+ std::stringstream optionsStream;
+ optionsStream << argFromVec(subopts, 3);
+ for (std::size_t i = 4; i < subopts.size(); ++i) {
+ optionsStream << ":" << subopts[i];
+ }
+ std::string options = optionsStream.str();
if (!mnt::addMountPtTail(nsjconf.get(), src, dst, /* fstype= */ fs_type,
/* options= */ options, /* flags= */ 0,
/* is_dir= */ mnt::NS_DIR_MAYBE, /* is_mandatory= */ true,