mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
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
This commit is contained in:
parent
d09a9be4da
commit
e69958cfe9
@ -229,16 +229,19 @@ find_root_dir_default() {
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // The Linux case
|
#else // The Linux/*BSD case
|
||||||
// e.g., /home/<username>/.panda3d
|
// e.g., /home/<username>/.panda3d
|
||||||
|
|
||||||
string root;
|
string root;
|
||||||
const char *uname = getlogin();
|
const passwd *pwdata = getpwuid(getuid());
|
||||||
if (uname == NULL) uname = getenv("USER");
|
|
||||||
|
|
||||||
const passwd *pwdata = getpwnam(uname);
|
|
||||||
if (pwdata == NULL) {
|
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 {
|
} else {
|
||||||
root = pwdata->pw_dir;
|
root = pwdata->pw_dir;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user