From 713872a5cdde8fc74507a13f9bd189324f88a939 Mon Sep 17 00:00:00 2001 From: Ophestra Umiker Date: Fri, 11 Oct 2024 04:12:47 +0900 Subject: [PATCH] helper/bwrap: move interfaceArgs before stringArgs Signed-off-by: Ophestra Umiker --- helper/bwrap/config.go | 15 +++++++++------ helper/bwrap/config_test.go | 23 ++++++++++++----------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/helper/bwrap/config.go b/helper/bwrap/config.go index 4163a7d..fffddbe 100644 --- a/helper/bwrap/config.go +++ b/helper/bwrap/config.go @@ -8,9 +8,9 @@ import ( func (c *Config) Args() (args []string) { b := c.boolArgs() n := c.intArgs() + g := c.interfaceArgs() s := c.stringArgs() p := c.pairArgs() - g := c.interfaceArgs() argc := 0 for i, arg := range b { @@ -23,6 +23,9 @@ func (c *Config) Args() (args []string) { argc += 2 } } + for _, arg := range g { + argc += len(arg) * 3 + } for _, arg := range s { argc += len(arg) * 2 } @@ -41,6 +44,11 @@ func (c *Config) Args() (args []string) { args = append(args, intArgs[i], strconv.Itoa(*arg)) } } + for i, arg := range g { + for _, v := range arg { + args = append(args, v.Value(interfaceArgs[i])...) + } + } for i, arg := range s { for _, v := range arg { args = append(args, stringArgs[i], v) @@ -51,11 +59,6 @@ func (c *Config) Args() (args []string) { args = append(args, pairArgs[i], v[0], v[1]) } } - for i, arg := range g { - for _, v := range arg { - args = append(args, v.Value(interfaceArgs[i])...) - } - } return } diff --git a/helper/bwrap/config_test.go b/helper/bwrap/config_test.go index 5326571..a14e310 100644 --- a/helper/bwrap/config_test.go +++ b/helper/bwrap/config_test.go @@ -54,6 +54,17 @@ func TestConfig_Args(t *testing.T) { "--assert-userns-disabled", "--clearenv", "--die-with-parent", + "--symlink", "usr/bin", "/bin", + "--symlink", "var/home", "/home", + "--symlink", "usr/lib", "/lib", + "--symlink", "usr/lib64", "/lib64", + "--symlink", "run/media", "/media", + "--symlink", "var/mnt", "/mnt", + "--symlink", "var/opt", "/opt", + "--symlink", "sysroot/ostree", "/ostree", + "--symlink", "var/roothome", "/root", + "--symlink", "usr/sbin", "/sbin", + "--symlink", "var/srv", "/srv", "--bind", "/run", "/run", "--bind", "/tmp", "/tmp", "--bind", "/var", "/var", @@ -65,17 +76,7 @@ func TestConfig_Args(t *testing.T) { "--ro-bind", "/sysroot", "/sysroot", "--ro-bind", "/usr", "/usr", "--ro-bind", "/etc", "/etc", - "--symlink", "usr/bin", "/bin", - "--symlink", "var/home", "/home", - "--symlink", "usr/lib", "/lib", - "--symlink", "usr/lib64", "/lib64", - "--symlink", "run/media", "/media", - "--symlink", "var/mnt", "/mnt", - "--symlink", "var/opt", "/opt", - "--symlink", "sysroot/ostree", "/ostree", - "--symlink", "var/roothome", "/root", - "--symlink", "usr/sbin", "/sbin", - "--symlink", "var/srv", "/srv"}, + }, }, }