@remcp/remcp 0.2.238 → 0.2.239
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli/service-linux.mjs +8 -5
- package/src/cli/service.mjs +3 -1
package/package.json
CHANGED
|
@@ -40,13 +40,16 @@ export function linuxActiveServiceFile() {
|
|
|
40
40
|
// even if systemctl --user enable --now reported success.
|
|
41
41
|
export function ensureLinuxLinger() {
|
|
42
42
|
if (process.platform !== 'linux') return;
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
if (
|
|
46
|
-
|
|
43
|
+
// Test-only synthetic HOME has no logind account and must never mutate the host.
|
|
44
|
+
// Guard before os.userInfo(): an isolated CI UID may not have a passwd entry.
|
|
45
|
+
if (process.env.NODE_ENV === 'test' && process.env.REMCP_TEST_PLATFORM === 'linux') return;
|
|
46
|
+
let account;
|
|
47
|
+
try { account = os.userInfo(); }
|
|
48
|
+
catch { throw new Error('ReMCP cannot resolve the current Linux account for persistent systemd supervision.'); }
|
|
49
|
+
if (path.resolve(home) !== path.resolve(account.homedir)) {
|
|
47
50
|
throw new Error('Refusing a persistent Linux service with HOME different from the account home directory.');
|
|
48
51
|
}
|
|
49
|
-
const username =
|
|
52
|
+
const username = account.username;
|
|
50
53
|
const query = () => spawnSync('loginctl', ['show-user', username, '-p', 'Linger', '--value'],
|
|
51
54
|
{ encoding:'utf8', timeout:10000 });
|
|
52
55
|
let state = query();
|
package/src/cli/service.mjs
CHANGED
|
@@ -66,7 +66,9 @@ export function installLinuxService(cliPath = globalCliPath(), nodePath = proces
|
|
|
66
66
|
const launcherFile = writeLinuxServiceLauncher(cliPath, nodePath);
|
|
67
67
|
// Fresh root installs are boot services owned by PID 1. Legacy per-user units are
|
|
68
68
|
// left under their existing supervisor, but must have linger enabled.
|
|
69
|
-
const
|
|
69
|
+
const syntheticLinuxFixture = process.env.NODE_ENV === 'test' && process.env.REMCP_TEST_PLATFORM === 'linux';
|
|
70
|
+
const privileged = !syntheticLinuxFixture && process.getuid?.() === 0
|
|
71
|
+
&& path.resolve(home) === path.resolve(os.userInfo().homedir);
|
|
70
72
|
if (privileged && fs.existsSync(linuxSystemServiceFile) && !linuxSystemAgentOwned()) {
|
|
71
73
|
throw new Error('Refusing to replace an unmanaged systemd remcp-agent.service');
|
|
72
74
|
}
|