Skip to content

Commit c87f49f

Browse files
Don't preserve ownership when copying pack contents (#418)
This change aims to preserve file attributes when copying via rsync or cp, without ownership to enable environments where containers are ran without root privileges. Co-authored-by: Daniel Porter <[email protected]>
1 parent c7e9f09 commit c87f49f

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Stop generating the checksum labels for Auth Secret (#392) when existing secret provided or disabled (by @bmarick)
88
* Use `image.pullPolicy` for all containers including init containers that use `image.utilityImage`. (#397) (by @jk464)
99
* Use `rsync` to copy pack contents when available, falling back to `cp`. (#414) (by @cognifloyd)
10+
* Support non-root container environments when copying pack contents (#414) (by @Stealthii)
1011

1112
## v1.0.0
1213
* Bump to latest CircleCI orb versions ([email protected] and [email protected] by @ZoeLeah)

templates/_helpers.tpl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,12 @@ Merge packs and virtualenvs from st2 with those from st2packs images
344344
- 'sh'
345345
- '-ec'
346346
- >
347-
if command rsync; then
348-
rsync -a /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
349-
rsync -a /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared;
347+
if hash rsync 2>/dev/null; then
348+
rsync -rlptD /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
349+
rsync -rlptD /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared;
350350
else
351-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
352-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared;
351+
cp -P --preserve=mode,timestamps,links,xattr /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
352+
cp -P --preserve=mode,timestamps,links,xattr /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared;
353353
fi
354354
{{- with .securityContext | default $.Values.st2actionrunner.securityContext | default $.Values.securityContext }}
355355
{{/* st2actionrunner is likely the most permissive so use that if defined. */}}
@@ -371,12 +371,12 @@ Merge packs and virtualenvs from st2 with those from st2packs images
371371
- 'sh'
372372
- '-ec'
373373
- >
374-
if command rsync; then
375-
rsync -a /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
376-
rsync -a /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared;
374+
if hash rsync 2>/dev/null; then
375+
rsync -rlptD /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
376+
rsync -rlptD /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared;
377377
else
378-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
379-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
378+
cp -P --preserve=mode,timestamps,links,xattr /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
379+
cp -P --preserve=mode,timestamps,links,xattr /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
380380
fi
381381
{{- with .Values.st2actionrunner.securityContext | default .Values.securityContext }}
382382
{{/* st2actionrunner is likely the most permissive so use that if defined. */}}
@@ -397,10 +397,10 @@ Merge packs and virtualenvs from st2 with those from st2packs images
397397
- 'sh'
398398
- '-ec'
399399
- >
400-
if command rsync; then
401-
rsync -a /opt/stackstorm/configs/. /opt/stackstorm/configs-shared;
400+
if hash rsync 2>/dev/null; then
401+
rsync -rlptD /opt/stackstorm/configs/. /opt/stackstorm/configs-shared;
402402
else
403-
/bin/cp -aR /opt/stackstorm/configs/. /opt/stackstorm/configs-shared;
403+
cp -P --preserve=mode,timestamps,links,xattr /opt/stackstorm/configs/. /opt/stackstorm/configs-shared;
404404
fi
405405
{{- with .Values.st2actionrunner.securityContext | default .Values.securityContext }}
406406
{{/* st2actionrunner is likely the most permissive so use that if defined. */}}

0 commit comments

Comments
 (0)