This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch]: env -i


Before:
~: env -i /bin/env
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\Owner
LOGONSERVER=\\COMPAQ
SYSTEMDRIVE=C:
SYSTEMROOT=C:\WINDOWS
USERDOMAIN=COMPAQ
USERNAME=Owner
USERPROFILE=C:\Documents and Settings\Owner

After:
~: env -i /bin/env
~: 
(but the variables are present with telnet, ssh, etc..)

Pierre

2004-05-08  Pierre Humblet <pierre.humblet@ieee.org>

	* environ.cc (build_env): Only try to construct required-but-missing
	variables while issetuid.



Index: environ.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/environ.cc,v
retrieving revision 1.98
diff -u -p -r1.98 environ.cc
--- environ.cc  8 May 2004 02:55:38 -0000       1.98
+++ environ.cc  8 May 2004 18:34:53 -0000
@@ -910,17 +910,18 @@ build_env (const char * const *envp, cha
 
   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 */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]