From 81c6ed2906622343c69b3c03e48700ae7abaea8b Mon Sep 17 00:00:00 2001 From: Patrick Pacher Date: Wed, 22 Jul 2020 15:44:56 +0200 Subject: [PATCH] Show warning on unexpected portmaster-start binary path --- cmds/portmaster-start/build | 13 +++++++++++++ updates/main.go | 8 +++++++- updates/upgrader.go | 18 ++++++++++-------- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/cmds/portmaster-start/build b/cmds/portmaster-start/build index dc0992a0..26fb3525 100755 --- a/cmds/portmaster-start/build +++ b/cmds/portmaster-start/build @@ -46,6 +46,19 @@ fi # build tools EXTRA_LD_FLAGS="" if [[ $GOOS == "windows" ]]; then + # checks + if [[ $CC_FOR_windows_amd64 == "" ]]; then + echo "ENV variable CC_FOR_windows_amd64 (c compiler) is not set. Please set it to the cross compiler you want to use for compiling for windows_amd64" + exit 1 + fi + if [[ $CXX_FOR_windows_amd64 == "" ]]; then + echo "ENV variable CXX_FOR_windows_amd64 (c++ compiler) is not set. Please set it to the cross compiler you want to use for compiling for windows_amd64" + exit 1 + fi + # compilers + export CC=$CC_FOR_windows_amd64 + export CXX=$CXX_FOR_windows_amd64 + # custom export CGO_ENABLED=1 EXTRA_LD_FLAGS='-H windowsgui' # Hide console window by default (but we attach to parent console if available) # generate resource.syso for windows metadata / icon diff --git a/updates/main.go b/updates/main.go index 6718b7e0..2d2310c7 100644 --- a/updates/main.go +++ b/updates/main.go @@ -185,7 +185,13 @@ func start() error { } // react to upgrades - return initUpgrader() + if err := initUpgrader(); err != nil { + return err + } + + warnOnIncorrectParentPath() + + return nil } // TriggerUpdate queues the update task to execute ASAP. diff --git a/updates/upgrader.go b/updates/upgrader.go index 281efb92..50aacfa5 100644 --- a/updates/upgrader.go +++ b/updates/upgrader.go @@ -148,13 +148,15 @@ func upgradePortmasterStart() error { } log.Infof("updates: upgraded %s", rootPmStartPath) - // TODO(ppacher): remove once we released a few more versions ... - warnOnIncorrectParentPath(filename) - return nil } -func warnOnIncorrectParentPath(expectedFileName string) { +func warnOnIncorrectParentPath() { + expectedFileName := "portmaster-start" + if onWindows { + expectedFileName += ".exe" + } + // upgrade parent process, if it's portmaster-start parent, err := processInfo.NewProcess(int32(os.Getppid())) if err != nil { @@ -191,10 +193,10 @@ func warnOnIncorrectParentPath(expectedFileName string) { if !strings.HasPrefix(absPath, root) { log.Warningf("detected unexpected path %s for portmaster-start", absPath) - // TODO(ppacher): once we released a new installer and folks had time - // to update we should send a module warning/hint to the - // UI notifying the user that he's using portmaster-start - // from a wrong location. + notifications.NotifyWarn( + "updates:unsupported-parent", + fmt.Sprintf("The portmaster has been launched by an unexpected %s binary at %s. Please configure your system to use the binary at %s as this version will be kept up to date automatically.", expectedFileName, absPath, filepath.Join(root, expectedFileName)), + ) } }