Use special profiles for Portmaster components and mark them as internal

This commit is contained in:
Daniel
2021-02-11 13:06:32 +01:00
parent 6cc0e470ee
commit 971edcfa41
7 changed files with 125 additions and 31 deletions

View File

@@ -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
}

View File

@@ -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.