From d68acede6f92ab86d6a8ec5d1415a7b8a900a975 Mon Sep 17 00:00:00 2001 From: liqiang-fit2cloud Date: Tue, 9 Dec 2025 19:02:49 +0800 Subject: [PATCH] refactor: change error number. --- apps/common/utils/tool_code.py | 2 +- installer/sandbox.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/common/utils/tool_code.py b/apps/common/utils/tool_code.py index f38460c76..16c1f2e30 100644 --- a/apps/common/utils/tool_code.py +++ b/apps/common/utils/tool_code.py @@ -119,7 +119,7 @@ sys.stdout.flush() result = json.loads(result_line[-1].split(":", 1)[1]) if result.get('code') == 200: return result.get('data') - raise Exception(result.get('msg')) + raise Exception(result.get('msg') + (f'\n{subprocess_result.stderr}' if subprocess_result.stderr else '')) def _generate_mcp_server_code(self, _code, params): # 解析代码,提取导入语句和函数定义 diff --git a/installer/sandbox.c b/installer/sandbox.c index 67b245432..f0fd1bc53 100644 --- a/installer/sandbox.c +++ b/installer/sandbox.c @@ -166,7 +166,7 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { if (is_sandbox_user() && banned_hosts && *banned_hosts) { if (ip[0] && match_banned_ip(ip, banned_hosts)) { - fprintf(stderr, "[sandbox] 🚫 Access to IP %s is banned\n", ip); + fprintf(stderr, "Permission denied to access %s.\n", ip); errno = EACCES; // Permission denied return -1; } @@ -188,8 +188,9 @@ int getaddrinfo(const char *node, const char *service, if (!is_ip) { // 仅对域名进行阻塞 if (match_banned_domain(node, banned_hosts)) { - fprintf(stderr, "[sandbox] 🚫 Access to host %s is banned (DNS blocked)\n", node); - return EAI_FAIL; + fprintf(stderr, "Permission denied to access %s.\n", node); + errno = EACCES; + return EAI_SYSTEM; } } }