From 306bf4875480c096a140f0c4803b87c1166b93f2 Mon Sep 17 00:00:00 2001 From: CakeCN Date: Sun, 14 Sep 2025 17:15:17 +0800 Subject: [PATCH] sudo fix --- Html/apps/utils/sudoUtil.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Html/apps/utils/sudoUtil.py b/Html/apps/utils/sudoUtil.py index f32e043..92002d4 100644 --- a/Html/apps/utils/sudoUtil.py +++ b/Html/apps/utils/sudoUtil.py @@ -18,14 +18,7 @@ def sudo_open(file_path, mode='r', encoding='utf-8'): content = result.stdout yield content elif mode == 'w': - # 使用 sudo 打开文件并写入内容 - def write_content(content): - result = subprocess.run(["sudo", "tee", file_path], input=content, text=True, capture_output=True, encoding=encoding) - if result.returncode != 0: - raise PermissionError(f"无法写入文件: {file_path}") - return result.stdout - - yield write_content + raise PermissionError(f"不允许以sudo权限写入文件: {file_path}") else: raise ValueError("只支持 'r' 或 'w' 模式") except Exception as e: