[launcherlib] Set cgroups of sandboxed apps correctly. Fixes JB#52187

Separate cgroups of sandboxed apps. Previously they were all put to the
same group with this change they are in separate groups.

Looking at invoker.c appName and fileName are the same and can be used
interchangeably.

Also change --desktop-file to have a bit more accurate description.

Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
pull/1/head
Tomi Leppänen 5 years ago
parent 7091378e7d
commit 26c5406e63

@ -416,7 +416,7 @@ static void usage(int status)
" -o, --keep-oom-score Notify invoker that the launched process should inherit oom_score_adj\n" " -o, --keep-oom-score Notify invoker that the launched process should inherit oom_score_adj\n"
" from the booster. The score is reset to 0 normally.\n" " from the booster. The score is reset to 0 normally.\n"
" -T, --test-mode Invoker test mode. Also control file in root home should be in place.\n" " -T, --test-mode Invoker test mode. Also control file in root home should be in place.\n"
" -F, --desktop-file Desktop file of the application.\n" " -F, --desktop-file Desktop file of the application to notify lipstick of launching app.\n"
" -h, --help Print this help.\n\n" " -h, --help Print this help.\n\n"
"Example: %s --type=qt5 /usr/bin/helloworld\n\n", "Example: %s --type=qt5 /usr/bin/helloworld\n\n",
PROG_NAME_INVOKER, EXIT_DELAY, RESPAWN_DELAY, MAX_RESPAWN_DELAY, PROG_NAME_INVOKER); PROG_NAME_INVOKER, EXIT_DELAY, RESPAWN_DELAY, MAX_RESPAWN_DELAY, PROG_NAME_INVOKER);
@ -468,7 +468,7 @@ static void notify_app_lauch(const char *desktop_file)
} else { } else {
info("Failed to connect to the DBus session bus: %s", error.message); info("Failed to connect to the DBus session bus: %s", error.message);
dbus_error_free(&error); dbus_error_free(&error);
return 1; return;
} }
} }

@ -107,7 +107,7 @@ void Booster::initialize(int initialArgc, char ** initialArgv, int newBoosterLau
SingleInstancePluginEntry * pluginEntry = singleInstance->pluginEntry(); SingleInstancePluginEntry * pluginEntry = singleInstance->pluginEntry();
if (pluginEntry) if (pluginEntry)
{ {
std::string lockedAppName = getLockedAppName(); std::string lockedAppName = getFinalFileName();
if (!pluginEntry->lockFunc(lockedAppName.c_str())) if (!pluginEntry->lockFunc(lockedAppName.c_str()))
{ {
// Try to activate the window of the existing instance // Try to activate the window of the existing instance
@ -433,7 +433,8 @@ void Booster::setEnvironmentBeforeLaunch()
if (!errno && cur_prio < m_appData->priority()) if (!errno && cur_prio < m_appData->priority())
setpriority(PRIO_PROCESS, 0, m_appData->priority()); setpriority(PRIO_PROCESS, 0, m_appData->priority());
setCgroup(m_appData->fileName()); std::string fileName = getFinalFileName();
setCgroup(fileName);
if (!m_appData->isPrivileged()) { if (!m_appData->isPrivileged()) {
// The application is not privileged. Drop group ID // The application is not privileged. Drop group ID
@ -615,9 +616,9 @@ void Booster::resetOomAdj()
} }
} }
std::string Booster::getLockedAppName() std::string Booster::getFinalFileName()
{ {
std::string name = m_appData->appName(); std::string name = m_appData->fileName();
if (name == "/usr/bin/sailjail") { if (name == "/usr/bin/sailjail") {
// This doesn't implement sailjail's parsing logic but instead // This doesn't implement sailjail's parsing logic but instead
// has some assumptions about the arguments: // has some assumptions about the arguments:

@ -194,8 +194,8 @@ private:
//! Helper method: load the library and find out address for "main". //! Helper method: load the library and find out address for "main".
void* loadMain(); void* loadMain();
//! Helper method: returns application name for to use for locking //! Helper method: returns application name for to use for locking etc.
std::string getLockedAppName(); std::string getFinalFileName();
//! Socket connection to invoker //! Socket connection to invoker
Connection* m_connection; Connection* m_connection;

Loading…
Cancel
Save