mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-15 09:23:37 +00:00
af1d2bd13a
LAL manages desktop file parsing for various parts of the Lomiri environment. It also handles turning them into SystemD services tracked in the background. And due to how things work one, it's code is also SystemD-launched by itself. When we package applications with desktop files, we don't want the Exec values to be absolute, so we patch out absolute paths. Without absolute paths, PATH is expected to have the path to the executables. But our PATHs don't always contain i.e. /run/current-system/sw/bin. Services launched by SystemD are one such instance. If LAL code is run under SystemD's restricted reduced PATH, then it fails to find the requested executables. This is what happens to content-hub, and it causes all transfer requests to be met with an immediate "could not launch peer"-like error, and a transfer being stuck halfway. To work around this (I wouldn't call this a real solution?), patch LAL code to: - also propagate whatever PATH it currently *does* have to its launched applications - postfix the PATH it has with /run/current-system/sw/bin, to give it a decent fallback These changes allow for lomiri-filemanager-app to be launched via a content-hub request from lomiri-system-settings (i.e. the background selection).
60 lines
2.3 KiB
Diff
60 lines
2.3 KiB
Diff
From e4fe87427f24aa9b506c15c0f73f298e8909aabe Mon Sep 17 00:00:00 2001
|
|
From: OPNA2608 <opna2608@protonmail.com>
|
|
Date: Fri, 31 May 2024 21:31:46 +0200
|
|
Subject: [PATCH] Inject current-system PATH
|
|
|
|
---
|
|
liblomiri-app-launch/jobs-systemd.cpp | 16 ++++++++++++++++
|
|
liblomiri-app-launch/jobs-systemd.h | 1 +
|
|
2 files changed, 17 insertions(+)
|
|
|
|
diff --git a/liblomiri-app-launch/jobs-systemd.cpp b/liblomiri-app-launch/jobs-systemd.cpp
|
|
index e9be801..246bea8 100644
|
|
--- a/liblomiri-app-launch/jobs-systemd.cpp
|
|
+++ b/liblomiri-app-launch/jobs-systemd.cpp
|
|
@@ -574,6 +574,20 @@ void SystemD::copyEnvByPrefix(const std::string& prefix, std::list<std::pair<std
|
|
}
|
|
}
|
|
|
|
+/* We don't have a normal PATH, so we need to inject our special one as a fallback & propagate it */
|
|
+void SystemD::setupNixosPath(std::list<std::pair<std::string, std::string>>& env)
|
|
+{
|
|
+ std::string newPath { "/run/current-system/sw/bin" };
|
|
+ char* oldPath = getenv("PATH");
|
|
+ if (oldPath != NULL && oldPath[0] != '\0')
|
|
+ {
|
|
+ newPath.insert(0, 1, ':');
|
|
+ newPath.insert(0, oldPath);
|
|
+ }
|
|
+ setenv("PATH", newPath.c_str(), true);
|
|
+ copyEnv("PATH", env);
|
|
+}
|
|
+
|
|
std::shared_ptr<Application::Instance> SystemD::launch(
|
|
const AppID& appId,
|
|
const std::string& job,
|
|
@@ -625,6 +639,8 @@ std::shared_ptr<Application::Instance> SystemD::launch(
|
|
|
|
copyEnv("DISPLAY", env);
|
|
|
|
+ setupNixosPath(env);
|
|
+
|
|
for (const auto& prefix : {"DBUS_", "MIR_", "LOMIRI_APP_LAUNCH_"})
|
|
{
|
|
copyEnvByPrefix(prefix, env);
|
|
diff --git a/liblomiri-app-launch/jobs-systemd.h b/liblomiri-app-launch/jobs-systemd.h
|
|
index fe35932..19bf44e 100644
|
|
--- a/liblomiri-app-launch/jobs-systemd.h
|
|
+++ b/liblomiri-app-launch/jobs-systemd.h
|
|
@@ -136,6 +136,7 @@ private:
|
|
static void copyEnv(const std::string& envname, std::list<std::pair<std::string, std::string>>& env);
|
|
static void copyEnvByPrefix(const std::string& prefix, std::list<std::pair<std::string, std::string>>& env);
|
|
static int envSize(std::list<std::pair<std::string, std::string>>& env);
|
|
+ static void setupNixosPath(std::list<std::pair<std::string, std::string>>& env);
|
|
|
|
static std::vector<std::string> parseExec(std::list<std::pair<std::string, std::string>>& env);
|
|
static void application_start_cb(GObject* obj, GAsyncResult* res, gpointer user_data);
|
|
--
|
|
2.42.0
|
|
|