summaryrefslogtreecommitdiff
path: root/0069-add-exec-workdir-support-for-oci-runtime.patch
blob: e57cee64463dba820d4d061540d193e72059fd9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From 921ee84f80adda64fb0a7125f9f709bff416945c Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Tue, 26 Dec 2023 10:17:19 +0800
Subject: [PATCH 69/71] add exec workdir support for oci runtime

Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
 src/cmd/isula/stream/exec.h                     | 2 +-
 src/cmd/isulad-shim/process.c                   | 4 ++++
 src/daemon/modules/runtime/isula/isula_rt_ops.c | 3 +++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/cmd/isula/stream/exec.h b/src/cmd/isula/stream/exec.h
index 83a4af06..8d8e4347 100644
--- a/src/cmd/isula/stream/exec.h
+++ b/src/cmd/isula/stream/exec.h
@@ -48,7 +48,7 @@ extern "C" {
         "Username or UID (format: <name|uid>[:<group|gid>])",                                              \
         NULL },                                                                                            \
     { CMD_OPT_TYPE_STRING_DUP, false, "workdir", 0, &(cmdargs).custom_conf.workdir,                        \
-        "Working directory inside the container, supported only when runtime is lcr", NULL }
+        "Working directory inside the container", NULL }
 
 extern const char g_cmd_exec_desc[];
 extern const char g_cmd_exec_usage[];
diff --git a/src/cmd/isulad-shim/process.c b/src/cmd/isulad-shim/process.c
index 97524f1a..06726a40 100644
--- a/src/cmd/isulad-shim/process.c
+++ b/src/cmd/isulad-shim/process.c
@@ -1274,6 +1274,10 @@ static void get_runtime_cmd(process_t *p, const char *log_path, const char *pid_
 #endif
         params[i++] = "--process";
         params[i++] = process_desc;
+        if (p->state->cwd != NULL) {
+            params[i++] = "--cwd";
+            params[i++] = p->state->cwd;
+        }
     } else {
         params[i++] = "create";
         params[i++] = "--bundle";
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
index fbb779f7..c754fc54 100644
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
@@ -1345,6 +1345,9 @@ static int preparation_exec(const char *id, const char *runtime, const char *wor
     p.runtime_args = (char **)runtime_args;
     p.runtime_args_len = runtime_args_len;
     copy_process(&p, process);
+    if (params->workdir != NULL) {
+        p.cwd = (char *)params->workdir;
+    }
 
     ret = create_process_json_file(workdir, &p);
     if (ret != 0) {
-- 
2.25.1