mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
Merge pull request #554 from safing/fix/pidlock-process-checking
Fix checking if existing pid-lock process is portmaster-start
This commit is contained in:
commit
014ac058ce
1 changed files with 2 additions and 10 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue