Allow root to request the version and help from mpirun without having to override the run-as-root protection.
Thanks to Robert McLay for pointing this out
Этот коммит содержится в:
родитель
89e14f5ad6
Коммит
2f365720b0
@ -656,24 +656,6 @@ int orterun(int argc, char *argv[])
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* check if we are running as root - if we are, then only allow
|
||||
* us to proceed if the allow-run-as-root flag was given. Otherwise,
|
||||
* exit with a giant warning flag
|
||||
*/
|
||||
if (0 == geteuid() && !orterun_globals.run_as_root) {
|
||||
/* show_help is not yet available, so print an error manually */
|
||||
fprintf(stderr, "--------------------------------------------------------------------------\n");
|
||||
fprintf(stderr, "%s has detected an attempt to run as root. This is *strongly*\n", orte_basename);
|
||||
fprintf(stderr, "discouraged as any mistake (e.g., in defining TMPDIR) or bug can\n");
|
||||
fprintf(stderr, "result in catastrophic damage to the OS file system, leaving\n");
|
||||
fprintf(stderr, "your system in an unusable state.\n\n");
|
||||
fprintf(stderr, "You can override this protection by adding the --allow-run-as-root\n");
|
||||
fprintf(stderr, "option to your cmd line. However, we reiterate our strong advice\n");
|
||||
fprintf(stderr, "against doing so - please do so at your own risk.\n");
|
||||
fprintf(stderr, "--------------------------------------------------------------------------\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Since this process can now handle MCA/GMCA parameters, make sure to
|
||||
* process them.
|
||||
@ -699,6 +681,71 @@ int orterun(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* print version if requested. Do this before check for help so
|
||||
that --version --help works as one might expect. */
|
||||
if (orterun_globals.version) {
|
||||
char *str, *project_name = NULL;
|
||||
if (0 == strcmp(orte_basename, "mpirun")) {
|
||||
project_name = "Open MPI";
|
||||
} else {
|
||||
project_name = "OpenRTE";
|
||||
}
|
||||
str = opal_show_help_string("help-orterun.txt", "orterun:version",
|
||||
false,
|
||||
orte_basename, project_name, OPAL_VERSION,
|
||||
PACKAGE_BUGREPORT);
|
||||
if (NULL != str) {
|
||||
printf("%s", str);
|
||||
free(str);
|
||||
}
|
||||
opal_finalize();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Check for help request */
|
||||
if (orterun_globals.help) {
|
||||
char *str, *args = NULL;
|
||||
char *project_name = NULL;
|
||||
if (0 == strcmp(orte_basename, "mpirun")) {
|
||||
project_name = "Open MPI";
|
||||
} else {
|
||||
project_name = "OpenRTE";
|
||||
}
|
||||
args = opal_cmd_line_get_usage_msg(&cmd_line);
|
||||
str = opal_show_help_string("help-orterun.txt", "orterun:usage", false,
|
||||
orte_basename, project_name, OPAL_VERSION,
|
||||
orte_basename, args,
|
||||
PACKAGE_BUGREPORT);
|
||||
if (NULL != str) {
|
||||
printf("%s", str);
|
||||
free(str);
|
||||
}
|
||||
free(args);
|
||||
|
||||
/* If someone asks for help, that should be all we do */
|
||||
opal_finalize();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* check if we are running as root - if we are, then only allow
|
||||
* us to proceed if the allow-run-as-root flag was given. Otherwise,
|
||||
* exit with a giant warning flag
|
||||
*/
|
||||
if (0 == geteuid() && !orterun_globals.run_as_root) {
|
||||
/* show_help is not yet available, so print an error manually */
|
||||
fprintf(stderr, "--------------------------------------------------------------------------\n");
|
||||
fprintf(stderr, "%s has detected an attempt to run as root. This is *strongly*\n", orte_basename);
|
||||
fprintf(stderr, "discouraged as any mistake (e.g., in defining TMPDIR) or bug can\n");
|
||||
fprintf(stderr, "result in catastrophic damage to the OS file system, leaving\n");
|
||||
fprintf(stderr, "your system in an unusable state.\n\n");
|
||||
fprintf(stderr, "You can override this protection by adding the --allow-run-as-root\n");
|
||||
fprintf(stderr, "option to your cmd line. However, we reiterate our strong advice\n");
|
||||
fprintf(stderr, "against doing so - please do so at your own risk.\n");
|
||||
fprintf(stderr, "--------------------------------------------------------------------------\n");
|
||||
opal_finalize();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* may look strange, but the way we handle prefix is a little weird
|
||||
* and probably needs to be addressed more fully at some future point.
|
||||
* For now, we have a conflict between app_files and cmd line usage.
|
||||
@ -1176,50 +1223,6 @@ static int init_globals(void)
|
||||
|
||||
static int parse_globals(int argc, char* argv[], opal_cmd_line_t *cmd_line)
|
||||
{
|
||||
/* print version if requested. Do this before check for help so
|
||||
that --version --help works as one might expect. */
|
||||
if (orterun_globals.version) {
|
||||
char *str, *project_name = NULL;
|
||||
if (0 == strcmp(orte_basename, "mpirun")) {
|
||||
project_name = "Open MPI";
|
||||
} else {
|
||||
project_name = "OpenRTE";
|
||||
}
|
||||
str = opal_show_help_string("help-orterun.txt", "orterun:version",
|
||||
false,
|
||||
orte_basename, project_name, OPAL_VERSION,
|
||||
PACKAGE_BUGREPORT);
|
||||
if (NULL != str) {
|
||||
printf("%s", str);
|
||||
free(str);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Check for help request */
|
||||
if (orterun_globals.help) {
|
||||
char *str, *args = NULL;
|
||||
char *project_name = NULL;
|
||||
if (0 == strcmp(orte_basename, "mpirun")) {
|
||||
project_name = "Open MPI";
|
||||
} else {
|
||||
project_name = "OpenRTE";
|
||||
}
|
||||
args = opal_cmd_line_get_usage_msg(cmd_line);
|
||||
str = opal_show_help_string("help-orterun.txt", "orterun:usage", false,
|
||||
orte_basename, project_name, OPAL_VERSION,
|
||||
orte_basename, args,
|
||||
PACKAGE_BUGREPORT);
|
||||
if (NULL != str) {
|
||||
printf("%s", str);
|
||||
free(str);
|
||||
}
|
||||
free(args);
|
||||
|
||||
/* If someone asks for help, that should be all we do */
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* check for request to report pid */
|
||||
if (NULL != orterun_globals.report_pid) {
|
||||
FILE *fp;
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user