summaryrefslogtreecommitdiff
path: root/Src/init.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-02-06 11:57:03 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-02-06 11:57:03 +0000
commit8b0cc8781764e0d1b203423033fab71774e40016 (patch)
tree0018ea9e0d2ad1308e1d384fdba3e5859dc99ed2 /Src/init.c
parent800c270d4d75aaa668da906383ae6b41f952f6f5 (diff)
downloadzsh-8b0cc8781764e0d1b203423033fab71774e40016.tar.gz
zsh-8b0cc8781764e0d1b203423033fab71774e40016.zip
22195: don't set HOME in the shell
Diffstat (limited to 'Src/init.c')
-rw-r--r--Src/init.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/Src/init.c b/Src/init.c
index 6751df6ba..adb6eb84a 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -795,22 +795,23 @@ setupvals(void)
* recheck the info for `USERNAME' */
cached_uid = getuid();
- /* Get password entry and set info for `HOME' and `USERNAME' */
+ /* Get password entry and set info for `USERNAME' */
#ifdef HAVE_GETPWUID
if ((pswd = getpwuid(cached_uid))) {
- home = metafy(pswd->pw_dir, -1, META_DUP);
cached_username = ztrdup(pswd->pw_name);
} else
#endif /* HAVE_GETPWUID */
{
- home = ztrdup("/");
cached_username = ztrdup("");
}
- /* Try a cheap test to see if we can *
- * initialize `PWD' from `HOME' */
- if (ispwd(home))
- pwd = ztrdup(home);
+ /*
+ * Try a cheap test to see if we can initialize `PWD' from `HOME'.
+ * HOME must come from the environment; we're not allowed to
+ * set it locally.
+ */
+ if ((ptr = getenv("HOME")) && ispwd(ptr))
+ pwd = ztrdup(ptr);
else if ((ptr = zgetenv("PWD")) && (strlen(ptr) < PATH_MAX) &&
(ptr = metafy(ptr, -1, META_STATIC), ispwd(ptr)))
pwd = ztrdup(ptr);
@@ -1105,8 +1106,11 @@ sourcehome(char *s)
queue_signals();
if (emulation == EMULATE_SH || emulation == EMULATE_KSH ||
- !(h = getsparam("ZDOTDIR")))
+ !(h = getsparam("ZDOTDIR"))) {
h = home;
+ if (!h)
+ return;
+ }
{
/* Let source() complain if path is too long */