Smail/test/tools/fix_remote_config_digest.py
smail bf1e69f480
Some checks are pending
Security Checks / security (push) Waiting to run
修复生产审查凭据泄露风险并增加持久投递队列
2026-09-17 10:17:09 +08:00

37 lines
1.0 KiB
Python

# -*- coding: utf-8 -*-
import paramiko, time
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.RejectPolicy())
from remote_ssh import connect_remote
connect_remote(ssh)
cmd = """python3 -c '
import hashlib, json
with open("/opt/smail/config/email.json", "rb") as f:
raw = f.read()
digest = hashlib.sha256(raw).hexdigest()
with open("/opt/smail/config/config.json", "r") as f:
cfg = json.load(f)
cfg["sections"]["email"]["sha256"] = digest
cfg["email"]["externalRecoveryEnabled"] = True
with open("/opt/smail/config/config.json", "w") as f:
json.dump(cfg, f, indent=2)
'
"""
stdin, stdout, stderr = ssh.exec_command(cmd)
print("Stderr:", stderr.read().decode())
ssh.exec_command("cd /opt/smail && nohup ./smail -p 80 > /opt/smail/log/stdout.log 2>&1 &")
time.sleep(2)
stdin, stdout, stderr = ssh.exec_command("ps -ef | grep smail")
print("Process:\n", stdout.read().decode())
stdin, stdout, stderr = ssh.exec_command("tail -n 15 /opt/smail/log/stdout.log")
print("Stdout tail:\n", stdout.read().decode())
ssh.close()