Skip to content

Commit 7685246

Browse files
committed
Merge branch 'v2-c' into knowledge_workflow
2 parents a7ed32b + 10b466b commit 7685246

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

apps/common/utils/tool_code.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, sandbox=False):
2929
else:
3030
self.sandbox_path = os.path.join(PROJECT_DIR, 'data', 'sandbox')
3131
self.user = None
32-
self.sandbox_so_path = f'{self.sandbox_path}/sandbox.so'
32+
self.sandbox_so_path = f'{self.sandbox_path}/lib/sandbox.so'
3333
self.process_timeout_seconds = int(CONFIG.get("SANDBOX_PYTHON_PROCESS_TIMEOUT_SECONDS", '3600'))
3434
try:
3535
self._init_dir()
@@ -60,10 +60,9 @@ def _init_dir(self):
6060
tmp_dir_path = os.path.join(self.sandbox_path, 'tmp')
6161
os.makedirs(tmp_dir_path, 0o700, exist_ok=True)
6262
os.system(f"chown -R {self.user}:root {tmp_dir_path}")
63-
if os.path.exists(self.sandbox_so_path):
64-
os.chmod(self.sandbox_so_path, 0o440)
6563
# 初始化sandbox配置文件
66-
sandbox_conf_file_path = f'{self.sandbox_path}/.sandbox.conf'
64+
sandbox_lib_path = os.path.dirname(self.sandbox_so_path)
65+
sandbox_conf_file_path = f'{sandbox_lib_path}/.sandbox.conf'
6766
if os.path.exists(sandbox_conf_file_path):
6867
os.remove(sandbox_conf_file_path)
6968
allow_subprocess = CONFIG.get("SANDBOX_PYTHON_ALLOW_SUBPROCESS", '0')
@@ -75,7 +74,7 @@ def _init_dir(self):
7574
with open(sandbox_conf_file_path, "w") as f:
7675
f.write(f"SANDBOX_PYTHON_BANNED_HOSTS={banned_hosts}\n")
7776
f.write(f"SANDBOX_PYTHON_ALLOW_SUBPROCESS={allow_subprocess}\n")
78-
os.chmod(sandbox_conf_file_path, 0o440)
77+
os.system(f"chmod -R 550 {sandbox_lib_path}")
7978

8079
def exec_code(self, code_str, keywords, function_name=None):
8180
_id = str(uuid.uuid7())

installer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN apt-get update && \
1313
apt-get clean all && \
1414
rm -rf /var/lib/apt/lists/*
1515
WORKDIR /opt/maxkb-app
16-
RUN gcc -shared -fPIC -o ${MAXKB_SANDBOX_HOME}/sandbox.so /opt/maxkb-app/installer/sandbox.c -ldl && \
16+
RUN gcc -shared -fPIC -o ${MAXKB_SANDBOX_HOME}/lib/sandbox.so /opt/maxkb-app/installer/sandbox.c -ldl && \
1717
rm -rf /opt/maxkb-app/ui && \
1818
pip install uv --break-system-packages && \
1919
python -m uv pip install -r pyproject.toml && \

installer/Dockerfile-base

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
2424
chmod 755 /usr/bin/start-*.sh && \
2525
find /etc/ -type f ! -path '/etc/resolv.conf' ! -path '/etc/hosts' | xargs chmod g-rx && \
2626
curl -L --connect-timeout 120 -m 1800 https://resource.fit2cloud.com/maxkb/ffmpeg/get-ffmpeg-linux | sh && \
27-
mkdir -p /opt/maxkb-app/sandbox && \
27+
mkdir -p /opt/maxkb-app/sandbox/lib && \
2828
useradd --no-create-home --home /opt/maxkb-app/sandbox sandbox -g root && \
29-
chown -R sandbox:root /opt/maxkb-app/sandbox && chmod 550 /opt/maxkb-app/sandbox && \
29+
chown sandbox:root /opt/maxkb-app/sandbox && chmod 550 /opt/maxkb-app/sandbox && \
3030
chmod g-xr /usr/local/bin/* /usr/bin/* /bin/* /usr/sbin/* /sbin/* /usr/lib/postgresql/17/bin/* && \
3131
chmod g+xr /usr/bin/ld.so && \
3232
chmod g+x /usr/local/bin/python* && \

0 commit comments

Comments
 (0)