aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-10-13 02:26:01 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-10-13 02:26:01 +0900
commitaee96b0fdf5e8272f36ee67eecfbf423c0aad0b6 (patch)
tree798bd0df019d0d667ed49fa334df3e9906c5bc38
parent655020eb5d509ed306ebddac00f50c96132787dd (diff)
helper/bwrap: allow pushing generic arguments to the end of argument stream
Bwrap argument order determines the order their corresponding actions are performed. This allows generic arguments like tmpfs to the end of the stream to override bind mounts. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
-rw-r--r--helper/bwrap/config.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/helper/bwrap/config.go b/helper/bwrap/config.go
index fffddbe0..6fdb08d8 100644
--- a/helper/bwrap/config.go
+++ b/helper/bwrap/config.go
@@ -46,6 +46,9 @@ func (c *Config) Args() (args []string) {
}
for i, arg := range g {
for _, v := range arg {
+ if v.Later() {
+ continue
+ }
args = append(args, v.Value(interfaceArgs[i])...)
}
}
@@ -59,6 +62,14 @@ func (c *Config) Args() (args []string) {
args = append(args, pairArgs[i], v[0], v[1])
}
}
+ for i, arg := range g {
+ for _, v := range arg {
+ if !v.Later() {
+ continue
+ }
+ args = append(args, v.Value(interfaceArgs[i])...)
+ }
+ }
return
}
@@ -217,6 +228,7 @@ type TmpfsConfig struct {
type argOf interface {
Value(arg string) (args []string)
+ Later() bool
}
func copyToArgOfSlice[T [2]string | string | TmpfsConfig](src []PermConfig[T]) (dst []argOf) {
@@ -228,6 +240,9 @@ func copyToArgOfSlice[T [2]string | string | TmpfsConfig](src []PermConfig[T]) (
}
type PermConfig[T [2]string | string | TmpfsConfig] struct {
+ // append this at the end of the argument stream
+ Last bool
+
// set permissions of next argument
// (--perms OCTAL)
Mode *os.FileMode `json:"mode,omitempty"`
@@ -236,6 +251,10 @@ type PermConfig[T [2]string | string | TmpfsConfig] struct {
Path T
}
+func (p PermConfig[T]) Later() bool {
+ return p.Last
+}
+
func (p PermConfig[T]) Value(arg string) (args []string) {
// max possible size
if p.Mode != nil {