mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-26 17:01:14 -06:00
client install: do not corrupt OpenSSH config with Match sections
https://fedorahosted.org/freeipa/ticket/5461 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
This commit is contained in:
parent
7f0d018c66
commit
2d041daf17
@ -1332,6 +1332,7 @@ def change_ssh_config(filename, changes, sections):
|
|||||||
section_keys = tuple(key.lower() for key in sections)
|
section_keys = tuple(key.lower() for key in sections)
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
|
in_section = False
|
||||||
for line in f:
|
for line in f:
|
||||||
line = line.rstrip('\n')
|
line = line.rstrip('\n')
|
||||||
pline = line.strip()
|
pline = line.strip()
|
||||||
@ -1340,7 +1341,7 @@ def change_ssh_config(filename, changes, sections):
|
|||||||
continue
|
continue
|
||||||
option = pline.split()[0].lower()
|
option = pline.split()[0].lower()
|
||||||
if option in section_keys:
|
if option in section_keys:
|
||||||
lines.append(line)
|
in_section = True
|
||||||
break
|
break
|
||||||
if option in change_keys:
|
if option in change_keys:
|
||||||
line = '#' + line
|
line = '#' + line
|
||||||
@ -1348,6 +1349,9 @@ def change_ssh_config(filename, changes, sections):
|
|||||||
for option, value in changes.items():
|
for option, value in changes.items():
|
||||||
if value is not None:
|
if value is not None:
|
||||||
lines.append('%s %s' % (option, value))
|
lines.append('%s %s' % (option, value))
|
||||||
|
if in_section:
|
||||||
|
lines.append('')
|
||||||
|
lines.append(line)
|
||||||
for line in f:
|
for line in f:
|
||||||
line = line.rstrip('\n')
|
line = line.rstrip('\n')
|
||||||
lines.append(line)
|
lines.append(line)
|
||||||
@ -1388,7 +1392,7 @@ def configure_ssh_config(fstore, options):
|
|||||||
changes['VerifyHostKeyDNS'] = 'yes'
|
changes['VerifyHostKeyDNS'] = 'yes'
|
||||||
changes['HostKeyAlgorithms'] = 'ssh-rsa,ssh-dss'
|
changes['HostKeyAlgorithms'] = 'ssh-rsa,ssh-dss'
|
||||||
|
|
||||||
change_ssh_config(ssh_config, changes, ['Host'])
|
change_ssh_config(ssh_config, changes, ['Host', 'Match'])
|
||||||
root_logger.info('Configured %s', ssh_config)
|
root_logger.info('Configured %s', ssh_config)
|
||||||
|
|
||||||
def configure_sshd_config(fstore, options):
|
def configure_sshd_config(fstore, options):
|
||||||
|
Loading…
Reference in New Issue
Block a user