From daaf80127838036a2b90bfa90c49a89de452e2f9 Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Thu, 8 Jun 2006 18:12:56 +0000 Subject: [PATCH] svn merge -r8356:8359 https://eris/svn/slurm/branches/slurm-1.1 --- NEWS | 2 ++ src/srun/reattach.c | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index c288eb7d2c1..ec408804233 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ documents those changes that are of interest to users and admins. -- Fix Bluegene configure to work with the new 64bit libs. -- Fix bug in controller that causes it to segfault when hit with a malformed message. + -- For "srun --attach=X" to other users job, report an error and exit (it + previously just hung). * Changes in SLURM 1.1.1 ======================== diff --git a/src/srun/reattach.c b/src/srun/reattach.c index 8b696505139..82b149f2014 100644 --- a/src/srun/reattach.c +++ b/src/srun/reattach.c @@ -2,7 +2,7 @@ * src/srun/reattach.c - reattach to a running job * $Id$ ***************************************************************************** - * Copyright (C) 2002 The Regents of the University of California. + * Copyright (C) 2002-2006 The Regents of the University of California. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Mark Grondona <grondona@llnl.gov>. * UCRL-CODE-217948. @@ -59,6 +59,8 @@ static pthread_mutex_t active_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t active_cond = PTHREAD_COND_INITIALIZER; static int active = 0; +static bool invalid_user = false; + typedef enum {THD_NEW, THD_ACTIVE, THD_DONE, THD_FAILED} state_t; typedef struct thd { @@ -244,6 +246,7 @@ _get_job_info(srun_step_t *s) static void _get_step_info(srun_step_t *s) { + uid_t my_uid; job_step_info_response_msg_t *resp = NULL; xassert(s->stepid != NO_VAL); @@ -259,6 +262,15 @@ _get_step_info(srun_step_t *s) goto done; } + invalid_user = false; + if ((my_uid = getuid()) != 0) { /* not user root */ + if (my_uid != resp->job_steps->user_id) { + error("Invalid user id"); + invalid_user = true; + /* We let the request continue and log the + * event in SlurmdLog for security purposes */ + } + } s->nodes = xstrdup(resp->job_steps->nodes); s->ntasks = resp->job_steps->num_tasks; @@ -493,6 +505,9 @@ int reattach() _attach_to_job(job); + if (invalid_user) + exit(1); + slurm_mutex_lock(&job->state_mutex); while (job->state < SRUN_JOB_TERMINATED) { pthread_cond_wait(&job->state_cond, &job->state_mutex); -- GitLab