diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2020-12-12 18:45:06 -0500 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2022-07-12 13:43:43 +0100 |
commit | 8004653c63db5152e2a6a42e7d69eb92266e22bd (patch) | |
tree | e4060859c91b8ef7e44ea3b396eda2067be5fb7c /kit | |
parent | wsd: jail: move LO_JAIL_SUBPATH to JailUtil (diff) | |
download | online-8004653c63db5152e2a6a42e7d69eb92266e22bd.tar.gz online-8004653c63db5152e2a6a42e7d69eb92266e22bd.zip |
wsd: jail: no need to pass loSubPath between processes
Since the value of the loSubPath (i.e. the directory
name of lo within the jail) is a compile-time constant,
there is no reason to pass it around at runtime.
Change-Id: If7457ea7f3e3fe5c42215eed3ce1ce4c8f328f16
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Diffstat (limited to 'kit')
-rw-r--r-- | kit/ForKit.cpp | 24 | ||||
-rw-r--r-- | kit/Kit.cpp | 6 | ||||
-rw-r--r-- | kit/Kit.hpp | 2 |
3 files changed, 8 insertions, 24 deletions
diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index 3d9091bec8..f2b60c18a8 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -366,7 +366,6 @@ static void cleanupChildren() static int createLibreOfficeKit(const std::string& childRoot, const std::string& sysTemplate, const std::string& loTemplate, - const std::string& loSubPath, bool queryVersion = false) { // Generate a jail ID to be used for in the jail path. @@ -405,7 +404,7 @@ static int createLibreOfficeKit(const std::string& childRoot, } } - lokit_main(childRoot, jailId, sysTemplate, loTemplate, loSubPath, NoCapsForKit, NoSeccomp, + lokit_main(childRoot, jailId, sysTemplate, loTemplate, NoCapsForKit, NoSeccomp, queryVersion, DisplayVersion, spareKitId); } else @@ -432,7 +431,6 @@ static int createLibreOfficeKit(const std::string& childRoot, void forkLibreOfficeKit(const std::string& childRoot, const std::string& sysTemplate, const std::string& loTemplate, - const std::string& loSubPath, int limit) { LOG_TRC("forkLibreOfficeKit limit: " << limit); @@ -455,8 +453,7 @@ void forkLibreOfficeKit(const std::string& childRoot, const size_t retry = count * 2; for (size_t i = 0; ForkCounter > 0 && i < retry; ++i) { - if (ForkCounter-- <= 0 - || createLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath) < 0) + if (ForkCounter-- <= 0 || createLibreOfficeKit(childRoot, sysTemplate, loTemplate) < 0) { LOG_ERR("Failed to create a kit process."); ++ForkCounter; @@ -567,7 +564,6 @@ int main(int argc, char** argv) } std::string childRoot; - std::string loSubPath; std::string sysTemplate; std::string loTemplate; @@ -575,12 +571,7 @@ int main(int argc, char** argv) { char *cmd = argv[i]; char *eq; - if (std::strstr(cmd, "--losubpath=") == cmd) - { - eq = std::strchr(cmd, '='); - loSubPath = std::string(eq+1); - } - else if (std::strstr(cmd, "--systemplate=") == cmd) + if (std::strstr(cmd, "--systemplate=") == cmd) { eq = std::strchr(cmd, '='); sysTemplate = std::string(eq+1); @@ -646,7 +637,6 @@ int main(int argc, char** argv) SingleKit = true; } #endif - // we are running in a lower-privilege mode - with no chroot else if (std::strstr(cmd, "--nocaps") == cmd) { @@ -670,8 +660,7 @@ int main(int argc, char** argv) } } - if (loSubPath.empty() || sysTemplate.empty() || - loTemplate.empty() || childRoot.empty()) + if (sysTemplate.empty() || loTemplate.empty() || childRoot.empty()) { printArgumentHelp(); return EX_USAGE; @@ -728,8 +717,7 @@ int main(int argc, char** argv) // We must have at least one child, more are created dynamically. // Ask this first child to send version information to master process and trace startup. ::setenv("COOL_TRACE_STARTUP", "1", 1); - const pid_t forKitPid - = createLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath, true); + const pid_t forKitPid = createLibreOfficeKit(childRoot, sysTemplate, loTemplate, true); if (forKitPid < 0) { LOG_FTL("Failed to create a kit process."); @@ -781,7 +769,7 @@ int main(int argc, char** argv) #if ENABLE_DEBUG if (!SingleKit) #endif - forkLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath); + forkLibreOfficeKit(childRoot, sysTemplate, loTemplate); } int returnValue = EX_OK; diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 71a558215f..39b04e6e58 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -2454,7 +2454,6 @@ void lokit_main( const std::string& jailId, const std::string& sysTemplate, const std::string& loTemplate, - const std::string& loSubPath, bool noCapabilities, bool noSeccomp, bool queryVersion, @@ -2506,7 +2505,6 @@ void lokit_main( assert(!childRoot.empty()); assert(!sysTemplate.empty()); assert(!loTemplate.empty()); - assert(!loSubPath.empty()); LOG_INF("Kit process for Jail [" << jailId << "] started."); @@ -2536,9 +2534,9 @@ void lokit_main( = std::chrono::steady_clock::now(); userdir_url = "file:///tmp/user"; - instdir_path = '/' + loSubPath + "/program"; + instdir_path = '/' + std::string(JailUtil::LO_JAIL_SUBPATH) + "/program"; - Poco::Path jailLOInstallation(jailPath, loSubPath); + Poco::Path jailLOInstallation(jailPath, JailUtil::LO_JAIL_SUBPATH); jailLOInstallation.makeDirectory(); const std::string loJailDestPath = jailLOInstallation.toString(); diff --git a/kit/Kit.hpp b/kit/Kit.hpp index ee7b2ec4e4..2a4c570b15 100644 --- a/kit/Kit.hpp +++ b/kit/Kit.hpp @@ -30,7 +30,6 @@ void lokit_main( const std::string& jailId, const std::string& sysTemplate, const std::string& loTemplate, - const std::string& loSubPath, bool noCapabilities, bool noSeccomp, bool queryVersionInfo, @@ -130,7 +129,6 @@ private: void forkLibreOfficeKit(const std::string& childRoot, const std::string& sysTemplate, const std::string& loTemplate, - const std::string& loSubPath, int limit = 0); /// Anonymize the basename of filenames, preserving the path and extension. |