diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c96febca9..e117e8fab5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,17 +7,7 @@ on: branches: - main pull_request: - paths: - - 'go.mod' - - 'go.sum' - - '.goreleaser.yml' - - '.goreleaser_ui.yaml' - - '.goreleaser_ui_darwin.yaml' - - '.github/workflows/release.yml' - - 'release_files/**' - - '**/Dockerfile' - - '**/Dockerfile.*' - - 'client/ui/**' + env: SIGN_PIPE_VER: "v0.0.11" @@ -106,6 +96,27 @@ jobs: name: release path: dist/ retention-days: 3 + - + name: upload linux packages + uses: actions/upload-artifact@v3 + with: + name: linux-packages + path: dist/netbird_linux** + retention-days: 3 + - + name: upload windows packages + uses: actions/upload-artifact@v3 + with: + name: windows-packages + path: dist/netbird_windows** + retention-days: 3 + - + name: upload macos packages + uses: actions/upload-artifact@v3 + with: + name: macos-packages + path: dist/netbird_darwin** + retention-days: 3 release_ui: runs-on: ubuntu-latest diff --git a/client/firewall/uspfilter/allow_netbird_windows.go b/client/firewall/uspfilter/allow_netbird_windows.go index 140bfc87aa..34274564fa 100644 --- a/client/firewall/uspfilter/allow_netbird_windows.go +++ b/client/firewall/uspfilter/allow_netbird_windows.go @@ -64,15 +64,18 @@ func manageFirewallRule(ruleName string, action action, extraArgs ...string) err if action == addRule { args = append(args, extraArgs...) } - - cmd := exec.Command("netsh", args...) + netshCmd := GetSystem32Command("netsh") + cmd := exec.Command(netshCmd, args...) cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} return cmd.Run() } func isWindowsFirewallReachable() bool { args := []string{"advfirewall", "show", "allprofiles", "state"} - cmd := exec.Command("netsh", args...) + + netshCmd := GetSystem32Command("netsh") + + cmd := exec.Command(netshCmd, args...) cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} _, err := cmd.Output() @@ -87,8 +90,23 @@ func isWindowsFirewallReachable() bool { func isFirewallRuleActive(ruleName string) bool { args := []string{"advfirewall", "firewall", "show", "rule", "name=" + ruleName} - cmd := exec.Command("netsh", args...) + netshCmd := GetSystem32Command("netsh") + + cmd := exec.Command(netshCmd, args...) cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} _, err := cmd.Output() return err == nil } + +// GetSystem32Command checks if a command can be found in the system path and returns it. In case it can't find it +// in the path it will return the full path of a command assuming C:\windows\system32 as the base path. +func GetSystem32Command(command string) string { + _, err := exec.LookPath(command) + if err == nil { + return command + } + + log.Tracef("Command %s not found in PATH, using C:\\windows\\system32\\%s.exe path", command, command) + + return "C:\\windows\\system32\\" + command + ".exe" +} diff --git a/client/internal/routemanager/systemops_windows.go b/client/internal/routemanager/systemops_windows.go index cfe2639ec0..32e94d8da4 100644 --- a/client/internal/routemanager/systemops_windows.go +++ b/client/internal/routemanager/systemops_windows.go @@ -16,6 +16,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/yusufpapurcu/wmi" + "github.com/netbirdio/netbird/client/firewall/uspfilter" "github.com/netbirdio/netbird/client/internal/peer" "github.com/netbirdio/netbird/iface" ) @@ -173,7 +174,9 @@ func addRouteCmd(prefix netip.Prefix, nexthop netip.Addr, intf *net.Interface) e args = append(args, "if", strconv.Itoa(intf.Index)) } - out, err := exec.Command("route", args...).CombinedOutput() + routeCmd := uspfilter.GetSystem32Command("route") + + out, err := exec.Command(routeCmd, args...).CombinedOutput() log.Tracef("route %s: %s", strings.Join(args, " "), out) if err != nil { return fmt.Errorf("route add: %w", err) @@ -202,7 +205,9 @@ func removeFromRouteTable(prefix netip.Prefix, nexthop netip.Addr, _ *net.Interf args = append(args, nexthop.Unmap().String()) } - out, err := exec.Command("route", args...).CombinedOutput() + routeCmd := uspfilter.GetSystem32Command("route") + + out, err := exec.Command(routeCmd, args...).CombinedOutput() log.Tracef("route %s: %s", strings.Join(args, " "), out) if err != nil {