From e69958cfe93129ba32a64aafac86dd10ed06aa0f Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 26 Oct 2010 16:40:42 +0000 Subject: [PATCH] Fix segmentation fault that only seems to happen in the buildbot's master shell environment. But I suppose the crash could manifest in other environments where getlogin() fails --- direct/src/plugin/find_root_dir.cxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/direct/src/plugin/find_root_dir.cxx b/direct/src/plugin/find_root_dir.cxx index 3d661152a6..0f9ad070ca 100755 --- a/direct/src/plugin/find_root_dir.cxx +++ b/direct/src/plugin/find_root_dir.cxx @@ -229,16 +229,19 @@ find_root_dir_default() { return root; } -#else // The Linux case +#else // The Linux/*BSD case // e.g., /home//.panda3d string root; - const char *uname = getlogin(); - if (uname == NULL) uname = getenv("USER"); - - const passwd *pwdata = getpwnam(uname); + const passwd *pwdata = getpwuid(getuid()); if (pwdata == NULL) { - root = getenv("HOME"); + char *home = getenv("HOME"); + if (home == NULL) { + // Beh. Let's hope it never gets to this point. + return "."; + } else { + root = home; + } } else { root = pwdata->pw_dir; }