[WIP] Fix ui api authentication
This commit is contained in:
@@ -4,12 +4,16 @@ import (
|
||||
"errors"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/safing/portmaster/base/log"
|
||||
"github.com/safing/portmaster/service/mgr"
|
||||
"github.com/safing/portmaster/service/updates"
|
||||
)
|
||||
|
||||
type ProcessModule struct {
|
||||
mgr *mgr.Manager
|
||||
instance instance
|
||||
|
||||
portmasterUIPath string
|
||||
}
|
||||
|
||||
func (pm *ProcessModule) Manager() *mgr.Manager {
|
||||
@@ -17,6 +21,12 @@ func (pm *ProcessModule) Manager() *mgr.Manager {
|
||||
}
|
||||
|
||||
func (pm *ProcessModule) Start() error {
|
||||
file, err := pm.instance.BinaryUpdates().GetFile("portmaster")
|
||||
if err != nil {
|
||||
log.Errorf("process: failed to get path of ui: %s", err)
|
||||
} else {
|
||||
pm.portmasterUIPath = file.Path()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -59,4 +69,6 @@ func New(instance instance) (*ProcessModule, error) {
|
||||
return module, nil
|
||||
}
|
||||
|
||||
type instance interface{}
|
||||
type instance interface {
|
||||
BinaryUpdates() *updates.Updates
|
||||
}
|
||||
|
||||
@@ -72,20 +72,9 @@ func (p *Process) getSpecialProfileID() (specialProfileID string) {
|
||||
specialProfileID = profile.PortmasterProfileID
|
||||
default:
|
||||
// Check if this is another Portmaster component.
|
||||
// FIXME(vladimir): provide a better check for detecting filepath. Note there is exception on linux with portmaster ui.
|
||||
// if updatesPath != "" && strings.HasPrefix(p.Path, updatesPath) {
|
||||
// switch {
|
||||
// case strings.Contains(p.Path, "portmaster-app"):
|
||||
// specialProfileID = profile.PortmasterAppProfileID
|
||||
// case strings.Contains(p.Path, "portmaster-notifier"):
|
||||
// specialProfileID = profile.PortmasterNotifierProfileID
|
||||
// default:
|
||||
// // Unexpected binary from within the Portmaster updates directpry.
|
||||
// log.Warningf("process: unexpected binary in the updates directory: %s", p.Path)
|
||||
// // TODO: Assign a fully restricted profile in the future when we are
|
||||
// // sure that we won't kill any of our own things.
|
||||
// }
|
||||
// }
|
||||
if module.portmasterUIPath != "" && p.Path == module.portmasterUIPath {
|
||||
specialProfileID = profile.PortmasterAppProfileID
|
||||
}
|
||||
// Check if this is the system resolver.
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
|
||||
Reference in New Issue
Block a user