Fixed determining the user's homedir: If $HOME and the /etc/passwd entry for the current user contradict each other, now $HOME takes preference over /etc/passwd.
This commit is contained in:
parent
e27d63f908
commit
2793e014d4
|
@ -2,6 +2,7 @@ Version 0.10.3 (unreleased)
|
||||||
---------------
|
---------------
|
||||||
Fixed bugs:
|
Fixed bugs:
|
||||||
* A comma in the base directory name would make the file system fail to mount, https://github.com/cryfs/cryfs/issues/326
|
* A comma in the base directory name would make the file system fail to mount, https://github.com/cryfs/cryfs/issues/326
|
||||||
|
* Fixed determining the user's homedir: If $HOME and the /etc/passwd entry for the current user contradict each other, now $HOME takes preference over /etc/passwd.
|
||||||
|
|
||||||
Version 0.10.2
|
Version 0.10.2
|
||||||
---------------
|
---------------
|
||||||
|
|
|
@ -9,13 +9,13 @@ using std::string;
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
namespace {
|
namespace {
|
||||||
bf::path _get_home_directory() {
|
bf::path _get_home_directory() {
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
string homedir = getenv("HOME");
|
||||||
string homedir;
|
if (homedir == "") {
|
||||||
if (pwd) {
|
// try the /etc/passwd entry
|
||||||
homedir = pwd->pw_dir;
|
struct passwd* pwd = getpwuid(getuid());
|
||||||
} else {
|
if (pwd) {
|
||||||
// try the $HOME environment variable
|
homedir = pwd->pw_dir;
|
||||||
homedir = getenv("HOME");
|
}
|
||||||
}
|
}
|
||||||
if (homedir == "") {
|
if (homedir == "") {
|
||||||
throw std::runtime_error("Couldn't determine home directory for user");
|
throw std::runtime_error("Couldn't determine home directory for user");
|
||||||
|
|
Loading…
Reference in New Issue