From 1210260f62cc729d052cd3c4d66c3e98812c1d88 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 11 Oct 2014 15:29:26 -0700 Subject: [PATCH] Allow HOME in environment to override passwd file. --- Console.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Console.cpp b/Console.cpp index 7a73c88..f963757 100644 --- a/Console.cpp +++ b/Console.cpp @@ -418,15 +418,18 @@ class History { }; static void Console(CYOptions &options) { - CYPool pool; - - passwd *passwd; - if (const char *username = getenv("LOGNAME")) - passwd = getpwnam(username); - else - passwd = getpwuid(getuid()); + std::string basedir; + if (const char *home = getenv("HOME")) + basedir = home; + else { + passwd *passwd; + if (const char *username = getenv("LOGNAME")) + passwd = getpwnam(username); + else + passwd = getpwuid(getuid()); + basedir = passwd->pw_dir; + } - std::string basedir(passwd->pw_dir); basedir += "/.cycript"; mkdir(basedir.c_str(), 0700); -- 2.50.0