Skip to content

Commit 3aa20d8

Browse files
committed
Switch back to using $USER to get username
1 parent c14df9c commit 3aa20d8

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

libs/common/src/System_Other.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
// along with Return To The Roots. If not, see <http://www.gnu.org/licenses/>.
1717

1818
#include "System.h"
19-
#include <pwd.h>
20-
#include <unistd.h>
19+
#include <stdexcept>
2120

2221
boost::filesystem::path System::getHomePath()
2322
{
@@ -33,7 +32,8 @@ boost::filesystem::path System::getHomePath()
3332

3433
std::string System::getUserName()
3534
{
36-
const auto uid = geteuid();
37-
const auto* pw = getpwuid(uid);
38-
return pw ? pw->pw_name : "";
35+
const std::string name = getEnvVar("USER");
36+
if(name.empty())
37+
throw std::runtime_error("Could not get username");
38+
return name;
3939
}

0 commit comments

Comments
 (0)