mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #31139 from exowaucka/develop
Improve %h and %u handling in SSH module
This commit is contained in:
commit
f24954dde5
@ -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
|
||||
|
||||
|
||||
|
@ -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%')
|
||||
|
Loading…
Reference in New Issue
Block a user