Use special profiles for Portmaster components and mark them as internal
This commit is contained in:
@@ -1,17 +1,30 @@
|
||||
package process
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/safing/portbase/modules"
|
||||
"github.com/safing/portmaster/updates"
|
||||
)
|
||||
|
||||
var (
|
||||
module *modules.Module
|
||||
module *modules.Module
|
||||
updatesPath string
|
||||
)
|
||||
|
||||
func init() {
|
||||
module = modules.Register("processes", prep, nil, nil, "profiles")
|
||||
module = modules.Register("processes", prep, start, nil, "profiles")
|
||||
}
|
||||
|
||||
func prep() error {
|
||||
return registerConfiguration()
|
||||
}
|
||||
|
||||
func start() error {
|
||||
updatesPath = updates.RootPath() + string(os.PathSeparator)
|
||||
if updatesPath != "" {
|
||||
updatesPath += string(os.PathSeparator)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package process
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portmaster/profile"
|
||||
@@ -38,6 +39,16 @@ func (p *Process) GetProfile(ctx context.Context) (changed bool, err error) {
|
||||
profileID = profile.SystemProfileID
|
||||
case ownPID:
|
||||
profileID = profile.PortmasterProfileID
|
||||
default:
|
||||
// Check if this is another Portmaster component.
|
||||
if updatesPath != "" && strings.HasPrefix(p.Path, updatesPath) {
|
||||
switch {
|
||||
case strings.Contains(p.Path, "portmaster-app"):
|
||||
profileID = profile.PortmasterAppProfileID
|
||||
case strings.Contains(p.Path, "portmaster-notifier"):
|
||||
profileID = profile.PortmasterNotifierProfileID
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the (linked) local profile.
|
||||
|
||||
Reference in New Issue
Block a user