summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2022-09-23 09:13:05 -0400
committercobackporter[bot] <cobackporter[bot]@users.noreply.github.com>2022-09-23 16:37:04 +0000
commit0e00a25ff4b670443e579e44c85d1b150e85f4e8 (patch)
treeb1253043f21afef8e16607fe6531e73160708783
parentRemove obsolete css rules for shadow-transparency items. (diff)
downloadonline-backport/5295/distro/collabora/co-22-05.tar.gz
online-backport/5295/distro/collabora/co-22-05.zip
wsd: re-create the jail directory when mounting fails backport/5295/distro/collabora/co-22-05
This guarantees that the jail directory is always created, especially in case mounting fails and we cleanup and fallback. Also, move the directory creation and setting the perms into a helper, and reuse. Change-Id: If6e9ef86afa5107638aa27050554e94c0af22b6e Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
-rw-r--r--common/JailUtil.cpp9
-rw-r--r--common/JailUtil.hpp3
-rw-r--r--kit/Kit.cpp9
3 files changed, 16 insertions, 5 deletions
diff --git a/common/JailUtil.cpp b/common/JailUtil.cpp
index 98336581fb..9b40df36ea 100644
--- a/common/JailUtil.cpp
+++ b/common/JailUtil.cpp
@@ -206,11 +206,18 @@ void cleanupJails(const std::string& root)
LOG_WRN("Jails root directory [" << root << "] is not empty. Will not remove it.");
}
+void createJailPath(const std::string& path)
+{
+ LOG_INF("Creating jail path (if missing): " << path);
+ Poco::File(path).createDirectories();
+ chmod(path.c_str(), S_IXUSR | S_IWUSR | S_IRUSR);
+}
+
void setupChildRoot(bool bindMount, const std::string& childRoot, const std::string& sysTemplate)
{
// Start with a clean slate.
cleanupJails(childRoot);
- Poco::File(childRoot + CHILDROOT_TMP_INCOMING_PATH).createDirectories();
+ createJailPath(childRoot + CHILDROOT_TMP_INCOMING_PATH);
disableBindMounting(); // Clear to avoid surprises.
diff --git a/common/JailUtil.hpp b/common/JailUtil.hpp
index 3a670c11d0..6c61cc5ecb 100644
--- a/common/JailUtil.hpp
+++ b/common/JailUtil.hpp
@@ -42,6 +42,9 @@ void removeJail(const std::string& root);
/// Remove all jails.
void cleanupJails(const std::string& jailRoot);
+/// Creates the jail directory path recursively.
+void createJailPath(const std::string& path);
+
/// Setup the Child-Root directory.
void setupChildRoot(bool bindMount, const std::string& jailRoot, const std::string& sysTemplate);
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index d07aa70a20..b1e9cdae69 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2627,9 +2627,7 @@ void lokit_main(
#if !MOBILEAPP
const Path jailPath = Path::forDirectory(childRoot + '/' + jailId);
const std::string jailPathStr = jailPath.toString();
- LOG_INF("Jail path: " << jailPathStr);
- File(jailPath).createDirectories();
- chmod(jailPathStr.c_str(), S_IXUSR | S_IWUSR | S_IRUSR);
+ JailUtil::createJailPath(jailPathStr);
if (!ChildSession::NoCapsForKit)
{
@@ -2658,7 +2656,7 @@ void lokit_main(
// Mount loTemplate inside it.
LOG_INF("Mounting " << loTemplate << " -> " << loJailDestPath);
- Poco::File(loJailDestPath).createDirectories();
+ JailUtil::createJailPath(loJailDestPath);
if (!JailUtil::bind(loTemplate, loJailDestPath)
|| !JailUtil::remountReadonly(loTemplate, loJailDestPath))
{
@@ -2707,6 +2705,9 @@ void lokit_main(
LOG_INF("Mounting is disabled, will link/copy " << sysTemplate << " -> "
<< jailPathStr);
+ // Make sure we have the jail directory.
+ JailUtil::createJailPath(jailPathStr);
+
// Create a file to mark this a copied jail.
JailUtil::markJailCopied(jailPathStr);