mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
[WIP] Fix minor bugs
This commit is contained in:
parent
a79be8b6a9
commit
a8517cd65f
6 changed files with 21 additions and 17 deletions
|
@ -6,7 +6,6 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
|
@ -113,17 +112,15 @@ func runServiceRestart() error {
|
|||
restartCommand, exists := os.LookupEnv("PORTMASTER_RESTART_COMMAND")
|
||||
|
||||
// Run the service restart
|
||||
var cmd *exec.Cmd
|
||||
if exists && restartCommand != "" {
|
||||
log.Debugf(`instance: running custom restart command: "%s"`, restartCommand)
|
||||
commandSplit := strings.Split(restartCommand, " ")
|
||||
cmd := exec.Command(commandSplit[0], commandSplit[1:]...)
|
||||
_ = cmd.Run()
|
||||
cmd = exec.Command("sh", "-c", restartCommand)
|
||||
} else {
|
||||
cmd := exec.Command("systemctl", "restart", "portmaster")
|
||||
if err := cmd.Start(); err != nil {
|
||||
return fmt.Errorf("failed run restart command: %w", err)
|
||||
}
|
||||
|
||||
cmd = exec.Command("systemctl", "restart", "portmaster")
|
||||
}
|
||||
if err := cmd.Start(); err != nil {
|
||||
return fmt.Errorf("failed run restart command: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ service:
|
|||
changes <- svc.Status{State: svc.StopPending}
|
||||
ws.instance.Shutdown()
|
||||
default:
|
||||
log.Errorf("unexpected control request: #%d", c)
|
||||
log.Errorf("unexpected control request: %+v", c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,11 +25,15 @@
|
|||
!macroend
|
||||
|
||||
!macro NSIS_HOOK_POSTINSTALL
|
||||
ExecWait 'sc.exe create PortmasterCore binPath= "$INSTDIR\portmaster-core.exe" --data="$COMMONPROGRAMDATA\Portmaster\data"'
|
||||
ExecWait 'sc.exe create PortmasterCore binPath= "$INSTDIR\portmaster-core.exe" --data="$COMMONPROGRAMDATA\Portmaster\data"' $0
|
||||
IntCmp $0 0 +2
|
||||
MessageBox MB_OK "Failed to create PortmasterCore service."
|
||||
!macroend
|
||||
|
||||
!macro NSIS_HOOK_PREUNINSTALL
|
||||
ExecWait 'sc.exe stop PortmasterCore'
|
||||
ExecWait 'sc.exe delete PortmasterCore'
|
||||
ExecWait 'sc.exe stop PortmasterCore' $0
|
||||
; Ignore errors if the service is not running
|
||||
ExecWait 'sc.exe delete PortmasterCore' $0
|
||||
; Ignore errors if the service does not exist
|
||||
!macroend
|
||||
|
||||
|
|
|
@ -120,9 +120,12 @@ func checkIfFileIsValid(filename string, artifact Artifact) (bool, error) {
|
|||
defer func() { _ = file.Close() }()
|
||||
|
||||
providedHash, err := hex.DecodeString(artifact.SHA256)
|
||||
if err != nil || len(providedHash) != sha256.Size {
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("invalid provided hash %s: %w", artifact.SHA256, err)
|
||||
}
|
||||
if len(providedHash) != sha256.Size {
|
||||
return false, fmt.Errorf("invalid hash length for %s", artifact.SHA256)
|
||||
}
|
||||
|
||||
// Calculate hash of the file
|
||||
fileHash := sha256.New()
|
||||
|
|
|
@ -181,7 +181,7 @@ func (d *Downloader) downloadAndVerify(ctx context.Context) error {
|
|||
// Make sure we have the bundle file parsed.
|
||||
err := d.parseBundle()
|
||||
if err != nil {
|
||||
log.Errorf("updates: invalid update bundle file: %s", err)
|
||||
return fmt.Errorf("invalid update bundle file: %w", err)
|
||||
}
|
||||
|
||||
// Make sure dir exists
|
||||
|
|
|
@ -24,7 +24,7 @@ type testInstance struct {
|
|||
geoip *geoip.GeoIP
|
||||
}
|
||||
|
||||
func (stub *testInstance) Updates() *updates.Updates {
|
||||
func (stub *testInstance) IntelUpdates() *updates.Updates {
|
||||
return stub.updates
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ func runTest(m *testing.M) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to create config: %w", err)
|
||||
}
|
||||
stub.updates, err = updates.New(stub)
|
||||
stub.updates, err = updates.New(stub, "Intel Test", updates.UpdateIndex{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create updates: %w", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue