salt icon indicating copy to clipboard operation
salt copied to clipboard

file.managed mode: setuid and setgid only work on second run

Open andreasnuesslein opened this issue 11 years ago • 13 comments

Changing a files user and setting uid needs 2 runs, e.g.

first: File.recurse('/tmp',user='nobody') and then: File.managed('/tmp/check_pidfile',user=root,mode='4750')

-> -rwxrwx--- 1 root nobody 11K Jan 18 15:10 check_pidfile

after a second run of File.managed('/tmp/check_pidfile',user=root,mode='4750') -> -rwsrwx--- 1 root nobody 11K Jan 18 15:10 check_pidfile

andreasnuesslein avatar Jan 18 '15 14:01 andreasnuesslein

Interesting. Can you post the output of salt --versions-report, please?

rallytime avatar Jan 20 '15 23:01 rallytime

Salt: 2014.7.0
Python: 2.7.9 (default, Dec 11 2014, 04:42:00)
Jinja2: 2.7.3
M2Crypto: 0.22
msgpack-python: 0.4.4
msgpack-pure: Not Installed
pycrypto: 2.6.1
libnacl: 1.4.0
PyYAML: 3.11
ioflo: 1.0.1
PyZMQ: 14.4.1
RAET: Not Installed
ZMQ: 4.0.5
Mako: Not Installed

andreasnuesslein avatar Jan 20 '15 23:01 andreasnuesslein

Having the same problem here. This is my salt --versions output.

Salt: 2014.7.2
Python: 2.7.8 (default, Sep  5 2014, 12:34:45)
Jinja2: 2.7.3
M2Crypto: 0.22
msgpack-python: 0.4.6
msgpack-pure: Not Installed
pycrypto: 2.6.1
libnacl: Not Installed
PyYAML: 3.11
ioflo: Not Installed
PyZMQ: 14.4.1
RAET: Not Installed
ZMQ: 4.0.5
Mako: Not Installed

annabzz avatar Apr 07 '15 11:04 annabzz

Seeing this as well on Ubuntu Trusty

kev009 avatar Aug 05 '15 07:08 kev009

Just hit this issue myself:

           Salt: 2015.5.3
         Python: 2.6.9 (unknown, Apr  1 2015, 18:16:00)
         Jinja2: 2.7.2
       M2Crypto: 0.21.1
 msgpack-python: 0.4.6
   msgpack-pure: Not Installed
       pycrypto: 2.6.1
        libnacl: Not Installed
         PyYAML: 3.10
          ioflo: Not Installed
          PyZMQ: 14.3.1
           RAET: Not Installed
            ZMQ: 3.2.5
           Mako: Not Installed
        Tornado: 4.1

Phomias avatar Aug 29 '15 18:08 Phomias

FWIW, I'm still hitting this issue in Salt: 2015.5.8

Phomias avatar Feb 03 '16 15:02 Phomias

For a workaround, make a second state that sets everything again and is dependent on the first state.

generate_salt_key_as_salt:
  file.managed:
    # Make sure to sync this state with the workaround state below.
    - name: {{ app }}/generate_salt_key_as_salt
    - user: salt
    - group: minion_key_mgrs 
    - mode: '4750' #setuid, rwxr-x---

workaround-issue-19834:
  # Because of a bug in salt, we need to run this state again.
  # https://github.com/saltstack/salt/issues/19834
  file.managed:
    - name: {{ app }}/generate_salt_key_as_salt
    - user: salt
    - group: minion_key_mgrs
    - mode: '4750' #setuid, rwxr-x---
    - require:
      - file: generate_salt_key_as_salt

Of course, you could accomplish something similar with a jinja loop. But since it's already a gross workaround I don't mind the copy-paste ugliness.

Phomias avatar Feb 03 '16 16:02 Phomias

I've just got the setgid issue (ie. setting a file group and changing the setgid bit) on a fully updated ArchLinux:

Salt Version:
           Salt: 2016.11.5

Dependency Versions:
          ioflo: 1.6.7
         Jinja2: 2.9.6
        libnacl: 1.5.0
       M2Crypto: 0.24.0
 msgpack-python: 0.4.8
       pycrypto: 2.6.1
         Python: 2.7.13 (default, Feb 11 2017, 12:22:40)
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: 0.6.7
        Tornado: 4.5.1
            ZMQ: 4.2.1

System Versions:
           dist:
        machine: x86_64
        release: 4.10.13-1-ARCH
         system: Linux

@Phomias : thank you for the workaround :)

Arkanosis avatar Jun 04 '17 00:06 Arkanosis

Happy Birthday issue #19834 ! :tada: :birthday: :gift:

ghost avatar Jan 18 '18 08:01 ghost

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar May 05 '19 22:05 stale[bot]

This seems fixed in 2019.2.0, thanks! Could anybody close the issue?

$ salt --versions-report | grep -v 'Not Installed'
Salt Version:
           Salt: 2019.2.0
 
Dependency Versions:
           cffi: 1.12.3
         Jinja2: 2.10.1
       M2Crypto: 0.30.1
 msgpack-python: 0.6.1
      pycparser: 2.19
       pycrypto: 3.8.1
         Python: 2.7.16 (default, Mar 11 2019, 18:59:25)
         PyYAML: 3.13
          PyZMQ: 18.0.1
        Tornado: 5.1.1
            ZMQ: 4.3.1
 
System Versions:
           dist:   
         locale: UTF-8
        machine: x86_64
        release: 5.0.9-arch1-1-ARCH
         system: Linux

Arkanosis avatar May 09 '19 08:05 Arkanosis

Thank you for updating this issue. It is no longer marked as stale.

stale[bot] avatar May 09 '19 08:05 stale[bot]

Yeah seems to be fixed here too :)

andreasnuesslein avatar May 30 '19 13:05 andreasnuesslein