Skip to content

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

Description

@zhujinhe

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions