]> git.saurik.com Git - cycript.git/commitdiff
Allow HOME in environment to override passwd file.
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 11 Oct 2014 22:29:26 +0000 (15:29 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Sat, 11 Oct 2014 22:29:26 +0000 (15:29 -0700)
Console.cpp

index 7a73c882bcf3bfe86af1249c7e79539ee13b03a1..f9637573b35c4a35a1fdba48d210df3b405f0b44 100644 (file)
@@ -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);