Merge pull request #31139 from exowaucka/develop

Improve %h and %u handling in SSH module
This commit is contained in:
Mike Place 2016-02-11 14:13:05 -07:00
commit f24954dde5
2 changed files with 5 additions and 1 deletions

View File

@ -116,9 +116,9 @@ def _get_config_file(user, config):
if not uinfo:
raise CommandExecutionError('User \'{0}\' does not exist'.format(user))
home = uinfo['home']
config = _expand_authorized_keys_path(config, user, home)
if not os.path.isabs(config):
config = os.path.join(home, config)
config = _expand_authorized_keys_path(config, user, home)
return config

View File

@ -34,6 +34,10 @@ class SSHAuthKeyTestCase(TestCase):
'/home/user')
self.assertEqual(output, '/home//home/user')
output = ssh._expand_authorized_keys_path('%h/foo', 'user',
'/home/user')
self.assertEqual(output, '/home/user/foo')
output = ssh._expand_authorized_keys_path('/srv/%h/aaa/%u%%', 'user',
'/home/user')
self.assertEqual(output, '/srv//home/user/aaa/user%')