From f0eac815971d739caa54cd2a22143e721309ac89 Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Mon, 17 Aug 2020 20:43:39 +0300 Subject: [PATCH 1/4] Enable linter in TravisCI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ec247cd0ce..a5b461a1df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ before_script: - ci_scripts/create-ip-aliases.sh script: -# - make lint TODO(evanlinjin): Temporary due to https://github.com/golangci/golangci-lint/issues/827 + - make lint # TODO(evanlinjin): Temporary due to https://github.com/golangci/golangci-lint/issues/827 - make test - make test-no-ci - make install-deps-ui From b6cdee76accbd828a8753f03ab190e33899b66d0 Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Wed, 4 Nov 2020 10:52:14 +0300 Subject: [PATCH 2/4] Suppress linter warnings --- pkg/hypervisor/hypervisor.go | 2 +- pkg/setup/node_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/hypervisor/hypervisor.go b/pkg/hypervisor/hypervisor.go index addc961d6b..16c33de40e 100644 --- a/pkg/hypervisor/hypervisor.go +++ b/pkg/hypervisor/hypervisor.go @@ -147,7 +147,7 @@ type MockConfig struct { // AddMockData adds mock data to Hypervisor. func (hv *Hypervisor) AddMockData(config MockConfig) error { - r := rand.New(rand.NewSource(time.Now().UnixNano())) + r := rand.New(rand.NewSource(time.Now().UnixNano())) // nolint:gosec for i := 0; i < config.Visors; i++ { pk, client, err := visor.NewMockRPCClient(r, config.MaxTpsPerVisor, config.MaxRoutesPerVisor) diff --git a/pkg/setup/node_test.go b/pkg/setup/node_test.go index f5c5b0a351..a6c7eb5a17 100644 --- a/pkg/setup/node_test.go +++ b/pkg/setup/node_test.go @@ -351,7 +351,7 @@ func randRulesMap(pks []cipher.PubKey) RulesMap { func randIntermediaryRules(n int) []routing.Rule { const keepAlive = time.Second - randRtID := func() routing.RouteID { return routing.RouteID(rand.Uint32()) } + randRtID := func() routing.RouteID { return routing.RouteID(rand.Uint32()) } // nolint:gosec out := make([]routing.Rule, n) for i := range out { From 28d301bd78177ba5ec7c31c8caf949dc175fa25c Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Wed, 4 Nov 2020 11:25:43 +0300 Subject: [PATCH 3/4] Fix issues with returned error --- internal/vpn/os_client_linux.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/vpn/os_client_linux.go b/internal/vpn/os_client_linux.go index 531ce56d8e..1ad1da8ee6 100644 --- a/internal/vpn/os_client_linux.go +++ b/internal/vpn/os_client_linux.go @@ -64,15 +64,13 @@ func setupClientSysPrivileges() (suid int, err error) { // set `CAP_NET_ADMIN` capability to needed caps sets. caps.Set(capability.CAPS|capability.BOUNDS|capability.AMBIENT, capability.CAP_NET_ADMIN) if err := caps.Apply(capability.CAPS | capability.BOUNDS | capability.AMBIENT); err != nil { - err = fmt.Errorf("failed to apply capabilties: %w", err) - return + return 0, fmt.Errorf("failed to apply capabilties: %w", err) } // let child process keep caps sets from the parent, so we may do calls to // system utilities with these caps. if err := unix.Prctl(unix.PR_SET_KEEPCAPS, 1, 0, 0, 0); err != nil { - err = fmt.Errorf("failed to set PR_SET_KEEPCAPS: %w", err) - return + return 0, fmt.Errorf("failed to set PR_SET_KEEPCAPS: %w", err) } }) From b85cc8ef8e40ac7c308fcaca8e09d7ae6e40ecb3 Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Wed, 4 Nov 2020 11:36:52 +0300 Subject: [PATCH 4/4] Fix issues with returned error --- internal/vpn/os_client_linux.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/vpn/os_client_linux.go b/internal/vpn/os_client_linux.go index 1ad1da8ee6..2ce6cd2231 100644 --- a/internal/vpn/os_client_linux.go +++ b/internal/vpn/os_client_linux.go @@ -63,14 +63,16 @@ func setupClientSysPrivileges() (suid int, err error) { // set `CAP_NET_ADMIN` capability to needed caps sets. caps.Set(capability.CAPS|capability.BOUNDS|capability.AMBIENT, capability.CAP_NET_ADMIN) - if err := caps.Apply(capability.CAPS | capability.BOUNDS | capability.AMBIENT); err != nil { - return 0, fmt.Errorf("failed to apply capabilties: %w", err) + if e := caps.Apply(capability.CAPS | capability.BOUNDS | capability.AMBIENT); e != nil { + err = fmt.Errorf("failed to apply capabilties: %w", e) + return } // let child process keep caps sets from the parent, so we may do calls to // system utilities with these caps. - if err := unix.Prctl(unix.PR_SET_KEEPCAPS, 1, 0, 0, 0); err != nil { - return 0, fmt.Errorf("failed to set PR_SET_KEEPCAPS: %w", err) + if e := unix.Prctl(unix.PR_SET_KEEPCAPS, 1, 0, 0, 0); e != nil { + err = fmt.Errorf("failed to set PR_SET_KEEPCAPS: %w", e) + return } })