Обсуждение: Windows: openssl & gssapi dislike each other

Поиск
Список
Период
Сортировка

Windows: openssl & gssapi dislike each other

От
Dave Page
Дата:
I recently noticed that at least with PostgreSQL 16, it is not possible to build using MSVC if both OpenSSL and gssapi (MIT Kerberos) are enabled. Both work if the other isn't included though..

I briefly tried to test with PG17 to see if it has the same issue, but it seems like gssapi has the same problem I recently found with zlib (https://www.postgresql.org/message-id/CA%2BOCxozrPZx57ue8rmhq6CD1Jic5uqKh80%3DvTpZurSKESn-dkw%40mail.gmail.com).

I've yet to find time to look into this - reporting anyway rather than sitting on it until I get round to it...

Build FAILED.

"C:\Users\dpage\Downloads\postgresql-16.3\pgsql.sln" (default target) (1) ->
"C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj" (default target) (9) ->
(ClCompile target) ->
  C:\build64\openssl\include\openssl\x509v3.h(201,1): warning C4228: nonstandard extension used: qualifiers after comma in declarator list are ignored [C:\User
s\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): warning C4228: nonstandard extension used: qualifiers after comma in declarator list are ignored [C:\User
s\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): warning C4228: nonstandard extension used: qualifiers after comma in declarator list are ignored [C:\User
s\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\Users\dpage\Downloads\postgresql-16.3\src\backend\utils\sort\tuplesort.c(2000,1): warning C4724: potential mod by 0 [C:\Users\dpage\Downloads\postgresql-1
6.3\postgres.vcxproj]


"C:\Users\dpage\Downloads\postgresql-16.3\pgsql.sln" (default target) (1) ->
"C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj" (default target) (9) ->
(ClCompile target) ->
  C:\build64\openssl\include\openssl\x509v3.h(181,9): error C2059: syntax error: '(' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(188,9): error C2059: syntax error: '<parameter-list>' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(193,5): error C2059: syntax error: '}' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(194,1): error C2059: syntax error: '}' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(198,5): error C2061: syntax error: identifier 'GENERAL_NAME' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.v
cxproj]
  C:\build64\openssl\include\openssl\x509v3.h(199,1): error C2059: syntax error: '}' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(201,1): error C2143: syntax error: missing ')' before '*' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxp
roj]
  C:\build64\openssl\include\openssl\x509v3.h(201,1): error C2143: syntax error: missing '{' before '*' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxp
roj]
  C:\build64\openssl\include\openssl\x509v3.h(201,1): error C2143: syntax error: missing ';' before '*' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxp
