Skip to content

Commit

Permalink
Reject container-save arguments with a trailing '/'
Browse files Browse the repository at this point in the history
See: NVIDIA/enroot#215

Signed-off-by: Felix Abecassis <[email protected]>
  • Loading branch information
flx42 committed Nov 5, 2024
1 parent 4245638 commit f2b5da4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions args.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ static int spank_option_container_save(int val, const char *optarg, int remote)
return (-1);
}

if (optarg[strlen(optarg) - 1] == '/') {
slurm_error("pyxis: --container-save: target is a directory");
return (-1);
}

/* Slurm can call us twice with the same value, check if it's a different value than before. */
if (pyxis_args.container_save != NULL) {
if (strcmp(pyxis_args.container_save, optarg) == 0)
Expand Down
11 changes: 11 additions & 0 deletions tests/invalid_args.bats
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,14 @@ load ./common
run_srun_unchecked --container-env FOO, --container-image=ubuntu:22.04 true
[ "${status}" -ne 0 ]
}

@test "invalid arg: --container-save=<directory>" {
run_srun_unchecked --container-save=/tmp/ --container-image=ubuntu:24.04 true
[ "${status}" -ne 0 ]

run_srun_unchecked --container-save=/ --container-image=ubuntu:24.04 true
[ "${status}" -ne 0 ]

run_srun_unchecked --container-save=./ --container-image=ubuntu:24.04 true
[ "${status}" -ne 0 ]
}

0 comments on commit f2b5da4

Please sign in to comment.