--- /dev/null
+---
+title: "Réparation d’Adminer"
+category: Fix
+tags: [BDD]
+date: 2020-06-13
+---
+Depuis la mise à jour de NixOS à 19.09, Adminer (et plus généralement
+php) n’était plus capable de se connecter à mysql avec le mécanisme PAM.
+L’extension mysqli a été patchée pour permettre une telle utilisation,
+permettant d’utiliser à nouveau Adminer comme client.
-{ adminer, php74, forcePhpSocket ? null }:
+{ adminer, php74, php74base, myPhpPackages, lib, forcePhpSocket ? null }:
rec {
activationScript = {
deps = [ "httpd" ];
phpFpm = rec {
user = apache.user;
group = apache.group;
- phpPackage = php74;
+ phpPackage = php74base.withExtensions (e: (lib.remove e.mysqli php74.enabledExtensions) ++ [myPhpPackages.mysqli_pam]);
settings = {
"listen.owner" = apache.user;
"listen.group" = apache.group;
mariadb_pam = super.mariadb.overrideAttrs(old: {
cmakeFlags = old.cmakeFlags ++ [ "-DWITH_AUTHENTICATION_PAM=ON" ];
buildInputs = old.buildInputs ++ [ self.pam ];
+ outputs = old.outputs ++ [ "dev" ];
+ postInstall = ''
+ mkdir -p $dev $dev/lib $dev/share
+ cp -a $out/include $dev
+ cp -a $out/lib/{libmariadbclient.a,libmysqlclient.a,libmysqlclient_r.a,libmysqlservices.a} $dev/lib
+ cp -a $out/lib/pkgconfig $dev/lib
+ cp -a $out/share/aclocal $dev/share
+ '' + old.postInstall;
+ });
+ # This patched version includes C headers from the server part (see
+ # above). It seems to be required to build pam support in clients.
+ libmysqlclient_pam = super.libmysqlclient.overrideAttrs(old: {
+ prePatch = old.prePatch or "" + ''
+ sed -i -e '/define INCLUDE/s|"$| -I@CMAKE_SYSROOT@@CMAKE_INSTALL_PREFIX@/@INSTALL_INCLUDEDIR@/mysql/server -I@CMAKE_SYSROOT@@CMAKE_INSTALL_PREFIX@/@INSTALL_INCLUDEDIR@/mysql/server/private"|' mariadb_config/mariadb_config.c.in
+ '';
+ postInstall = old.postInstall or "" + ''
+ cp -a ${mariadb_pam.dev}/include/* $out/include/mariadb
+ '';
});
}
nixops = import ./nixops;
pass = import ./pass;
pelican = import ./pelican;
+ php-packages = import ./php-packages;
postfix = import ./postfix;
postgresql = import ./databases/postgresql;
sc-im = import ./sc-im;
--- /dev/null
+self: super: rec {
+ myPhpPackages.mysqli_pam = self.php74.extensions.mysqli.overrideAttrs(old: {
+ configureFlags = [ "--with-mysqli=${self.libmysqlclient_pam}/bin/mysql_config" "--with-mysql-sock=/run/mysqld/mysqld.sock" ];
+ patches = old.patches or [] ++ [ ./mysqli_patch.patch ];
+});
+}
--- /dev/null
+--- a/mysqli_nonapi.c
++++ b/mysqli_nonapi.c
+@@ -263,7 +263,7 @@ void mysqli_common_connect(INTERNAL_FUNC
+ php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql));
+
+ #if !defined(MYSQLI_USE_MYSQLND)
+- mysql->mysql->reconnect = MyG(reconnect);
++ mysql_options(mysql->mysql, MYSQL_OPT_RECONNECT, (my_bool *)&MyG(reconnect));
+ #endif
+
+ mysql_options(mysql->mysql, MYSQL_OPT_LOCAL_INFILE, (char *)&MyG(allow_local_infile));