Skip to content

Commit 1f0f861

Browse files
committed
job-ingest: add module parameter to allow root jobs
Problem: Jobs submitted as root are rejected by the job-ingest module if the instance owner is not also root, but some tests may need to simulate submission of jobs to an instance running as root. Add a job-ingest module parameter `allow-root-jobs`, which disables the check for uid=0 when used.
1 parent afcb43a commit 1f0f861

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/modules/job-ingest/job-ingest.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ static const double batch_timeout = 0.01;
8282
*/
8383
static int max_fluid_generator_id = 16384 - 16 - 1;
8484

85+
/* By default, root (userid=0) jobs are rejected at submission
86+
* unless the instance owner is also root. However, for testing
87+
* purposes it may be useful to allow root jobs:
88+
*/
89+
static bool allow_root_jobs = false;
90+
8591
struct job_ingest_ctx {
8692
flux_t *h;
8793
struct pipeline *pipeline;
@@ -579,7 +585,7 @@ static void submit_cb (flux_t *h, flux_msg_handler_t *mh,
579585
/* Do not allow root user to submit jobs in a multi-user instance.
580586
* The jobs will fail at runtime anyway.
581587
*/
582-
if (ctx->owner != 0 && job->cred.userid == 0) {
588+
if (ctx->owner != 0 && !allow_root_jobs && job->cred.userid == 0) {
583589
errmsg = "submission of jobs as user root not supported";
584590
goto error;
585591
}
@@ -703,6 +709,9 @@ static int job_ingest_configure (struct job_ingest_ctx *ctx,
703709
else if (strstarts (argv[i], "max-fluid-generator-id=")) {
704710
max_fluid_id = argv[i] + 23;
705711
}
712+
else if (streq (argv[i], "allow-root-jobs")) {
713+
allow_root_jobs = true;
714+
}
706715
else {
707716
errprintf (error, "Invalid option: %s", argv[i]);
708717
errno = EINVAL;

0 commit comments

Comments
 (0)