mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 15:17:30 +00:00
fix(docker): look at the volume roots only, and say when chown is refused
The ownership check still read every inode of the volumes on each start. It now looks at the dirs and what sits directly in them, hands a volume over once when it is not node's, and logs a warning instead of walking a volume that refuses chown (NFS with root_squash).
This commit is contained in:
@@ -59,12 +59,22 @@ describe('entrypoint script', () => {
|
||||
.filter((line) => !line.trimStart().startsWith('#'))
|
||||
.join('\n');
|
||||
|
||||
it('never chowns the volumes recursively and unconditionally', () => {
|
||||
expect(code).not.toMatch(/chown\s+-R/);
|
||||
expect(code).toContain('! -user node -o ! -group node');
|
||||
it('never walks the volumes on a start where they already belong to node', () => {
|
||||
// Only the dir and its direct entries are looked at, never the whole tree.
|
||||
expect(code).toContain('find "$dir" -maxdepth 1 \\( ! -user node -o ! -group node \\) -print -quit');
|
||||
expect(code).not.toMatch(/find "\$dir" \\\(/);
|
||||
// The recursive hand-over sits behind that check and behind a chown of the dir that worked.
|
||||
const check = code.indexOf('-maxdepth 1');
|
||||
const dirChown = code.indexOf('if chown node:node "$dir"');
|
||||
expect(dirChown).toBeGreaterThan(check);
|
||||
expect(code.indexOf('chown -R')).toBeGreaterThan(dirChown);
|
||||
expect(code).toContain('Correcting ownership of $dir for the node user...');
|
||||
});
|
||||
|
||||
it('says so once instead of walking a volume that refuses chown', () => {
|
||||
expect(code).toContain('cannot be handed to the node user (chown refused); run the container as uid 1000 instead.');
|
||||
});
|
||||
|
||||
// Under runAsUser: 1000 there is no privilege to drop and gosu cannot switch
|
||||
// users, so the non-root branch has to exec Node itself before any chown or gosu.
|
||||
it('starts Node directly, without chown or gosu, when not running as root', () => {
|
||||
|
||||
Reference in New Issue
Block a user