[Fluorine] State file.directory recurse: When both file_mode and dir_mode are supplied, file_mode overrides dir_mode for the directory itself
Open
Nobody has claimed this yet.
bug
severity-medium
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description of Issue/Question
Hi, I have an issue with file.directory state, when both file_mode and dir_mode are supplied, file_mode overrides dir_mode for the directory itself
According to Saltstack Document, file_mode for permission of files, dir_mode for permission of directories.
Setup
[root@localhost salttest]# pwd
/tmp/salttest
[root@localhost salttest]# tree -up .
.
├── [drwxr-xr-x root ] dir_one
│ └── [drwxr-xr-x root ] dir_two
│ └── [-rw-r--r-- root ] testfile.txt
├── [-rw-r--r-- root ] file_perm.sls
└── [-rw-r--r-- root ] top.sls
2 directories, 3 files
[root@localhost salttest]# cat file_perm.sls
/tmp/salttest/dir_one:
file.directory:
- user: root
- group: root
- dir_mode: 755
- file_mode: 644
- recurse:
- user
- group
- mode
/tmp/salttest/dir_one/dir_two:
file.directory:
- user: root
- group: root
- dir_mode: 755
- makedirs: True
Steps to Reproduce Issue
[root@localhost salttest]# salt-call --local --file-root=/tmp/salttest/ state.apply test=True file_perm
local:
----------
ID: /tmp/salttest/dir_one
Function: file.directory
Result: None
Comment: The following files will be changed:
/tmp/salttest/dir_one: mode - 0644
Started: 14:41:07.828673
Duration: 6.19 ms
Changes:
----------
ID: /tmp/salttest/dir_one/dir_two
Function: file.directory
Result: True
Comment: The directory /tmp/salttest/dir_one/dir_two is in the correct state
Started: 14:41:07.835033
Duration: 0.738 ms
Changes:
Summary for local
------------
Succeeded: 2 (unchanged=1)
Failed: 0
------------
Total states run: 2
Total run time: 6.928 ms
Versions Report
[root@localhost salttest]# salt-call --versions-report
Salt Version:
Salt: 2019.2.0
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.5 (default, Apr 11 2018, 07:36:10)
python-gnupg: Not Installed
PyYAML: 3.10
PyZMQ: 15.3.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: centos 7.5.1804 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-862.3.2.el7.x86_64
system: Linux
version: CentOS Linux 7.5.1804 Core
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the supplied salt-call command and the file.directory state in file_perm.sls. Trace how recurse mode handling applies file_mode and dir_mode, then verify that dir_mode controls directories while file_mode controls files in the resulting state output and permissions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100