BUG #16775: Problem building with Kerberos (--with-gssapi) support on Windows - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16775: Problem building with Kerberos (--with-gssapi) support on Windows
Date
Msg-id 16775-aae444d3bb6f41e1@postgresql.org
Whole thread Raw
Responses Re: BUG #16775: Problem building with Kerberos (--with-gssapi) support on Windows
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16775
Logged by:          Uwe Benner
Email address:      uwe.benner@posteo.de
PostgreSQL version: 12.5
Operating system:   Windows 10
Description:

Hello there!

I am building postgres from source on Windows, because I need a 32bit
version, and wanted to have kerberos support a.k.a. `--with-gssapi`
activated.
When compiling, it complains about the line 493 in file
src/backend/be-secure-gssapi.c [0]
```
 493         setenv("KRB5_KTNAME", pg_krb_server_keyfile, 1);
 ```
 which seams reasonable, since it seams to be the linux api call. Is it
supposed to be the linux api or does postgres itself define a setenv
function somewhere else?
 Is it okay to fix it like this?
 ```
 #ifndef WIN32
  setenv("KRB5_KTNAME", pg_krb_server_keyfile, 1);
#else
  SetEnvironmentVariable("KRB5_KTNAME", pg_krb_server_keyfile);
#endif
```

Or should `pg_setenv`[1] or something like tat be called instead? `putenv`
would be another, more or less cross platform safe option, but it's
deprecated[2] in Windows and `_putenv`/`_putenv_s` should be used instead.

And another thing, can you check if the call to `SetEnvironmentVariableA` in
the function `pg_setenv`[1] is right? I think it's a typo and should call
`SetEnvironmentVariable`.

Thanks in advance
Uwe Benner

[0]

https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/libpq/be-secure-gssapi.c;h=5a73302b7b9ea65dc8a3d57d232d473ef54ce2c1;hb=HEAD#l493
[1]

https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/bin/pg_upgrade/util.c;h=a16c794261b598326253f2665eaea9039724ac45;hb=HEAD#l246
[2]
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv?view=msvc-160


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #16774: PostgreSQL clean build MINGW64 gcc but initdb fails, cannot find startadress CreateProcessAsUserA
Next
From: Tom Lane
Date:
Subject: Re: BUG #16775: Problem building with Kerberos (--with-gssapi) support on Windows