Skip to content

Commit d9086f6

Browse files
authored
Merge pull request #12214 from Mab879/fix_file_owner_bash
Adjust bash template (group)file_owner to follow symlinks
2 parents 71477d1 + 07fd359 commit d9086f6

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

shared/templates/file_groupowner/bash.template

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
{{%- if RECURSIVE %}}
88
{{%- set FIND_RECURSE_ARGS="" %}}
99
{{%- else %}}
10-
{{%- set FIND_RECURSE_ARGS="-maxdepth 1" %}}
10+
{{%- set FIND_RECURSE_ARGS="-maxdepth 1 -L" %}}
1111
{{%- endif %}}
1212

1313
{{%- for path in FILEPATH %}}
1414
{{%- if IS_DIRECTORY %}}
1515
{{%- if FILE_REGEX %}}
1616

17-
find {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f ! -group {{{ GID_OR_NAME }}} -regextype posix-extended -regex '{{{ FILE_REGEX[loop.index0] }}}' -exec chgrp {{{ GID_OR_NAME }}} {} \;
17+
find {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f ! -group {{{ GID_OR_NAME }}} -regextype posix-extended -regex '{{{ FILE_REGEX[loop.index0] }}}' -exec chgrp -L {{{ GID_OR_NAME }}} {} \;
1818
{{%- else %}}
19-
find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type d -exec chgrp {{{ GID_OR_NAME }}} {} \;
19+
find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type d -exec chgrp -L {{{ GID_OR_NAME }}} {} \;
2020
{{%- endif %}}
2121
{{%- else %}}
22-
chgrp {{{ GID_OR_NAME }}} {{{ path }}}
22+
chgrp -L {{{ GID_OR_NAME }}} {{{ path }}}
2323
{{%- endif %}}
2424
{{%- endfor %}}

shared/templates/file_owner/bash.template

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
{{%- if RECURSIVE %}}
88
{{%- set FIND_RECURSE_ARGS="" %}}
99
{{%- else %}}
10-
{{%- set FIND_RECURSE_ARGS="-maxdepth 1" %}}
10+
{{%- set FIND_RECURSE_ARGS="-maxdepth 1 -L" %}}
1111
{{%- endif %}}
1212

1313
{{%- for path in FILEPATH %}}
1414
{{%- if IS_DIRECTORY %}}
1515
{{%- if FILE_REGEX %}}
1616

17-
find {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f ! -uid {{{ FILEUID }}} -regextype posix-extended -regex '{{{ FILE_REGEX[loop.index0] }}}' -exec chown {{{ FILEUID }}} {} \;
17+
find {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f ! -uid {{{ FILEUID }}} -regextype posix-extended -regex '{{{ FILE_REGEX[loop.index0] }}}' -exec chown -L {{{ FILEUID }}} {} \;
1818
{{%- else %}}
19-
find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type d -exec chown {{{ FILEUID }}} {} \;
19+
find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type d -exec chown -L {{{ FILEUID }}} {} \;
2020
{{%- endif %}}
2121
{{%- else %}}
22-
chown {{{ FILEUID }}} {{{ path }}}
22+
chown -L {{{ FILEUID }}} {{{ path }}}
2323
{{%- endif %}}
2424
{{%- endfor %}}

0 commit comments

Comments
 (0)