From 1e80973f288a6285f73b4565e7c4fcee12713b72 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 23 Jul 2015 17:42:07 +0200 Subject: [PATCH] Ignore non-absolute $HOME when started from native process * uinfo.cc (cygheap_user::ontherange): Ignore $HOME if it's not starting with a slash (aka, absolute POSIX Path). Signed-off-by: Corinna Vinschen --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/release/2.2.0 | 3 +++ winsup/cygwin/uinfo.cc | 11 +++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 2d8475b14..55ea458f0 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-07-23 Corinna Vinschen + + * uinfo.cc (cygheap_user::ontherange): Ignore $HOME if it's not + starting with a slash (aka, absolute POSIX Path). + 2015-07-21 Corinna Vinschen * common.din (siglongjmp): Export. diff --git a/winsup/cygwin/release/2.2.0 b/winsup/cygwin/release/2.2.0 index 2fab1f64a..39df25c3d 100644 --- a/winsup/cygwin/release/2.2.0 +++ b/winsup/cygwin/release/2.2.0 @@ -11,6 +11,9 @@ What's new: What changed: ------------- +- When started from a non-Cygwin process, check if $HOME starts with a + slash (absolute POSIX path). Otherwise ignore it. + Bug Fixes --------- diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index bc5f814d0..334c2e988 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -331,8 +331,15 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw) char *p; if ((p = getenv ("HOME"))) - debug_printf ("HOME is already in the environment %s", p); - else + { + debug_printf ("HOME is already in the environment %s", p); + if (p[0] != '/') + { + p = NULL; + debug_printf ("discard HOME, no absolute POSIX path"); + } + } + if (!p) { if (pw && pw->pw_dir && *pw->pw_dir) {