[krbdev.mit.edu #2636] replace all calls to getenv()/setenv() with Get/SetEnvironmentVariable on Windows

Nicolas Williams via RT rt-comment at krbdev.mit.edu
Wed Jul 14 16:30:07 EDT 2004


On Wed, Jul 14, 2004 at 04:11:01PM -0400, Jeffrey Altman [Kermit Project] via RT wrote:
> 
> Ken Raeburn wrote:
> 
> > On the plus side, that'll likely be a thread-safe interface, compared 
> > with the UNIX one (if setenv is used).  Perhaps we should modify our 
> > uses of getenv to call a helper function which returns us a string in 
> > allocated storage; then that helper function could use either getenv 
> > or GetEnvironmentVariable, and in the getenv case, while it still 
> > wouldn't be thread-safe, it would reduce the window of exposure somewhat.

Yes.

> > Ken
> 
> A mutex could be placed in the helper function to ensure that at most 
> one krb5 library call is accessing the environment variables
> we care about at a time.

The krb5 library doesn't use setenv()/putenv() and I think it's safe to
assume that getenv() is always safe with respect to other concurrent
calls to getenv(), so the krb5 lib should not worry about getenv()'s
thread-safety (there's nothing it could w.r.t. other threads that do a
setenv() outside the context of krb5).

Nico
-- 


More information about the krb5-bugs mailing list