/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/transport/ssh.py

  • Committer: Martin
  • Date: 2019-06-16 01:03:51 UTC
  • mto: This revision was merged to the branch mainline in revision 7340.
  • Revision ID: gzlist@googlemail.com-20190616010351-uz89ydnwdoal4ve4
Split non-ini config methods to bedding

Functions that determine filesystem paths to use for config and default
username are now outside of the main (large) config module.

Also move cache_dir function from osutils and normalise logic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
from .. import (
32
32
    config,
 
33
    bedding,
33
34
    errors,
34
35
    osutils,
35
36
    trace,
312
313
            save_host_keys()
313
314
        if server_key != our_server_key:
314
315
            filename1 = os.path.expanduser('~/.ssh/known_hosts')
315
 
            filename2 = osutils.pathjoin(config.config_dir(), 'ssh_host_keys')
 
316
            filename2 = _ssh_host_keys_config_dir()
316
317
            raise errors.TransportError(
317
318
                'Host keys for %s do not match!  %s != %s' %
318
319
                (host, our_server_key_hex, server_key_hex),
610
611
    return False
611
612
 
612
613
 
 
614
def _ssh_host_keys_config_dir():
 
615
    return osutils.pathjoin(bedding.config_dir(), 'ssh_host_keys')
 
616
 
 
617
 
613
618
def load_host_keys():
614
619
    """
615
620
    Load system host keys (probably doesn't work on windows) and any
621
626
            os.path.expanduser('~/.ssh/known_hosts'))
622
627
    except IOError as e:
623
628
        trace.mutter('failed to load system host keys: ' + str(e))
624
 
    brz_hostkey_path = osutils.pathjoin(config.config_dir(), 'ssh_host_keys')
 
629
    brz_hostkey_path = _ssh_host_keys_config_dir()
625
630
    try:
626
631
        BRZ_HOSTKEYS = paramiko.util.load_host_keys(brz_hostkey_path)
627
632
    except IOError as e:
634
639
    Save "discovered" host keys in $(config)/ssh_host_keys/.
635
640
    """
636
641
    global SYSTEM_HOSTKEYS, BRZ_HOSTKEYS
637
 
    bzr_hostkey_path = osutils.pathjoin(config.config_dir(), 'ssh_host_keys')
638
 
    config.ensure_config_dir_exists()
 
642
    bzr_hostkey_path = _ssh_host_keys_config_dir()
 
643
    bedding.ensure_config_dir_exists()
639
644
 
640
645
    try:
641
646
        with open(bzr_hostkey_path, 'w') as f: