feat: 修改服务器时间时传递密码
This commit is contained in:
parent
36790a72b4
commit
fdb454d6e5
|
@ -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
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue