Skip to content

Commit c7e9ebc

Browse files
authored
Merge pull request #2433 from larsewi/chown-no-dereference-build-host
Fixed chown of root owned files escaping the jenkins home
2 parents 792bfa2 + db73513 commit c7e9ebc

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎ci/setup-cfengine-build-host.sh‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ fi
1818
# Fixes and names just the root owned files. chown -R over the whole tree clears
1919
# setuid bits, which stripped /usr/bin/sudo inside every image in the rootless
2020
# container store under /home/jenkins.
21-
function chown-root-owned-to-jenkins()
22-
{
23-
root_owned=$(find /home/jenkins -user root -print 2>/dev/null | head -n 20)
21+
#
22+
# chown -h: to avoid following symlinks
23+
# -path /home/jenkins/testmachine-chroot --prune: do not touch this directory
24+
function chown-root-owned-to-jenkins() {
25+
root_owned=$(find /home/jenkins -path /home/jenkins/testmachine-chroot -prune -o -user root -print 2>/dev/null | head -n 20)
2426
if [ -n "$root_owned" ]; then
2527
echo "Root owned files in /home/jenkins (first 20), chowning all to jenkins:"
2628
echo "$root_owned"
27-
find /home/jenkins -user root -exec chown jenkins {} \;
29+
find /home/jenkins -path /home/jenkins/testmachine-chroot -prune -o -user root -exec chown -h jenkins {} \;
2830
fi
2931
}
3032

0 commit comments

Comments
 (0)