feat: 修改服务器时间时传递密码

This commit is contained in:
caoqianming 2025-05-22 09:09:17 +08:00
parent 36790a72b4
commit fdb454d6e5
1 changed files with 2 additions and 2 deletions

View File

@ -64,8 +64,8 @@ class ServerTime(APIView):
""" """
command = f'date -s "{request.data["server_time"]}"' command = f'date -s "{request.data["server_time"]}"'
completed = subprocess.run( completed = subprocess.run(
["sudo", "sh", "-c", command], # 避免 shell=True 的安全风险 ["sudo", "-S", "sh", "-c", command], # 添加 -S 参数
input=SD_PWD, # 密码从安全配置读取 input=SD_PWD + "\n", # 注意要在密码后加换行符
capture_output=True, capture_output=True,
text=True text=True
) )