Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Merge !135: Coach job directory permissions without CAP_DAC_OVERRIDE (T13o)

Duarte Santos020b7f447770
diff --cc api/coach/jobs.js
index f4ab6b050,663d8f01e..e22017415
--- a/api/coach/jobs.js
+++ b/api/coach/jobs.js
@@@ -323,11 -293,9 +324,11 @@@ async function execute(job)
// An HTTPS provider has no child process, so no directory for one to live in either.
const jobDir = adapter.spawns === false ? null : fs.mkdtempSync(path.join(os.tmpdir(), 'coach-'));
const env = cfgStore.jobEnv(jobDir || os.tmpdir(), cfgStore.credentialFor(job.uid));
+ const ctl = new AbortController();
+ aborts.set(job.uid, ctl);
try {
const ids = jobDir && unprivilegedIds();
- if (ids) fs.chownSync(jobDir, ids.uid, ids.gid);
+ if (ids) shareJobDir(jobDir, ids);
const attempt = await runPipeline({
adapter, cfg, kind: job.kind, payload, model: cfgStore.modelFor(cfg), timeoutMs: TIMEOUT_MS,
@@@ -356,8 -321,7 +357,8 @@@
};
return finish(job, { outcome: 'ready', pending });
} finally {
+ aborts.delete(job.uid);
- if (jobDir) fs.rmSync(jobDir, { recursive: true, force: true });
+ if (jobDir) removeJobDir(jobDir, unprivilegedIds());
}
}