You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/units
Sean Reifschneider 243aea45ce
Symbolic modes with X or =[ugo] always use original mode (#80132)
* Symbolic modes with X or =[ugo] always use original mode (Fixes #80128)

Here's what's happening, by way of this mode example: u=,u=rX

At the first step in the loop, the "u" bits of are set to 0. On the next
step in the loop, the current stat of the filesystem object is used to
determine X, not the "new_mode" in the previous iteration of the loop. So
while most operations kind of operate left to right, "X" is always going
back to the original file to determine whether to set x bit.

The Linux "chmod" (the only one I've tested) doesn't operate this way. In
it, "X" operates on the current state the loop understands it is in,
based on previous operations (and starting with the file permissions).

This is an issue with "X" and any of the "=[ugo]" settings, because
they are lookups. For example, if a file is 755 and you do "ug=rx,o=u",
file module produces 0557 and chmod produces 0555.

This really becomes a problem when you want to recursively change a
directory of files, and the files are currently 755, but you want to
change the directory to 750 and the files to 640. In chmod you can do
"a=,ug=rX,u+w" (or "a=,u=rwX,g=rX"), and have it apply equally to the
directory and the files. I can't come up with a single way in the ansible
file module to deterministically, recursively, set a directory to 750
and the contents to 640 no matter what the current permissions are,
as the code currently is.

The fix is to pass in "new_mode" to _get_octal_mode_from_symbolic_perms
in lib/ansible/module_utils/basic.py inside _symbolic_mode_to_octal. And
then take "new_mode" as an argument and use it instead of the filesystem
object stat.st_mode value.

* Fixing my new unit test, fixing bug in test comments
3 years ago
..
_vendor Clean up unused imports in unit tests (#79893) 3 years ago
ansible_test Replace validate-modules's semantic markup parser with antsibull-docs-parser (#80406) 3 years ago
cli Remove unused and unreachable unit test code (#79854) 3 years ago
compat Clean up unused imports in unit tests (#79893) 3 years ago
config ansible-playbook -K breaks when passwords have quotes (#79837) 3 years ago
errors Clean up unit tests. (#78498) 3 years ago
executor Do not double calculate loops and `delegate_to` (#80171) 3 years ago
galaxy Clean up unused imports in unit tests (#79893) 3 years ago
inventory Fix pointless statements in unit tests (#79940) 3 years ago
inventory_test_data/group_vars Merge branch 'v2_final' into devel_switch_v2 11 years ago
mock Remove unused unit test code (#79879) 3 years ago
module_utils Only use the selectors code path when we are prompt matching (#79931) 3 years ago
modules Symbolic modes with X or =[ugo] always use original mode (#80132) 3 years ago
parsing Add support for importlib.resources (#78915) 3 years ago
playbook Raise an error on invalid FA.isa value (#80040) 3 years ago
plugins password lookup, handle ident properly when saved (#80251) 3 years ago
regex Add toggle to control invalid character substitution in group names (#52748) 7 years ago
template Clean up unused imports in unit tests (#79893) 3 years ago
utils add a worker queue to get updates from the main results thread (#79886) 3 years ago
vars Fix pointless statements in unit tests (#79940) 3 years ago
__init__.py Add empty-init code-smell script. (#18406) 9 years ago
requirements.txt Update unit test controller requirements. (#78376) 3 years ago
test_context.py Clean up unit test boilerplate. 6 years ago
test_no_tty.py ansible-test - Fix subprocess management. (#77641) 4 years ago