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
No known key found for this signature in database
2 changed files with 10 additions and 6 deletions

View File

@ -152,12 +152,14 @@ export default class KubernetesIntegration extends Integration<T> {
return;
}
const path = join('/proc', dir, 'cmdline');
const path = join('/proc', dir, 'comm');
try {
log.debug('config', 'Reading %s', path);
const data = await readFile(path, 'utf8');
if (!data.includes('headscale') && !data.includes('serve')) {
throw new Error('Found PID without Headscale serve command');
if (data.trim() !== 'headscale') {
throw new Error(
`Found PID with unexpected command: ${data.trim()}`,
);
}
return pid;

View File

@ -34,12 +34,14 @@ export default class ProcIntegration extends Integration<T> {
return;
}
const path = join('/proc', dir, 'cmdline');
const path = join('/proc', dir, 'comm');
try {
log.debug('config', 'Reading %s', path);
const data = await readFile(path, 'utf8');
if (!data.includes('headscale') && !data.includes('serve')) {
throw new Error('Found PID without Headscale serve command');
if (data.trim() !== 'headscale') {
throw new Error(
`Found PID with unexpected command: ${data.trim()}`,
);
}
return pid;