Allow some plugins to read from playbook dir

Currently the lookup plugins are only permitted to read data
from the work dir.  Some of them expect to read files based on
the CWD which Ansible sets to be the playbook directory.  In the
case that the lookup plugins are being run by a playbook in a
project which is in the dependency chain, that will work fine.
But if the playbook project is not in the dependency chain, it
is checked out into the "trusted/" directory in the jobdir, which
is outside of the work dir.  In this case, the lookup plugin will
fail.

Alter the lookup plugins to permit access to the "trusted/"
directory as well as "work/".  This is safe because these plugins
only read files, not write.  And the only content in the "trusted/"
directory is git repository checkouts which the user already has
access to.

Also allow the include_vars and synchronize action modules access
to read files from these directories.

The current tests are sufficient to show that current behavior is
not broken by this change.  A followup change moves all playbook
project checkouts outside of the work directory, so that case will
be tested then.

Change-Id: Ie2e5b0d1c099d4f9cf59c1e67fb0603d7c5f757b
This commit is contained in:
James E. Blair
2018-04-05 09:54:28 -07:00
parent c56edfbc74
commit b4385b2d93
9 changed files with 12 additions and 11 deletions

View File

@@ -35,7 +35,7 @@ class LookupModule(LookupBase):
dwimmed_path = self.find_file_in_search_path(
variables, 'files', os.path.dirname(term))
if dwimmed_path:
paths._fail_if_unsafe(dwimmed_path)
paths._fail_if_unsafe(dwimmed_path, allow_trusted=True)
globbed = glob.glob(to_bytes(
os.path.join(dwimmed_path, term_file),
errors='surrogate_or_strict'))