diff --git a/management/daemon.py b/management/daemon.py index 76fd528d..3304f12e 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -534,6 +534,7 @@ def smtp_relay_get(): @app.route('/system/smtp/relay', methods=["POST"]) @authorized_personnel_only def smtp_relay_set(): + import re from editconf import edit_conf config = utils.load_settings(env) newconf = request.form @@ -550,7 +551,7 @@ def smtp_relay_set(): "smtp_sasl_auth_enable=" + "yes" if config["SMTP_RELAY_AUTH"] else "no", "smtp_sasl_security_options=" + "noanonymous" if config["SMTP_RELAY_AUTH"] else "anonymous", "smtp_sasl_tls_security_options=" + "noanonymous" if config["SMTP_RELAY_AUTH"] else "anonymous" - ], False, False) + ], r"\s*=\s*", "#") if config["SMTP_RELAY_AUTH"]: # Edit the sasl password with open("/etc/postfix/sasl_passwd", "w") as f: diff --git a/management/editconf.py b/management/editconf.py index a0d32b17..60322203 100755 --- a/management/editconf.py +++ b/management/editconf.py @@ -24,7 +24,9 @@ # create the new config file in memory -def edit_conf(filename, settings, folded_lines, testing): +import sys, re + +def edit_conf(filename, settings, delimiter_re, comment_char, folded_lines = False, testing = False): found = set() buf = "" input_lines = list(open(filename, "r+")) @@ -97,8 +99,6 @@ def edit_conf(filename, settings, folded_lines, testing): # Run standalone if __name__ == "__main__": - import sys, re - # sanity check if len(sys.argv) < 3: print("usage: python3 editconf.py /etc/file.conf [-s] [-w] [-c ] [-t] NAME=VAL [NAME=VAL ...]") @@ -140,4 +140,4 @@ if __name__ == "__main__": print("Invalid command line: ", subprocess.list2cmdline(sys.argv)) sys.exit(1) - edit_conf(filename, settings, folded_lines, testing) + edit_conf(filename, settings, delimiter_re, comment_char, folded_lines, testing)