mirror of
				https://github.com/mail-in-a-box/mailinabox.git
				synced 2025-10-30 18:50:53 +00:00 
			
		
		
		
	Import other stuff
This commit is contained in:
		
							parent
							
								
									10e4b79423
								
							
						
					
					
						commit
						8f247e3b70
					
				| @ -534,6 +534,7 @@ def smtp_relay_get(): | |||||||
| @app.route('/system/smtp/relay', methods=["POST"]) | @app.route('/system/smtp/relay', methods=["POST"]) | ||||||
| @authorized_personnel_only | @authorized_personnel_only | ||||||
| def smtp_relay_set(): | def smtp_relay_set(): | ||||||
|  | 	import re | ||||||
| 	from editconf import edit_conf | 	from editconf import edit_conf | ||||||
| 	config = utils.load_settings(env) | 	config = utils.load_settings(env) | ||||||
| 	newconf = request.form | 	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_auth_enable=" + "yes" if config["SMTP_RELAY_AUTH"] else "no", | ||||||
| 			"smtp_sasl_security_options=" + "noanonymous" if config["SMTP_RELAY_AUTH"] else "anonymous", | 			"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" | 			"smtp_sasl_tls_security_options=" + "noanonymous" if config["SMTP_RELAY_AUTH"] else "anonymous" | ||||||
| 		], False, False) | 		], r"\s*=\s*", "#") | ||||||
| 		if config["SMTP_RELAY_AUTH"]: | 		if config["SMTP_RELAY_AUTH"]: | ||||||
| 			# Edit the sasl password | 			# Edit the sasl password | ||||||
| 			with open("/etc/postfix/sasl_passwd", "w") as f: | 			with open("/etc/postfix/sasl_passwd", "w") as f: | ||||||
|  | |||||||
| @ -24,7 +24,9 @@ | |||||||
| 
 | 
 | ||||||
| # create the new config file in memory | # 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() | 	found = set() | ||||||
| 	buf = "" | 	buf = "" | ||||||
| 	input_lines = list(open(filename, "r+")) | 	input_lines = list(open(filename, "r+")) | ||||||
| @ -97,8 +99,6 @@ def edit_conf(filename, settings, folded_lines, testing): | |||||||
| 
 | 
 | ||||||
| # Run standalone | # Run standalone | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
| 	import sys, re |  | ||||||
| 
 |  | ||||||
| 	# sanity check | 	# sanity check | ||||||
| 	if len(sys.argv) < 3: | 	if len(sys.argv) < 3: | ||||||
| 		print("usage: python3 editconf.py /etc/file.conf [-s] [-w] [-c <CHARACTER>] [-t] NAME=VAL [NAME=VAL ...]") | 		print("usage: python3 editconf.py /etc/file.conf [-s] [-w] [-c <CHARACTER>] [-t] NAME=VAL [NAME=VAL ...]") | ||||||
| @ -140,4 +140,4 @@ if __name__ == "__main__": | |||||||
| 			print("Invalid command line: ", subprocess.list2cmdline(sys.argv)) | 			print("Invalid command line: ", subprocess.list2cmdline(sys.argv)) | ||||||
| 			sys.exit(1) | 			sys.exit(1) | ||||||
| 
 | 
 | ||||||
| 	edit_conf(filename, settings, folded_lines, testing) | 	edit_conf(filename, settings, delimiter_re, comment_char, folded_lines, testing) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user