Skip to content

Commit 0709e59

Browse files
committed
job-ingest: reject jobs for user root unless owner=root
Problem: In a multi-user flux instance, user root is able to submit jobs successfully, but the later fail to execute because the IMP refuses to run procesess as root. If the instance owner userid is not 0, refuse to accept jobs submitted as root with a reasonable error message. Fixes #6144
1 parent 10cdf3b commit 0709e59

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#endif
1414
#include <time.h>
1515
#include <unistd.h>
16+
#include <sys/types.h>
1617
#include <jansson.h>
1718
#include <flux/core.h>
1819
#if HAVE_FLUX_SECURITY
@@ -84,6 +85,7 @@ static int max_fluid_generator_id = 16384 - 16 - 1;
8485
struct job_ingest_ctx {
8586
flux_t *h;
8687
struct pipeline *pipeline;
88+
uid_t owner;
8789
#if HAVE_FLUX_SECURITY
8890
flux_security_t *sec;
8991
#else
@@ -574,6 +576,13 @@ static void submit_cb (flux_t *h, flux_msg_handler_t *mh,
574576
errmsg = error.text;
575577
goto error;
576578
}
579+
/* Do not allow root user to submit jobs in a multi-user instance.
580+
* The jobs will fail at runtime anyway.
581+
*/
582+
if (ctx->owner != 0 && job->cred.userid == 0) {
583+
errmsg = "submission of jobs as user root not supported";
584+
goto error;
585+
}
577586
if (pipeline_process_job (ctx->pipeline, job, &f, &error) < 0) {
578587
errmsg = error.text;
579588
goto error;
@@ -797,6 +806,8 @@ int job_ingest_ctx_init (struct job_ingest_ctx *ctx,
797806
ctx->h = h;
798807
flux_error_t error;
799808

809+
ctx->owner = getuid ();
810+
800811
/* Default worker input buffer size is 10MB */
801812
ctx->buffer_size = "10M";
802813

0 commit comments

Comments
 (0)