From 614fa555c6680fc2fcd782f1b10c8673f8599e5f Mon Sep 17 00:00:00 2001 From: James Foucar Date: Thu, 31 Oct 2024 15:26:56 -0600 Subject: [PATCH] If batch script is already executable, don't chmod it Linux won't let you chmod files you don't own, so the old impl can cause permissions problems when sharing cases. --- CIME/XML/env_batch.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CIME/XML/env_batch.py b/CIME/XML/env_batch.py index aea6342b457..3417b58c3af 100644 --- a/CIME/XML/env_batch.py +++ b/CIME/XML/env_batch.py @@ -298,10 +298,14 @@ def make_batch_script(self, input_template, job, case, outfile=None): fd.write(output_text) # make sure batch script is exectuble - os.chmod( - output_name, - os.stat(output_name).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH, - ) + if not os.access(output_name, os.X_OK): + os.chmod( + output_name, + os.stat(output_name).st_mode + | stat.S_IXUSR + | stat.S_IXGRP + | stat.S_IXOTH, + ) def set_job_defaults(self, batch_jobs, case): if self._batchtype is None: