fix ssh_wrap to use Shellwords.escape - #996
Merged
Merged
Conversation
This was referenced Sep 25, 2026
johrstrom
approved these changes
Oct 5, 2026
johrstrom
left a comment
Contributor
There was a problem hiding this comment.
Tested at OSC and it works for me for to both slurm (for sbatch and other things like sacctmgr) and linux host adapters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
ssh_wrappassed the command, its arguments, and env values through tosshunescaped.SSH does no escaping of its own — the remote shell re-parses the whole command string — so
any argument containing a shell metacharacter gets mangled.
The reporter's example: an LSF resource request like
-R select[mem>4000]has its>interpreted as a redirect on the remote host, so the job is never submitted correctly.
Arguments with spaces split, and env values were interpolated raw into
export KEY=VALUE;.ssh_wrapnow shell-escapescmd_argsand env values. The escaping happens after theexisting early return:
so sites not using
submit_hostare unaffected — they return before reaching it, andOpen3.capture3passes arguments as separate argv entries with no shell involved.Related issue
Closes #923
Testing
Three existing assertions in
spec/job/adapters/helper_spec.rbupdated — they used aJob Namefixture with a space and asserted the unescaped output. The two local-pathassertions are unchanged and confirm no behavior change without
submit_host.New
test/job/adapters/helper_test.rbcovers the reporter'sselect[mem>4000]case, asemicolon, env values with spaces, and the no-
submit_hostpath.bundle exec rake testandbundle exec rake specare green.Checklist
Anything else?
Sites currently working around this will need to stop. @keysmashes noted manually
.shellescape-ingnativearguments insubmit.yml.erbto get LSF submission workingover SSH. After this, those get escaped twice. Worth a release note.
On double-escaping, per @johrstrom's caution on the issue: I checked the other escaping
in the adapters.
torque.rb:136escapes envvars, but that is in the hash-nativebranchwhich submits through the pbs-ruby bindings, not through
ssh_wrap— separate path, nooverlap. The
Shellwordsuse inkubernetes/helper.rbis asplit, not an escape.Affects every adapter that submits over SSH: slurm, psij, pbspro, sge, htcondor, torque,
lsf.