From fdb454d6e54a61e2c217a8b2bb60406c683880fd Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 22 May 2025 09:09:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E6=97=B6=E9=97=B4=E6=97=B6=E4=BC=A0=E9=80=92=E5=AF=86?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/develop/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/develop/views.py b/apps/develop/views.py index 2b793a75..735739e7 100755 --- a/apps/develop/views.py +++ b/apps/develop/views.py @@ -64,8 +64,8 @@ class ServerTime(APIView): """ command = f'date -s "{request.data["server_time"]}"' completed = subprocess.run( - ["sudo", "sh", "-c", command], # 避免 shell=True 的安全风险 - input=SD_PWD, # 密码从安全配置读取 + ["sudo", "-S", "sh", "-c", command], # 添加 -S 参数 + input=SD_PWD + "\n", # 注意要在密码后加换行符 capture_output=True, text=True )