From 426e012f67700760841c307e028315da30daf672 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 2 Mar 2022 12:09:57 +0100 Subject: [PATCH] Fix checking if existing pid-lock process is portmaster-start --- cmds/portmaster-start/lock.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/cmds/portmaster-start/lock.go b/cmds/portmaster-start/lock.go index e121c1f5..673844b3 100644 --- a/cmds/portmaster-start/lock.go +++ b/cmds/portmaster-start/lock.go @@ -56,17 +56,9 @@ func checkAndCreateInstanceLock(path, name string) (pid int32, err error) { if err != nil { return 0, fmt.Errorf("failed to evaluate path of existing process: %w", err) } - ownBinaryPath, err := os.Executable() - if err != nil { - return 0, fmt.Errorf("failed to get path of own process: %w", err) - } - cleanedOwnBinaryPath, err := filepath.EvalSymlinks(ownBinaryPath) - if err != nil { - return 0, fmt.Errorf("failed to evaluate path of own process: %w", err) - } - // Check if the binary path matches. - if cleanedExecutingBinaryPath != cleanedOwnBinaryPath { + // Check if the binary is portmaster-start with high probability. + if !strings.Contains(filepath.Base(cleanedExecutingBinaryPath), "portmaster-start") { // The process with the locked PID belongs to another binary. // As the Portmaster usually starts very early, it will have a low PID, // which could be assigned to another process on next boot.