From 94f29ccdf6f99197d2de941e5411a9d5b6c787d6 Mon Sep 17 00:00:00 2001 From: Pierre Humblet Date: Sun, 9 May 2004 15:17:15 +0000 Subject: [PATCH] 2004-05-09 Pierre Humblet * environ.cc (build_env): Only try to construct required-but-missing variables while issetuid. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/environ.cc | 23 ++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 325c01f56..02e0c05df 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2004-05-09 Pierre Humblet + + * environ.cc (build_env): Only try to construct required-but-missing + variables while issetuid. + 2004-05-08 Pierre Humblet Christopher Faylor diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 749d8139f..be4b88408 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -910,17 +910,18 @@ build_env (const char * const *envp, char *&envblock, int &envc, assert ((srcp - envp) == n); /* Fill in any required-but-missing environment variables. */ - for (unsigned i = 0; i < SPENVS_SIZE; i++) - if (!saw_spenv[i]) - { - *dstp = spenvs[i].retrieve (no_envblock); - if (*dstp && !no_envblock && *dstp != env_dontadd) - { - tl += strlen (*dstp) + 1; - dstp++; - } - } - + if (cygheap->user.issetuid ()) + for (unsigned i = 0; i < SPENVS_SIZE; i++) + if (!saw_spenv[i]) + { + *dstp = spenvs[i].retrieve (no_envblock); + if (*dstp && !no_envblock && *dstp != env_dontadd) + { + tl += strlen (*dstp) + 1; + dstp++; + } + } + envc = dstp - newenv; /* Number of entries in newenv */ assert ((size_t) envc <= (n + SPENVS_SIZE)); *dstp = NULL; /* Terminate */