Skip to content

Commit

Permalink
chroot connection plugin: defer get_option() call (ansible#59065)
Browse files Browse the repository at this point in the history
* The chroot connection plugin crashes because its constructor calls
  self.get_option(...) before the plugin loader has established its
  self._load_name.  Therefore, we should defer the self.get_option(...)
  call so that it happens in connect().

Fixes ansible#59063
  • Loading branch information
dpoon authored and s-hertel committed Jul 16, 2019
1 parent 88c4cf2 commit b16c264
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ansible/plugins/connection/chroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def __init__(self, play_context, new_stdin, *args, **kwargs):
if not (is_executable(chrootsh) or (os.path.lexists(chrootsh) and os.path.islink(chrootsh))):
raise AnsibleError("%s does not look like a chrootable dir (/bin/sh missing)" % self.chroot)

def _connect(self):
''' connect to the chroot '''
if os.path.isabs(self.get_option('chroot_exe')):
self.chroot_cmd = self.get_option('chroot_exe')
else:
Expand All @@ -104,8 +106,6 @@ def __init__(self, play_context, new_stdin, *args, **kwargs):
if not self.chroot_cmd:
raise AnsibleError("chroot command (%s) not found in PATH" % to_native(self.get_option('chroot_exe')))

def _connect(self):
''' connect to the chroot; nothing to do here '''
super(Connection, self)._connect()
if not self._connected:
display.vvv("THIS IS A LOCAL CHROOT DIR", host=self.chroot)
Expand Down

0 comments on commit b16c264

Please sign in to comment.