From 069eead2c99becac40e5ebdffa4904bfac5b30f7 Mon Sep 17 00:00:00 2001
From: Matthieu Hautreux <matthieu.hautreux@cea.fr>
Date: Thu, 9 Aug 2012 14:33:46 -0700
Subject: [PATCH] Fix sbcast's credential to last till the end of a job instead
 of the previous 20 minute time limit.  The previous behavior would fail for
 large files 20 minutes into the transfer.

---
 NEWS                     | 3 +++
 src/common/slurm_cred.c  | 6 ++++--
 src/common/slurm_cred.h  | 3 ++-
 src/slurmctld/proc_req.c | 8 +++++---
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index 59133651ede..6ad438ffbbd 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,9 @@ documents those changes that are of interest to users and admins.
  -- BLUEGENE - updated documentation.
  -- Close the batch job's environment file when it contains no data to avoid
     leaking file descriptors.
+ -- Fix sbcast's credential to last till the end of a job instead of the
+    previous 20 minute time limit.  The previous behavior would fail for
+    large files 20 minutes into the transfer.
 
 * Changes in SLURM 2.4.2
 ========================
diff --git a/src/common/slurm_cred.c b/src/common/slurm_cred.c
index 0b278915b48..55b68819ef3 100644
--- a/src/common/slurm_cred.c
+++ b/src/common/slurm_cred.c
@@ -2177,7 +2177,8 @@ static void _pack_sbcast_cred(sbcast_cred_t *sbcast_cred, Buf buffer)
  *	including digital signature.
  * RET the sbcast credential or NULL on error */
 sbcast_cred_t *create_sbcast_cred(slurm_cred_ctx_t ctx,
-				  uint32_t job_id, char *nodes)
+				  uint32_t job_id, char *nodes,
+				  time_t expiration)
 {
 	Buf buffer;
 	int rc;
@@ -2190,7 +2191,7 @@ sbcast_cred_t *create_sbcast_cred(slurm_cred_ctx_t ctx,
 
 	sbcast_cred = xmalloc(sizeof(struct sbcast_cred));
 	sbcast_cred->ctime      = now;
-	sbcast_cred->expiration = now + DEFAULT_EXPIRATION_WINDOW;
+	sbcast_cred->expiration = expiration;
 	sbcast_cred->jobid      = job_id;
 	sbcast_cred->nodes      = xstrdup(nodes);
 
@@ -2371,4 +2372,5 @@ void  print_sbcast_cred(sbcast_cred_t *sbcast_cred)
 	info("Sbcast_cred: Jobid   %u", sbcast_cred->jobid         );
 	info("Sbcast_cred: Nodes   %s", sbcast_cred->nodes         );
 	info("Sbcast_cred: ctime   %s", ctime(&sbcast_cred->ctime) );
+	info("Sbcast_cred: Expire  %s", ctime(&sbcast_cred->expiration) );
 }
diff --git a/src/common/slurm_cred.h b/src/common/slurm_cred.h
index f77caaa46b4..98312da3ec1 100644
--- a/src/common/slurm_cred.h
+++ b/src/common/slurm_cred.h
@@ -337,7 +337,8 @@ void slurm_cred_print(slurm_cred_t *cred);
  * Caller of extract_sbcast_cred() must xfree returned node string
  */
 sbcast_cred_t *create_sbcast_cred(slurm_cred_ctx_t ctx,
-				 uint32_t job_id, char *nodes);
+				  uint32_t job_id, char *nodes,
+				  time_t expiration);
 sbcast_cred_t *copy_sbcast_cred(sbcast_cred_t *sbcast_cred);
 void          delete_sbcast_cred(sbcast_cred_t *sbcast_cred);
 int           extract_sbcast_cred(slurm_cred_ctx_t ctx,
diff --git a/src/slurmctld/proc_req.c b/src/slurmctld/proc_req.c
index 45c7e8aed1b..6483c3f28ce 100644
--- a/src/slurmctld/proc_req.c
+++ b/src/slurmctld/proc_req.c
@@ -2139,9 +2139,11 @@ static void _slurm_rpc_job_sbcast_cred(slurm_msg_t * msg)
 		       job_info_msg->job_id, uid,
 		       slurm_strerror(error_code));
 		slurm_send_rc_msg(msg, error_code);
-	} else if ((sbcast_cred = create_sbcast_cred(slurmctld_config.cred_ctx,
-						     job_ptr->job_id,
-						     job_ptr->nodes)) == NULL){
+	} else if ((sbcast_cred =
+		    create_sbcast_cred(slurmctld_config.cred_ctx,
+				       job_ptr->job_id,
+				       job_ptr->nodes,
+				       job_ptr->end_time)) == NULL){
 		unlock_slurmctld(job_read_lock);
 		error("_slurm_rpc_job_sbcast_cred JobId=%u cred create error",
 		      job_info_msg->job_id);
-- 
GitLab