michael-yuji / xc

FreeBSD container engine
Other
87 stars 9 forks source link

Duplicated args with xc run #11

Closed j1cken closed 9 months ago

j1cken commented 10 months ago

Reproducer:

  1. build from HEAD (commit a9945ec1c8bebae3a4557678e75c8a4f57f0f1b2 (HEAD -> main, origin/main, origin/HEAD))
  2. doas xc run --network default --vnet quay.io/keycloak/keycloak:23.0 -- /opt/keycloak/bin/kc.sh start-dev --db dev-mem --hostname 192.168.17.11

xcd output:

2023-12-19T15:38:31.499002Z  INFO xc::container::runner: spawn: Jexec {
    arg0: "/opt/keycloak/bin/kc.sh",
    args: [
        "start-dev",
        "--db",
        "dev-mem",
        "--hostname",
        "192.168.17.11",
        "start-dev",
        "--db",
        "dev-mem",
        "--hostname",
        "192.168.17.11",
    ],
    envs: {},
    uid: None,
    gid: None,
    user: None,
    group: None,
    output_mode: Terminal,
    notify: None,
    work_dir: None,
}

Once I apply

diff --git a/xc/src/models/exec.rs b/xc/src/models/exec.rs
index 485e4ad..bdf528a 100644
--- a/xc/src/models/exec.rs
+++ b/xc/src/models/exec.rs
@@ -234,6 +234,7 @@ impl Exec {
         envs: &HashMap<String, String>,
         args: &[String],
     ) -> Result<Jexec, crate::container::error::Error> {
+
         let mut argv = Vec::new();
         let mut resolved_envs = if self.clear_env {
             HashMap::new()
@@ -260,11 +261,12 @@ impl Exec {
             for arg in self.default_args.iter() {
                 argv.push(arg.apply(&resolved_envs));
             }
-        } else {
-            for arg in args {
-                argv.push(arg.to_string());
-            }
-        }
+        } 
+        // else {
+        //     for arg in args {
+        //         argv.push(arg.to_string());
+        //     }
+        // }

         let uid = self.user.as_ref().and_then(|user| user.parse::<u32>().ok());
         let gid = self

everything looks as expected. I have no idea what other issue this hack introduces but it works for my use case:

2023-12-19T15:47:11.518841Z  INFO xc::container::runner: spawn: Jexec {
    arg0: "/opt/keycloak/bin/kc.sh",
    args: [
        "start-dev",
        "--db",
        "dev-mem",
        "--hostname",
        "192.168.17.11",
    ],
    envs: {},
    uid: None,
    gid: None,
    user: None,
    group: None,
    output_mode: Terminal,
    notify: None,
    work_dir: None,
}
elliptic-kitty commented 9 months ago

fixed https://github.com/michael-yuji/xc/commit/0137a2f49f367b888ab7434bb85aa8f3a171b73f