saltstack / saltstack/salt

file.managed chmod failed if file attrs has already been set.

Open
#44,197 4 comments 1 reaction 1 assignee View on GitHub

@MKLeb is already working on this.

Since Aug 31, 2023.

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

File chmod failed if attrs has already been set.
We should remove attrs --do chmod -- add old attrs back to avoid chmod failure.

Setup

(Please provide relevant configs and/or SLS files (Be sure to remove sensitive info).)

Steps to Reproduce Issue

(Include debug logs if possible and relevant.)

File:

## file mode is 002 and has a(appendonly) attr. failed to change mode to 222.
[root@localhost ~]# ls -alh /var/log/history/history.log
--------w- 1 root root 5.1K Oct 19 16:19 /var/log/history/history.log
[root@localhost ~]# lsattr /var/log/history/history.log
-----a-------e-- /var/log/history/history.log

Salt states:
history_log_file:
  file.managed:
    - name: /var/log/history/history.log
    - user: root
    - group: root
    - mode: 222
    - attrs: a

Output:
      ID: history_log_file
Function: file.managed
    Name: /var/log/history/history.log
  Result: False
 Comment: Failed to change mode to 0222
 Started: 16:19:06.438731
Duration: 1.575 ms
 Changes:
Versions Report

(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)

[root@localhost ~]# salt --versions-report
Salt Version:
           Salt: 2017.7.2

Dependency Versions:
           cffi: Not Installed
       cherrypy: unknown
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8.1
        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.13 (default, Jul 12 2017, 17:32:34)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.5.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: centos 6.9 Final
         locale: UTF-8
        machine: x86_64
        release: 2.6.32-431.23.3.el6.x86_64
         system: Linux
        version: CentOS 6.9 Final

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.