Skip to content

Commit

Permalink
Add env var: OMPI_ALLOW_RUN_AS_ROOT
Browse files Browse the repository at this point in the history
Adds a new recognized environment variable
`OMPI_ALLOW_RUN_AS_ROOT` that can be set alternatively to
passing `--allow-run-as-root` to orte.

Implements proposal in
open-mpi#4451

Alternative solutions are very welcome!
  • Loading branch information
ax3l committed May 31, 2018
1 parent 04b509b commit 0cb8fc4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion orte/orted/orted_submit.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ int orte_submit_init(int argc, char *argv[],
* us to proceed if the allow-run-as-root flag was given. Otherwise,
* exit with a giant warning flag
*/
if (0 == geteuid() && !orte_cmd_options.run_as_root) {
if (0 == geteuid() && !orte_cmd_options.run_as_root && getenv("OMPI_ALLOW_RUN_AS_ROOT") == NULL) {
/* show_help is not yet available, so print an error manually */
fprintf(stderr, "--------------------------------------------------------------------------\n");
if (orte_cmd_options.help) {
Expand Down
2 changes: 1 addition & 1 deletion orte/tools/orte-dvm/orte-dvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ int main(int argc, char *argv[])
* us to proceed if the allow-run-as-root flag was given. Otherwise,
* exit with a giant warning flag
*/
if (0 == geteuid() && !myglobals.run_as_root) {
if (0 == geteuid() && !myglobals.run_as_root && getenv("OMPI_ALLOW_RUN_AS_ROOT") == NULL) {
/* show_help is not yet available, so print an error manually */
fprintf(stderr, "--------------------------------------------------------------------------\n");
if (myglobals.help) {
Expand Down
2 changes: 1 addition & 1 deletion orte/tools/orterun/orterun.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ int orterun(int argc, char *argv[])
* us to proceed if the allow-run-as-root flag was given. Otherwise,
* exit with a giant warning flag
*/
if (0 == geteuid() && !orte_cmd_options.run_as_root) {
if (0 == geteuid() && !orte_cmd_options.run_as_root && getenv("OMPI_ALLOW_RUN_AS_ROOT") == NULL) {
fprintf(stderr, "--------------------------------------------------------------------------\n");
if (NULL != orte_cmd_options.help) {
fprintf(stderr, "%s cannot provide the help message when run as root.\n", orte_basename);
Expand Down
2 changes: 1 addition & 1 deletion orte/tools/prun/prun.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ int prun(int argc, char *argv[])
* us to proceed if the allow-run-as-root flag was given. Otherwise,
* exit with a giant warning flag
*/
if (0 == geteuid() && !orte_cmd_options.run_as_root) {
if (0 == geteuid() && !orte_cmd_options.run_as_root && getenv("OMPI_ALLOW_RUN_AS_ROOT") == NULL) {
/* show_help is not yet available, so print an error manually */
fprintf(stderr, "--------------------------------------------------------------------------\n");
if (orte_cmd_options.help) {
Expand Down

0 comments on commit 0cb8fc4

Please sign in to comment.