From: Gilles DAVID Date: Thu, 30 Mar 2023 17:13:55 +0000 (+0200) Subject: USER or LOGNAME is not defined in a Docker container: on Linux get username with... X-Git-Tag: emc2p_1.3.7-rc1^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a90309e7a72b9642316eda15e8f422772ad2971f;p=modules%2Fkernel.git USER or LOGNAME is not defined in a Docker container: on Linux get username with getpwuid(getuid()) --- diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index e878a7404..b72495818 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -37,6 +37,7 @@ #include #else static const char SEPARATOR = '/'; +#include #endif Launcher::Job::Job() @@ -191,7 +192,12 @@ Launcher::Job::setResourceDefinition(const ParserResourcesType & resource_defini if (resource_definition.UserName == "") { #ifndef WIN32 - user_name = getenv("USER"); + struct passwd *pwd = getpwuid(getuid()); + if (pwd) { + user_name = std::string(pwd->pw_name); + } + if (user_name == "") + user_name = getenv("USER"); #else user_name = getenv("USERNAME"); #endif