fix: use /proc/pid/comm to check commands

This commit is contained in:
Aarnav Tale
2025-05-29 12:05:30 -04:00
parent 59525b7b63
commit 2f316176c8
2 changed files with 10 additions and 6 deletions
+5 -3
View File
@@ -152,12 +152,14 @@ export default class KubernetesIntegration extends Integration<T> {
return; return;
} }
const path = join('/proc', dir, 'cmdline'); const path = join('/proc', dir, 'comm');
try { try {
log.debug('config', 'Reading %s', path); log.debug('config', 'Reading %s', path);
const data = await readFile(path, 'utf8'); const data = await readFile(path, 'utf8');
if (!data.includes('headscale') && !data.includes('serve')) { if (data.trim() !== 'headscale') {
throw new Error('Found PID without Headscale serve command'); throw new Error(
`Found PID with unexpected command: ${data.trim()}`,
);
} }
return pid; return pid;
+5 -3
View File
@@ -34,12 +34,14 @@ export default class ProcIntegration extends Integration<T> {
return; return;
} }
const path = join('/proc', dir, 'cmdline'); const path = join('/proc', dir, 'comm');
try { try {
log.debug('config', 'Reading %s', path); log.debug('config', 'Reading %s', path);
const data = await readFile(path, 'utf8'); const data = await readFile(path, 'utf8');
if (!data.includes('headscale') && !data.includes('serve')) { if (data.trim() !== 'headscale') {
throw new Error('Found PID without Headscale serve command'); throw new Error(
`Found PID with unexpected command: ${data.trim()}`,
);
} }
return pid; return pid;