summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2015-12-10 07:41:03 -0400
committerHenry Castro <hcastro@collabora.com>2015-12-10 07:41:03 -0400
commite68aef6bef404882ebbb734c515d8fee58f48395 (patch)
tree5ff2a053fcd5ece74fdb8a3f423187d1ccb6ff5d
parentloolwsd: add external binary LOOLMount.cpp (diff)
downloadonline-e68aef6bef404882ebbb734c515d8fee58f48395.tar.gz
online-e68aef6bef404882ebbb734c515d8fee58f48395.zip
loolwsd: use external binary to mount systemplate
-rw-r--r--loolwsd/LOOLWSD.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 6eb50187a3..8d82121756 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -102,7 +102,7 @@ DEALINGS IN THE SOFTWARE.
#include <Poco/TemporaryFile.h>
#include <Poco/StreamCopier.h>
#include <Poco/URI.h>
-
+#include <Poco/Process.h>
#include "LOOLProtocol.hpp"
#include "LOOLSession.hpp"
@@ -842,13 +842,15 @@ void LOOLWSD::componentMain()
Path jailPath = Path::forDirectory(LOOLWSD::childRoot + Path::separator() + std::to_string(_childId));
File(jailPath).createDirectory();
- if (mount(sysTemplate.c_str(), jailPath.toString().c_str(), NULL, MS_BIND, NULL) < 0 )
- {
- std::cout << Util::logPrefix() << "Failed to mount " << sysTemplate
- << " on " << jailPath.toString() << " :"<< strerror(errno)
- << std::endl;
+ Path aCmdPath(Application::instance().commandPath());
+ Process::Args aArgs;
+ aArgs.push_back("--source=" + sysTemplate);
+ aArgs.push_back("--target=" + jailPath.toString());
+ std::string aExec = aCmdPath.parent().toString() + "loolmount";
+
+ Poco::ProcessHandle aProcess = Process::launch(aExec, aArgs);
+ if (aProcess.wait() < 0)
exit(Application::EXIT_UNAVAILABLE);
- }
// We need this because sometimes the hostname is not resolved
std::vector<std::string> networkFiles = {"/etc/host.conf", "/etc/hosts", "/etc/nsswitch.conf", "/etc/resolv.conf"};
@@ -1043,6 +1045,15 @@ void LOOLWSD::desktopMain()
setSignals(false);
#endif
+ Path aCmdPath(Application::instance().commandPath());
+ std::string aExec = aCmdPath.parent().toString() + "loolmount";
+
+ if (!File(aExec).exists())
+ {
+ std::cout << Util::logPrefix() << "Application " << aExec << " does not exists" << std::endl;
+ exit(Application::EXIT_UNAVAILABLE);
+ }
+
_rng.seed(Process::id());
startupComponent(_numPreSpawnedChildren);
@@ -1058,18 +1069,20 @@ void LOOLWSD::desktopMain()
{
std::cout << Util::logPrefix() << "One of our known child processes died :"
<< std::to_string(pid) << std::endl;
+
Path jailPath = Path::forDirectory(LOOLWSD::childRoot +
Path::separator() +
std::to_string(MasterProcessSession::_childProcesses[pid]));
- if (umount(jailPath.toString().c_str()) == 0)
+
+ Process::Args aArgs;
+ aArgs.push_back("--target=" + jailPath.toString());
+
+ Poco::ProcessHandle aProcess = Process::launch(aExec, aArgs);
+ if (aProcess.wait() == 0)
{
if (File(jailPath).exists())
File(jailPath).remove(true);
}
- else
- std::cout << Util::logPrefix() << "Failed to umount "
- << jailPath.toString() << " :"
- << strerror(errno) << std::endl;
MasterProcessSession::_childProcesses.erase(pid);
}