diff --git a/orte/mca/pls/tm/pls_tm_module.c b/orte/mca/pls/tm/pls_tm_module.c index 1dc674e651..2b886d4869 100644 --- a/orte/mca/pls/tm/pls_tm_module.c +++ b/orte/mca/pls/tm/pls_tm_module.c @@ -35,6 +35,9 @@ #ifdef HAVE_SYS_TYPES_H #include #endif +#ifdef HAVE_SYS_STAT_H +#include +#endif #ifdef HAVE_SYS_WAIT_H #include #endif @@ -139,6 +142,7 @@ static int pls_tm_launch_job(orte_jobid_t jobid) int maxtime=0, mintime=99999999, maxiter = 0, miniter = 0, deltat; float avgtime=0.0; bool failed_launch = true; + mode_t current_umask; /* check for timing request - get start time if so */ if (mca_pls_tm_component.timing) { @@ -236,6 +240,12 @@ static int pls_tm_launch_job(orte_jobid_t jobid) * won't work on remote nodes */ orte_pls_base_purge_mca_params(&env); + + /* add our umask -- see big note in orted.c */ + current_umask = umask(0); + umask(current_umask); + asprintf(&var, "0%o", current_umask); + opal_setenv("ORTE_DAEMON_UMASK_VALUE", var, true, &env); /* If we have a prefix, then modify the PATH and LD_LIBRARY_PATH environment variables. We only allow diff --git a/orte/tools/orted/orted.c b/orte/tools/orted/orted.c index d604a72946..421ccce7ee 100644 --- a/orte/tools/orted/orted.c +++ b/orte/tools/orted/orted.c @@ -19,9 +19,44 @@ * $HEADER$ */ +#include "orte_config.h" + +#include +#ifdef HAVE_LIMITS_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#include + #include "orte/orted/orted.h" int main(int argc, char *argv[]) { + /* Allow the PLS starters to pass us a umask to use, if required. + Most starters by default can do something sane with the umask, + but some (like TM) do not pass on the umask but instead inherit + it form the root level process starter. This has to happen + before opal_init and everything else so that the couple of + places that stash a umask end up with the correct value. Only + do it here (and not in orte_daemon) mainly to make it clear + that this should only happen when starting an orted for the + first time. All startes I'm aware of that don't require an + orted are smart enough to pass on a reasonable umask, so they + wouldn't need this functionality anyway. */ + char *umask_str = getenv("ORTE_DAEMON_UMASK_VALUE"); + if (NULL != umask_str) { + char *endptr; + long mask = strtol(umask_str, &endptr, 8); + if ((! (0 == mask && (EINVAL == errno || ERANGE))) && + (*endptr == '\0')) { + umask(mask); + } + } + return orte_daemon(argc, argv); }