We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c14df9c commit 3aa20d8Copy full SHA for 3aa20d8
1 file changed
libs/common/src/System_Other.cpp
@@ -16,8 +16,7 @@
16
// along with Return To The Roots. If not, see <http://www.gnu.org/licenses/>.
17
18
#include "System.h"
19
-#include <pwd.h>
20
-#include <unistd.h>
+#include <stdexcept>
21
22
boost::filesystem::path System::getHomePath()
23
{
@@ -33,7 +32,8 @@ boost::filesystem::path System::getHomePath()
33
32
34
std::string System::getUserName()
35
36
- const auto uid = geteuid();
37
- const auto* pw = getpwuid(uid);
38
- return pw ? pw->pw_name : "";
+ const std::string name = getEnvVar("USER");
+ if(name.empty())
+ throw std::runtime_error("Could not get username");
+ return name;
39
}
0 commit comments