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 )