salt
salt copied to clipboard
git.latest fails if cloning into a directory with group-only permission
Test case:
/srv/salt $ cat test/init.sls
a_shared_groop:
group.present:
- gid: 2000
a_user:
user.present:
- uid: 1001
- groups:
- a_shared_groop
- require:
- group.present: a_shared_groop
/tmp/shared:
file.directory:
- user: root
- group: a_shared_groop
- mode: 775
- require:
- group.present: a_shared_groop
https://github.com/saltstack/salt.git:
git.latest:
- rev: develop
- target: /tmp/shared/salt
- runas: a_user
- require:
- user.present: a_user
- file.directory: /tmp/shared
Output:
[INFO ] Executing command 'git clone https://github.com/saltstack/salt.git /tmp/shared/salt ' as user 'a_user' in directory '/home/a_user'
[ERROR ] Command 'git clone https://github.com/saltstack/salt.git /tmp/shared/salt ' failed with return code: 128
[ERROR ] stderr: fatal: could not create work tree dir '/tmp/shared/salt'.: Permission denied
[ERROR ] No changes made for https://github.com/saltstack/salt.git
local:
----------
State: - group
Name: a_shared_groop
Function: present
Result: True
Comment: No change
Changes:
----------
State: - file
Name: /tmp/shared
Function: directory
Result: True
Comment: Directory /tmp/shared is in the correct state
Changes:
----------
State: - user
Name: a_user
Function: present
Result: True
Comment: User a_user is present and up to date
Changes:
----------
State: - git
Name: https://github.com/saltstack/salt.git
Function: latest
Result: False
Comment: fatal: could not create work tree dir '/tmp/shared/salt'.: Permission denied
Changes:
The underlying issue appears to be in the implementation of cmd.run.
$ salt-call cmd.run 'touch /tmp/shared/file' /tmp/ a_user
[INFO ] Loaded configuration file: /etc/salt/minion
[WARNING ] Package debconf-utils is not installed.
[INFO ] Executing command 'touch /tmp/shared/file' as user 'a_user' in directory '/tmp/'
local:
touch: cannot touch `/tmp/shared/file': Permission denied
$ ls -ld /tmp/shared
drwxrwxr-x 2 root a_shared_groop 4096 Mar 29 18:22 /tmp/shared
$ su a_user
$ id
uid=1001(a_user) gid=1001(a_user) groups=1001(a_user),2000(a_shared_groop)
$ touch /tmp/shared/baz
$
Reporting this on behalf of @cvrebert.
This is a really good catch, thanks @dlindquist and @cvrebert! We were not setting supplemental groups when shelling out, which was a pretty big oversight. Should be fixed in my pull req: #4396