From b69a01c714bcbdf9b3d3ce2c41c5008fd6e27381 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Tue, 11 Aug 2015 13:46:41 +0200 Subject: [PATCH] mxqsub: Disallow whitespace in command or command-alias fixes https://github.molgen.mpg.de/mariux64/mxq/issues/20 --- mxqsub.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/mxqsub.c b/mxqsub.c index cbd311c..7faabe1 100644 --- a/mxqsub.c +++ b/mxqsub.c @@ -551,8 +551,10 @@ int main(int argc, char *argv[]) case 'a': p = strchr(optctl.optarg, ' '); - if (p) - *p = 0; + if (p) { + mx_log_crit("--command-alias '%s': String contains whitespace characters.", optctl.optarg); + exit(EX_CONFIG); + } if (!(*optctl.optarg)) { mx_log_crit("--command-alias '%s': String is empty.", optctl.optarg); exit(EX_CONFIG); @@ -647,6 +649,15 @@ int main(int argc, char *argv[]) /* from this point values in argc,argv are the ones of the cluster job */ + if (!arg_program_name) { + p = strchr(argv[0], ' '); + if (p) { + mx_log_crit(" contains whitespace characters. Please set --command-alias if this is intended.", optctl.optarg); + exit(EX_CONFIG); + } + arg_program_name = argv[0]; + } + if (!arg_time) { arg_time = 15; mx_log_warning("option '--runtime' or '-t' not used. Your job will get killed if it runs longer than the default of %d minutes.", arg_time); @@ -656,9 +667,6 @@ int main(int argc, char *argv[]) mx_log_warning("option '--runtime' specifies a runtime longer than 24h. Your job may get killed. Be sure to implement some check pointing."); } - if (!arg_program_name) - arg_program_name = argv[0]; - if (!(*arg_program_name)) { mx_log_crit(" is empty. Please check usage with '%s --help'.", program_invocation_short_name); exit(EX_CONFIG);