From: Ovidiu Mircescu Date: Fri, 14 Apr 2023 09:03:22 +0000 (+0200) Subject: USER or LOGNAME is not defined in a Docker container: on Linux get username with... X-Git-Tag: V9_11_0a1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5663bb50500d4e91c2e437ea43ca6551cdbb8681;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