mirror of
				https://github.com/mail-in-a-box/mailinabox.git
				synced 2025-11-03 19:30:54 +00:00 
			
		
		
		
	tweaks to reading ssh config
This commit is contained in:
		
							parent
							
								
									bdda55413c
								
							
						
					
					
						commit
						2a42e888c3
					
				@ -449,9 +449,10 @@ def build_sshfp_records():
 | 
			
		||||
	# specify that port to sshkeyscan.
 | 
			
		||||
 | 
			
		||||
	port = get_ssh_port()
 | 
			
		||||
	# If nothing returned, assume default
 | 
			
		||||
 | 
			
		||||
	# If nothing returned, SSH is probably not installed.
 | 
			
		||||
	if not port:
 | 
			
		||||
		port = 22
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
	keys = shell("check_output", ["ssh-keyscan", "-4", "-t", "rsa,dsa,ecdsa,ed25519", "-p", str(port), "localhost"])
 | 
			
		||||
	keys = sorted(keys.split("\n"))
 | 
			
		||||
 | 
			
		||||
@ -181,7 +181,7 @@ def wait_for_service(port, public, env, timeout):
 | 
			
		||||
 | 
			
		||||
def get_ssh_port():
 | 
			
		||||
	port_value = get_ssh_config_value("port")
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	if port_value:
 | 
			
		||||
		return int(port_value)
 | 
			
		||||
 | 
			
		||||
@ -198,12 +198,11 @@ def get_ssh_config_value(parameter_name):
 | 
			
		||||
		# error while calling shell command
 | 
			
		||||
		return None
 | 
			
		||||
 | 
			
		||||
	returnNext = False
 | 
			
		||||
	for e in output.split():
 | 
			
		||||
		if returnNext:
 | 
			
		||||
			return e
 | 
			
		||||
		if e == parameter_name:
 | 
			
		||||
			returnNext = True
 | 
			
		||||
	for line in output.split("\n"):
 | 
			
		||||
		if " " not in line: continue # there's a blank line at the end
 | 
			
		||||
		key, values = line.split(" ", 1)
 | 
			
		||||
		if key == parameter_name:
 | 
			
		||||
			return values # space-delimited if there are multiple values
 | 
			
		||||
 | 
			
		||||
	# Did not find the parameter!
 | 
			
		||||
	return None
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user