From 2493dda4e519b3845f5a4926a4368d65829413c2 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Tue, 9 Dec 2014 08:20:57 -0800 Subject: [PATCH] Before pulling submodules from repos add ssh hostkeys for those submodules Fixes #9655 --- source_control/git.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/source_control/git.py b/source_control/git.py index 7ac24804e77..44d4c143450 100644 --- a/source_control/git.py +++ b/source_control/git.py @@ -467,16 +467,23 @@ def submodules_fetch(git_path, module, remote, track_submodules, dest): # no submodules return changed - # Check for new submodules gitmodules_file = open(os.path.join(dest, '.gitmodules'), 'r') for line in gitmodules_file: - if line.strip().startswith('path'): + # Check for new submodules + if not changed and line.strip().startswith('path'): path = line.split('=', 1)[1].strip() # Check that dest/path/.git exists if not os.path.exists(os.path.join(dest, path, '.git')): changed = True - break - ### FIXME: Add the submodule hostkeys here as well + + # add the submodule repo's hostkey + if line.strip().startswith('url'): + repo = line.split('=', 1)[1].strip() + if module.params['ssh_opts'] is not None: + if not "-o StrictHostKeyChecking=no" in module.params['ssh_opts']: + add_git_host_key(module, repo, accept_hostkey=module.params['accept_hostkey']) + else: + add_git_host_key(module, repo, accept_hostkey=module.params['accept_hostkey']) # Check for updates to existing modules if not changed: