From 0d49685c0ef1502e6cb57f655c2e5ae6b00d8e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Wed, 5 Jun 2024 18:44:33 -0400 Subject: [PATCH 1/6] github: Drop firewall rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- .github/workflows/test.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0f0c824..cd29e17 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,15 @@ jobs: - name: Install dependencies run: | sudo add-apt-repository ppa:ubuntu-lxc/daily -y - sudo apt-get install -qq apparmor lxc lxc-dev pkg-config uidmap busybox libdbus-1-dev libseccomp-dev libcap-dev libselinux-dev + sudo apt-get install -qq apparmor lxc lxc-dev pkg-config uidmap busybox libdbus-1-dev libseccomp-dev libcap-dev libselinux-dev nftables iptables + + - name: Reset all firewalling + run: | + sudo iptables -F + sudo iptables -P INPUT ACCEPT + sudo iptables -P OUTPUT ACCEPT + sudo iptables -P FORWARD ACCEPT + sudo nft flush ruleset - name: Setup test environment run: | From 19f911d11d59a3d926f4d91ee933b97c1964338e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Wed, 5 Jun 2024 18:23:16 -0400 Subject: [PATCH 2/6] gomod: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0f41775..51b2cda 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/lxc/go-lxc go 1.20 -require golang.org/x/sys v0.12.0 +require golang.org/x/sys v0.21.0 diff --git a/go.sum b/go.sum index 63a0250..ac7fb31 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,2 @@ -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= From beb1045152aff40a43bc9e803b1e135f92dc629e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Wed, 5 Jun 2024 18:14:10 -0400 Subject: [PATCH 3/6] container: Better handle lxc_start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- container.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/container.go b/container.go index d22345d..004cf6f 100644 --- a/container.go +++ b/container.go @@ -647,9 +647,16 @@ func (c *Container) StartWithArgs(args []string) error { return err } - if !bool(C.go_lxc_start(c.container, 0, makeNullTerminatedArgs(args))) { - return ErrStartFailed + if args != nil { + if !bool(C.go_lxc_start(c.container, 0, makeNullTerminatedArgs(args))) { + return ErrStartFailed + } + } else { + if !bool(C.go_lxc_start(c.container, 0, nil)) { + return ErrStartFailed + } } + return nil } @@ -667,8 +674,14 @@ func (c *Container) StartExecute(args []string) error { return err } - if !bool(C.go_lxc_start(c.container, 1, makeNullTerminatedArgs(args))) { - return ErrStartFailed + if args != nil { + if !bool(C.go_lxc_start(c.container, 1, makeNullTerminatedArgs(args))) { + return ErrStartFailed + } + } else { + if !bool(C.go_lxc_start(c.container, 1, nil)) { + return ErrStartFailed + } } return nil From 13b4a628b02e5f666bf93add2517cd9f36b5a8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Thu, 6 Jun 2024 13:40:15 -0400 Subject: [PATCH 4/6] lxc_test: Remove travis function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- lxc_test.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lxc_test.go b/lxc_test.go index bf77e56..7908b56 100644 --- a/lxc_test.go +++ b/lxc_test.go @@ -42,11 +42,6 @@ func unprivileged() bool { return os.Geteuid() != 0 } -func travis() bool { - // https://docs.travis-ci.com/user/environment-variables/#default-environment-variables - return os.Getenv("TRAVIS") == "true" -} - func supported(moduleName string) bool { if _, err := os.Stat("/sys/module/" + moduleName); err != nil { return false From 555f57ca48c965217ee6ab9a5be854c31222f5c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Thu, 6 Jun 2024 13:48:53 -0400 Subject: [PATCH 5/6] lxc_test: Enable IPv6 testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- lxc_test.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lxc_test.go b/lxc_test.go index 7908b56..8d04eb0 100644 --- a/lxc_test.go +++ b/lxc_test.go @@ -1412,10 +1412,6 @@ func TestIPv4Addresses(t *testing.T) { } func TestIPv6Addresses(t *testing.T) { - if !ipv6() { - t.Skip("skipping test since lxc bridge does not have ipv6 address") - } - c, err := NewContainer(ContainerName()) if err != nil { t.Errorf(err.Error()) From f0b282955adc2e2f266884290cf9ed440c640f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Thu, 6 Jun 2024 13:49:02 -0400 Subject: [PATCH 6/6] lxc_test: Add delay for network configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- lxc_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lxc_test.go b/lxc_test.go index 8d04eb0..e14a346 100644 --- a/lxc_test.go +++ b/lxc_test.go @@ -1406,6 +1406,9 @@ func TestIPv4Addresses(t *testing.T) { } defer c.Release() + // Wait for IP configuration. + time.Sleep(5 * time.Second) + if _, err := c.IPv4Addresses(); err != nil { t.Errorf(err.Error()) } @@ -1418,6 +1421,9 @@ func TestIPv6Addresses(t *testing.T) { } defer c.Release() + // Wait for IP configuration. + time.Sleep(5 * time.Second) + if _, err := c.IPv6Addresses(); err != nil { t.Errorf(err.Error()) }