Skip to content

Fix execute chown and chgrp for symlink #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Fix execute chown and chgrp for symlink #6

wants to merge 2 commits into from

Conversation

tryfunc
Copy link
Contributor

@tryfunc tryfunc commented Aug 11, 2019

Description

Used resource:

recursive_file_permissions { '/usr/lib/one/sunstone':
    file_mode => '0644',
    dir_mode  => '0755',
    owner     => 'root',
    group     => 'oneadmin',
}

exec:

find /usr/lib/one/sunstone "(" -type f '!' -perm 0644 ")" \
-o "(" -type d '!' -perm 0755 ")" \
-o "(" '!' -user root ")" \
-o "(" '!' -group oneadmin ")" | grep '.*'

result:

/usr/lib/one/sunstone/public/dist/main.js

this is symlink:

ls -la main.js
lrwxrwxrwx 1 oneadmin oneadmin 29 Apr  7 15:21 main.js -> /var/lib/one/sunstone/main.js

The next step is to run the chown command for the file /usr/lib/one/sunstone/public/dist/main.js, which modifies /var/lib/one/sunstone/main.js. But next time the puppet will find the given file again. (recursive loop).

The resource should change the symlink, not the file that she points to.

Fixes

Use the -h option for chown and chgrp. This option is supported by all operating systems for which support for this module is claimed.

--dereference
affect the referent of each symbolic link (this is the default),
rather than the symbolic link itself

-h, --no-dereference
affect each symbolic link instead of any referenced file
(useful only on systems that can change the ownership/group of a symlink)

Signed-off-by: Vadim Chernyshev <tryfunc@gmail.com>
Signed-off-by: Vadim Chernyshev <tryfunc@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants