Bug 1536881

Summary: FTBFS with libxcrypt
Product: [Fedora] Fedora Reporter: Michal Schorm <mschorm>
Component: community-mysqlAssignee: Michal Schorm <mschorm>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: high    
Version: rawhideCC: besser82, fweimer, hhorak, jstanek, mschorm
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-01-22 15:32:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1534789, 1535520    
Attachments:
Description Flags
patch 1 none

Description Michal Schorm 2018-01-21 22:24:54 UTC
FTBFS

/builddir/build/BUILD/mysql-5.7.21/sql/item_strfunc.cc:2276:14: error: 'crypt' was not declared in this scope
   char *tmp= crypt(res->c_ptr_safe(),salt_ptr);
              ^~~~~

---

Cause:
  https://fedoraproject.org/wiki/Changes/Replace_glibc_libcrypt_with_libxcrypt

---

Build Logs to examine:
  https://koji.fedoraproject.org/koji/taskinfo?taskID=24346348
  https://koji.fedoraproject.org/koji/taskinfo?taskID=24330771

Comment 1 Michal Schorm 2018-01-21 22:29:01 UTC
Is that expected?
  (Is the function known for not being provided by libxcrypt header files?)

What's the suggested process?

Comment 2 Björn Esser (besser82) 2018-01-21 23:01:34 UTC
(In reply to Michal Schorm from comment #1)
> Is that expected?
>   (Is the function known for not being provided by libxcrypt header files?)
> 
> What's the suggested process?

Well, no…  It is the `crypt()` function well supported by libxcrypt.  All files using this function should not make the blind assumption it will be declared in <unistd.h>. One can only rely on having it declared in that header file, if `_XOPEN_CRYPT` is defined *after* including it…

Putting this in the affected file after importing all other header files will fix that particular problem:

#if defined(__GLIBC__) && !defined(_XOPEN_CRYPT)
#include <crypt.h>
#endif

Do you want to provide a patch and upstream it, or shall I provide an upstreamable one?

Comment 3 Björn Esser (besser82) 2018-01-21 23:04:00 UTC
Another option would be to have CMake check for `crypt.h` being present and define a macro like `HAVE_CRYPT_H`; then add this in the affected files:

#ifdef HAVE_CRYPT_H
#include <crypt.h>
#endif

Comment 4 Michal Schorm 2018-01-22 01:09:02 UTC
You also rebuilt MariaDB, but no problem was there. So I checked, how MariaDB does it.

It uses:

 mariadb-10.2.12/libmariadb/cmake/CheckIncludeFiles.cmake
   CHECK_INCLUDE_FILES (crypt.h HAVE_CRYPT_H)

 mariadb-10.2.12/include/my_global.h:
   #if defined(HAVE_CRYPT_H)
   #include <crypt.h>
   #endif

So they check the crypt.h library file directly.

---

MySQL uses the same system, so I'd stick to it and use the "CHECK_INCLUDE_FILES" cmake function.

Comment 5 Michal Schorm 2018-01-22 01:10:27 UTC
Created attachment 1384165 [details]
patch 1

Looking at MariaDB, I think this patch should get the stuff done.

Comment 6 Michal Schorm 2018-01-22 01:12:19 UTC
Do you agree?

Comment 7 Michal Schorm 2018-01-22 01:48:44 UTC
Test build with the patch:
  https://koji.fedoraproject.org/koji/taskinfo?taskID=24358755

Comment 8 Björn Esser (besser82) 2018-01-22 05:17:54 UTC
(In reply to Michal Schorm from comment #6)
> Do you agree?

LGTM.  =)

Comment 9 Michal Schorm 2018-01-22 15:32:07 UTC
Very well then.

Built:
https://koji.fedoraproject.org/koji/taskinfo?taskID=24369733