From dfdadaa8ca99973bd33b74f6b428bcd26bbdf5e0 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Thu, 29 Oct 2026 23:44:34 +0200 Subject: [PATCH] AppImages: FerretDB and mongo-tools are readable by every user again. releases/fetch.sh downloaded into a mktemp file and moved it into place, so every download kept mktemp's 0600, and the bundled ferretdb and mongo-tools were 0711 after chmod +x. A user other than the owner gets "Permission denied" from such a file, and since today's appimagetool checks for it, all six v12.69 AppImages (i686, x86_64, aarch64, armhf and both musl ones) failed: "has mode 0711, but it must be readable for all users". A download now gets the mode its umask gives a new file, and the AppDir is made a+rX before it is packed. tests/releaseDownloads.test.cjs fails on the old fetch.sh with 711 instead of 755 and checks that a stricter umask is still followed; tests/appImageRuntime.test.cjs pins both. Thanks to xet7 ! --- .github/workflows/AppImage.yml | 4 ++++ releases/fetch.sh | 9 ++++++++- tests/appImageRuntime.test.cjs | 10 ++++++++++ tests/releaseDownloads.test.cjs | 20 ++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/.github/workflows/AppImage.yml b/.github/workflows/AppImage.yml index add7834862..c20a039237 100644 --- a/.github/workflows/AppImage.yml +++ b/.github/workflows/AppImage.yml @@ -405,6 +405,10 @@ jobs: APPRUN sed -i "s/@APPIMAGE_ARCH@/$arch/" AppDir/AppRun chmod +x AppDir/AppRun + # The AppImage runs as whoever starts it, not as this runner, so + # everything in it must be readable by all. v12.69's FerretDB and + # mongo-tools were 0711 and appimagetool refused to pack them. + chmod -R a+rX AppDir - name: Pack the AppImage if: ${{ env.BUILD_THIS == 'true' }} diff --git a/releases/fetch.sh b/releases/fetch.sh index 823dbefc5f..dedbab6240 100755 --- a/releases/fetch.sh +++ b/releases/fetch.sh @@ -86,7 +86,14 @@ while : ; do case "$code" in 2??) if [ "$mode" = check ]; then exit 0; fi - if [ "$out" = "-" ]; then cat "$tmp"; else mv "$tmp" "$out"; fi + if [ "$out" = "-" ]; then cat "$tmp"; else + # mktemp made it 0600, and mv keeps that: a FerretDB or + # mongo-tools fetched here and then `chmod +x`ed was 0711, + # unreadable to anyone else, and appimagetool refused to pack + # it (v12.69). A download gets the mode the umask gives a file. + chmod "$(printf '%o' $(( 0666 & ~$(umask) )))" "$tmp" + mv "$tmp" "$out" + fi exit 0 ;; 401|403|404|410) diff --git a/tests/appImageRuntime.test.cjs b/tests/appImageRuntime.test.cjs index 311f4a66cf..202eae0e0b 100644 --- a/tests/appImageRuntime.test.cjs +++ b/tests/appImageRuntime.test.cjs @@ -92,6 +92,16 @@ test('only orphaned mount directories are removed, never a live one (negative)', 'rm -rf only runs inside the "not currently mounted" branch'); }); +test('everything in the AppDir is readable by every user before it is packed (v12.69)', () => { + // appimagetool refuses an AppDir with a 0711 file, and a user other than the + // one who built it would get "Permission denied" from one. + const build = workflow.slice(workflow.indexOf('- name: Build the AppDir'), workflow.indexOf('- name: Pack the AppImage')); + assert.match(build, /chmod -R a\+rX AppDir/); + assert.ok(workflow.indexOf('chmod -R a+rX AppDir') < workflow.indexOf('./appimagetool AppDir')); + // ...and the downloads it is made of are not 0600 to begin with. + assert.match(fs.readFileSync('releases/fetch.sh', 'utf8'), /chmod "\$\(printf '%o' \$\(\( 0666 & ~\$\(umask\) \)\)\)" "\$tmp"/); +}); + test('the full release waits for every bundle that an AppImage wraps', () => { const job = releaseAll.match(/^ appimage:\n([\s\S]*?)(?=^ \S)/m); assert.ok(job, 'release-all.yml must contain an appimage job'); diff --git a/tests/releaseDownloads.test.cjs b/tests/releaseDownloads.test.cjs index a82fc12507..7c3eb1ebe0 100644 --- a/tests/releaseDownloads.test.cjs +++ b/tests/releaseDownloads.test.cjs @@ -87,6 +87,26 @@ test('a 503 is waited out, and the file arrives', () => { assert.ok(/::warning::/.test(r.stderr), 'and the log says why the job paused'); }); +test('a download is readable by everyone, as an AppImage needs (v12.69)', () => { + // mktemp's 0600 survived the mv, so FerretDB and mongo-tools were 0711 + // after `chmod +x`, and appimagetool refused to pack them. + const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'fetch-')); + const out = path.join(dir, 'ferretdb'); + const r = spawnSync('bash', ['-c', `umask 022; bash "${fetchSh}" -o "${out}" "${base}/ok" && chmod +x "${out}"`], + { encoding: 'utf8', env: Object.assign({}, process.env, { FETCH_SLEEPS: '0' }) }); + assert.strictEqual(r.status, 0, r.stderr); + assert.strictEqual((fs.statSync(out).mode & 0o777).toString(8), '755'); +}); + +test('a download still follows a stricter umask (negative)', () => { + const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'fetch-')); + const out = path.join(dir, 'private'); + const r = spawnSync('bash', ['-c', `umask 077; bash "${fetchSh}" -o "${out}" "${base}/ok"`], + { encoding: 'utf8', env: Object.assign({}, process.env, { FETCH_SLEEPS: '0' }) }); + assert.strictEqual(r.status, 0, r.stderr); + assert.strictEqual((fs.statSync(out).mode & 0o777).toString(8), '600'); +}); + test('a 404 fails at once - it is an answer, not an outage (negative)', () => { const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'fetch-')); const out = path.join(dir, 'nope');