+ struct passwd *pw;
+
+ /*
+ * To distinguish between the error case and the "not found" case we
+ * have to check errno after getpwuid(3). The manual page recommends to
+ * set it to zero before the call.
+ */
+ errno = 0;
+ pw = getpwuid(getuid());
+ if (pw)
+ return para_strdup(pw->pw_dir);
+ if (errno != 0)
+ PARA_EMERG_LOG("getpwuid error: %s\n", strerror(errno));
+ else
+ PARA_EMERG_LOG("no pw entry for uid %u\n", (unsigned)getuid());
+ exit(EXIT_FAILURE);