roj]
  C:\build64\openssl\include\openssl\x509v3.h(201,1): error C2059: syntax error: ')' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(201,1): error C2373: 'a': redefinition; different type modifiers [C:\Users\dpage\Downloads\postgresql-16.3\postgr
es.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(201,1): error C2054: expected '(' to follow 'ptr' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(201,1): error C2146: syntax error: missing ')' before identifier 'cmp' [C:\Users\dpage\Downloads\postgresql-16.3\
postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(201,1): error C2061: syntax error: identifier 'cmp' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(201,1): error C2059: syntax error: ';' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(201,1): error C2449: found '{' at file scope (missing function header?) [C:\Users\dpage\Downloads\postgresql-16.3
\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(201,1): error C2059: syntax error: '}' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(201,1): error C2146: syntax error: missing ')' before identifier 'fr' [C:\Users\dpage\Downloads\postgresql-16.3\p
ostgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(201,1): error C2061: syntax error: identifier 'fr' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2236: unexpected token 'struct'. Did you forget a ';'? [C:\Users\dpage\Downloads\postgresql-16.3\p
ostgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2143: syntax error: missing ')' before '*' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxp
roj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2143: syntax error: missing '{' before '*' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxp
roj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2143: syntax error: missing ';' before '*' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxp
roj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2059: syntax error: ')' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2373: 'a': redefinition; different type modifiers [C:\Users\dpage\Downloads\postgresql-16.3\postgr
es.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2054: expected '(' to follow 'ptr' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2146: syntax error: missing ')' before identifier 'cmp' [C:\Users\dpage\Downloads\postgresql-16.3\
postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2061: syntax error: identifier 'cmp' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2059: syntax error: ';' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2449: found '{' at file scope (missing function header?) [C:\Users\dpage\Downloads\postgresql-16.3
\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2059: syntax error: '}' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2146: syntax error: missing ')' before identifier 'fr' [C:\Users\dpage\Downloads\postgresql-16.3\p
ostgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(227,1): error C2061: syntax error: identifier 'fr' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(295,5): error C2059: syntax error: '(' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(296,1): error C2059: syntax error: '}' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(313,5): error C2061: syntax error: identifier 'DIST_POINT_NAME' [C:\Users\dpage\Downloads\postgresql-16.3\postgre
s.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(317,1): error C2059: syntax error: '}' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(522,5): error C2061: syntax error: identifier 'GENERAL_NAME' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.v
cxproj]
  C:\build64\openssl\include\openssl\x509v3.h(525,1): error C2059: syntax error: '}' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C2143: syntax error: missing ')' before '*' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxp
roj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C2143: syntax error: missing '{' before '*' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxp
roj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C2143: syntax error: missing ';' before '*' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxp
roj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C2059: syntax error: ')' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C2373: 'a': redefinition; different type modifiers [C:\Users\dpage\Downloads\postgresql-16.3\postgr
es.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C2054: expected '(' to follow 'ptr' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C2146: syntax error: missing ')' before identifier 'cmp' [C:\Users\dpage\Downloads\postgresql-16.3\
postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C2061: syntax error: identifier 'cmp' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C2059: syntax error: ';' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C2449: found '{' at file scope (missing function header?) [C:\Users\dpage\Downloads\postgresql-16.3
\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C2059: syntax error: '}' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C2146: syntax error: missing ')' before identifier 'fr' [C:\Users\dpage\Downloads\postgresql-16.3\p
ostgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C2061: syntax error: identifier 'fr' [C:\Users\dpage\Downloads\postgresql-16.3\postgres.vcxproj]
  C:\build64\openssl\include\openssl\x509v3.h(527,1): error C1003: error count exceeds 100; stopping compilation [C:\Users\dpage\Downloads\postgresql-16.3\post
gres.vcxproj]

    4 Warning(s)
    53 Error(s)

Re: Windows: openssl & gssapi dislike each other

От
Imran Zaheer
Дата:
I was able to reproduce the gssapi & openssl error on windows. I tried
on PG16 with msvc build system and on PG17 with meson build system.
The error was reproducible when enabling both openssl and gssapi from
the configurations. Turns out that it was due to the conflicting
macros.


"be-secure-openssl.c" tries to prevent this conflict here [1]. But the
error again appears when gssapi is enabled. The file
"be-secure-openssl.c" fails to compile because it has a similar
scenario as explained here [2]. The header libpq.h is indirectly
including libpq-be.h which has a wrong order of including openssl
headers. Header "gssapi.h" indirectly includes "wincrypt.h" and
openssl header should be defined after gssapi includes.

Now this can either be solved by just just undefine the macro defined
by wincrypt.h as done here [3]
```
#ifdef X509_NAME
#undef X509_NAME
#endif
```

Or we should rearrange our headers. Openssl header should be at the
bottom (after the gssapi includes).


I am attaching the patch here in which I rearranged the openssl header
in libpq-be.h


[1]:
https://github.com/postgres/postgres/blob/8ba34c698d19450ccae9a5aea59a6d0bc8b75c0e/src/backend/libpq/be-secure-openssl.c#L46
[2]: https://github.com/openssl/openssl/issues/10307#issuecomment-964155382
[3]: https://github.com/postgres/postgres/blob/00ac25a3c365004821e819653c3307acd3294818/contrib/sslinfo/sslinfo.c#L29


Thanks
Imran Zaheer
Bitnine

Вложения

Re: Windows: openssl & gssapi dislike each other

От
Andrew Dunstan
Дата:
On 2024-06-08 Sa 06:22, Imran Zaheer wrote:
> I was able to reproduce the gssapi & openssl error on windows. I tried
> on PG16 with msvc build system and on PG17 with meson build system.
> The error was reproducible when enabling both openssl and gssapi from
> the configurations. Turns out that it was due to the conflicting
> macros.
>
>
> "be-secure-openssl.c" tries to prevent this conflict here [1]. But the
> error again appears when gssapi is enabled. The file
> "be-secure-openssl.c" fails to compile because it has a similar
> scenario as explained here [2]. The header libpq.h is indirectly
> including libpq-be.h which has a wrong order of including openssl
> headers. Header "gssapi.h" indirectly includes "wincrypt.h" and
> openssl header should be defined after gssapi includes.
>
> Now this can either be solved by just just undefine the macro defined
> by wincrypt.h as done here [3]
> ```
> #ifdef X509_NAME
> #undef X509_NAME
> #endif
> ```
>
> Or we should rearrange our headers. Openssl header should be at the
> bottom (after the gssapi includes).
>
>
> I am attaching the patch here in which I rearranged the openssl header
> in libpq-be.h
>
>
> [1]:
https://github.com/postgres/postgres/blob/8ba34c698d19450ccae9a5aea59a6d0bc8b75c0e/src/backend/libpq/be-secure-openssl.c#L46
> [2]: https://github.com/openssl/openssl/issues/10307#issuecomment-964155382
> [3]:
https://github.com/postgres/postgres/blob/00ac25a3c365004821e819653c3307acd3294818/contrib/sslinfo/sslinfo.c#L29
>
>

Let's be consistent and use the #undef from [3]. I did find the comment 
in sslinfo.c slightly confusing until I understood that this was a 
#define clashing with a typedef.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com




Re: Windows: openssl & gssapi dislike each other

От
Tom Lane
Дата:
Andrew Dunstan <andrew@dunslane.net> writes:
> On 2024-06-08 Sa 06:22, Imran Zaheer wrote:
>> Now this can either be solved by just just undefine the macro defined
>> by wincrypt.h as done here [3]
>> Or we should rearrange our headers. Openssl header should be at the
>> bottom (after the gssapi includes).

> Let's be consistent and use the #undef from [3].

+1.  Depending on header order is not great, especially when you have
to make it depend on an order that is directly contradictory to
project conventions [0].

            regards, tom lane

[0] https://wiki.postgresql.org/wiki/Committing_checklist#Policies



Re: Windows: openssl & gssapi dislike each other

От
Imran Zaheer
Дата:
Hi

I am submitting two new patches. We can undefine the macro at two locations

1). As be-secure-openssl.c [1] was the actual
file where the conflict happened so I undefined the macro here before
the ssl includes. I changed the comment a little to make it understandable.
I am also attaching the error generated with ninja build.

OR

2). Right after the gssapi includes in libpq-be.h


Thanks
Imran Zaheer
Bitnine

[1]:
https://github.com/postgres/postgres/blob/00ac25a3c365004821e819653c3307acd3294818/src/backend/libpq/be-secure-openssl.c#L46

On Sun, Jun 9, 2024 at 7:21 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Andrew Dunstan <andrew@dunslane.net> writes:
> > On 2024-06-08 Sa 06:22, Imran Zaheer wrote:
> >> Now this can either be solved by just just undefine the macro defined
> >> by wincrypt.h as done here [3]
> >> Or we should rearrange our headers. Openssl header should be at the
> >> bottom (after the gssapi includes).
>
> > Let's be consistent and use the #undef from [3].
>
> +1.  Depending on header order is not great, especially when you have
> to make it depend on an order that is directly contradictory to
> project conventions [0].
>
>                         regards, tom lane
>
> [0] https://wiki.postgresql.org/wiki/Committing_checklist#Policies

Вложения

Re: Windows: openssl & gssapi dislike each other

От
Dave Page
Дата:
Hi

On Sun, 9 Jun 2024 at 08:29, Imran Zaheer <imran.zhir@gmail.com> wrote:
Hi

I am submitting two new patches. We can undefine the macro at two locations

1). As be-secure-openssl.c [1] was the actual
file where the conflict happened so I undefined the macro here before
the ssl includes. I changed the comment a little to make it understandable.
I am also attaching the error generated with ninja build.

OR

2). Right after the gssapi includes in libpq-be.h

Thank you for working on this. I can confirm the undef version compiles and passes tests with 16.3.
 
--

Re: Windows: openssl & gssapi dislike each other

От
Andrew Dunstan
Дата:


On 2024-06-11 Tu 05:19, Dave Page wrote:
Hi

On Sun, 9 Jun 2024 at 08:29, Imran Zaheer <imran.zhir@gmail.com> wrote:
Hi

I am submitting two new patches. We can undefine the macro at two locations

1). As be-secure-openssl.c [1] was the actual
file where the conflict happened so I undefined the macro here before
the ssl includes. I changed the comment a little to make it understandable.
I am also attaching the error generated with ninja build.

OR

2). Right after the gssapi includes in libpq-be.h

Thank you for working on this. I can confirm the undef version compiles and passes tests with 16.3.
 


Thanks for testing.

I think I prefer approach 2, which should also allow us to remove the #undef in sslinfo.c so we only need to do this in one place.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

Re: Windows: openssl & gssapi dislike each other

От
Dave Page
Дата:


On Tue, 11 Jun 2024 at 12:22, Andrew Dunstan <andrew@dunslane.net> wrote:


On 2024-06-11 Tu 05:19, Dave Page wrote:
Hi

On Sun, 9 Jun 2024 at 08:29, Imran Zaheer <imran.zhir@gmail.com> wrote:
Hi

I am submitting two new patches. We can undefine the macro at two locations

1). As be-secure-openssl.c [1] was the actual
file where the conflict happened so I undefined the macro here before
the ssl includes. I changed the comment a little to make it understandable.
I am also attaching the error generated with ninja build.

OR

2). Right after the gssapi includes in libpq-be.h

Thank you for working on this. I can confirm the undef version compiles and passes tests with 16.3.
 


Thanks for testing.

I think I prefer approach 2, which should also allow us to remove the #undef in sslinfo.c so we only need to do this in one place.

OK, well that version compiles and passes tests as well :-)

Thanks! 

--

Re: Windows: openssl & gssapi dislike each other

От
Imran Zaheer
Дата:
Hi

I removed the macro from the sslinfo.c as suggested by Andrew. Then I
was thinking maybe we can undo some other similar code.

I rearranged the headers to their previous position in
be-secure-openssl.c and in fe-secure-openssl.c. I was able to compile
with gssapi and openssl enabled. You can look into the original commits. [1,
2]
Is it ok if we undo the changes from these commits?

I am attaching two new patches.
One with macro guards removed from ssinfo.c.
Second patch will additionally rearrange headers for
be-secure-openssl.c and in fe-secure-openssl.c to their previous
position.

Thanks
Imran Zaheer
Bitnine

[1]: https://github.com/postgres/postgres/commit/1241fcbd7e649414f09f9858ba73e63975dcff64
[2]: https://github.com/postgres/postgres/commit/568620dfd6912351b4127435eca5309f823abde8

On Wed, Jun 12, 2024 at 12:34 AM Dave Page <dpage@pgadmin.org> wrote:
>
>
>
> On Tue, 11 Jun 2024 at 12:22, Andrew Dunstan <andrew@dunslane.net> wrote:
>>
>>
>> On 2024-06-11 Tu 05:19, Dave Page wrote:
>>
>> Hi
>>
>> On Sun, 9 Jun 2024 at 08:29, Imran Zaheer <imran.zhir@gmail.com> wrote:
>>>
>>> Hi
>>>
>>> I am submitting two new patches. We can undefine the macro at two locations
>>>
>>> 1). As be-secure-openssl.c [1] was the actual
>>> file where the conflict happened so I undefined the macro here before
>>> the ssl includes. I changed the comment a little to make it understandable.
>>> I am also attaching the error generated with ninja build.
>>>
>>> OR
>>>
>>> 2). Right after the gssapi includes in libpq-be.h
>>
>>
>> Thank you for working on this. I can confirm the undef version compiles and passes tests with 16.3.
>>
>>
>>
>> Thanks for testing.
>>
>> I think I prefer approach 2, which should also allow us to remove the #undef in sslinfo.c so we only need to do this
inone place. 
>
> OK, well that version compiles and passes tests as well :-)
>
> Thanks!
>
> --
> Dave Page
> pgAdmin: https://www.pgadmin.org
> PostgreSQL: https://www.postgresql.org
> EDB: https://www.enterprisedb.com
>

Вложения