summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/path.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/common/path.c b/common/path.c
index f7bd2b9..3c714d5 100644
--- a/common/path.c
+++ b/common/path.c
@@ -131,11 +131,18 @@ expand_homedir (const char *remainder)
} else {
#ifdef OS_UNIX
+ char buf[1024];
+ struct passwd pws;
struct passwd *pwd;
int error = 0;
+ int ret;
- pwd = getpwuid (getuid ());
- if (!pwd) {
+ ret = getpwuid_r (getuid (), &pws, buf, sizeof (buf), &pwd);
+ if (ret == 0 && !pwd) {
+ ret = -1;
+ errno = ESRCH;
+ }
+ if (ret < 0) {
error = errno;
p11_message_err (errno, "couldn't lookup home directory for user %d", getuid ());
errno = error;