Add support for network service

This commit is contained in:
Daniel
2021-01-19 15:43:22 +01:00
parent 3f8c99517f
commit 12f3c0ea8d
14 changed files with 320 additions and 65 deletions

View File

@@ -2,11 +2,16 @@ package process
import (
"context"
"os"
"github.com/safing/portbase/log"
"github.com/safing/portmaster/profile"
)
var (
ownPID = os.Getpid()
)
// GetProfile finds and assigns a profile set to the process.
func (p *Process) GetProfile(ctx context.Context) (changed bool, err error) {
// Update profile metadata outside of *Process lock.
@@ -31,6 +36,8 @@ func (p *Process) GetProfile(ctx context.Context) (changed bool, err error) {
profileID = profile.UnidentifiedProfileID
case SystemProcessID:
profileID = profile.SystemProfileID
case ownPID:
profileID = profile.PortmasterProfileID
}
// Get the (linked) local profile.
@@ -56,7 +63,7 @@ func (p *Process) UpdateProfileMetadata() {
}
// Update metadata of profile.
metadataUpdated := localProfile.UpdateMetadata(p.Name)
metadataUpdated := localProfile.UpdateMetadata(p.Name, p.Path)
// Mark profile as used.
profileChanged := localProfile.MarkUsed()