git: 1709b49e199d - main - net/libnss-mysql: unbreak build with mysql80/maria105+ (+)

From: Dima Panov <fluffy_at_FreeBSD.org>
Date: Wed, 01 Feb 2023 12:08:34 UTC
The branch main has been updated by fluffy:

URL: https://cgit.FreeBSD.org/ports/commit/?id=1709b49e199d5ca6c4059585ff56668649e6c0ef

commit 1709b49e199d5ca6c4059585ff56668649e6c0ef
Author:     Dima Panov <fluffy@FreeBSD.org>
AuthorDate: 2023-02-01 12:06:35 +0000
Commit:     Dima Panov <fluffy@FreeBSD.org>
CommitDate: 2023-02-01 12:08:25 +0000

    net/libnss-mysql: unbreak build with mysql80/maria105+ (+)
    
    Transfer maintainership vd => fluffy
    
    PR:             269130
    Approved by:    vd
---
 net/libnss-mysql/Makefile                     |  2 +-
 net/libnss-mysql/files/patch-src_mysql.c      | 22 ++++++++++++++++++++++
 net/libnss-mysql/files/patch-src_nss__mysql.h | 13 +++++++++++++
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/net/libnss-mysql/Makefile b/net/libnss-mysql/Makefile
index c6a37c172892..7fcd6930feba 100644
--- a/net/libnss-mysql/Makefile
+++ b/net/libnss-mysql/Makefile
@@ -4,7 +4,7 @@ PORTREVISION=	5
 CATEGORIES=	net
 MASTER_SITES=	SF
 
-MAINTAINER=	vd@FreeBSD.org
+MAINTAINER=	fluffy@FreeBSD.org
 COMMENT=	NSS module using a MySQL database for backend
 WWW=		http://libnss-mysql.sourceforge.net/
 
diff --git a/net/libnss-mysql/files/patch-src_mysql.c b/net/libnss-mysql/files/patch-src_mysql.c
new file mode 100644
index 000000000000..11f9a288c6c9
--- /dev/null
+++ b/net/libnss-mysql/files/patch-src_mysql.c
@@ -0,0 +1,22 @@
+--- src/mysql.c.orig	2005-09-04 03:34:02 UTC
++++ src/mysql.c
+@@ -196,6 +196,7 @@ _nss_mysql_connect_sql (MYSQL_RES **mresult)
+   int retval;
+   sql_server_t *server = &conf.sql.server;
+   unsigned int port;
++  my_bool reconnect = 1;
+ 
+   DENTER
+ 
+@@ -238,8 +239,9 @@ _nss_mysql_connect_sql (MYSQL_RES **mresult)
+           DSRETURN (NSS_UNAVAIL)
+         }
+       ci.valid = ntrue;
+-      ci.link.reconnect = 0; /* Safety: We can't let MySQL assume socket is
+-                                still valid; see _nss_mysql_validate_socket */
++      /* Safety: We can't let MySQL assume socket is still valid;
++         see _nss_mysql_validate_socket */
++      mysql_options(&ci.link, MYSQL_OPT_RECONNECT, &reconnect); 
+       DSRETURN (NSS_SUCCESS)
+     }
+   _nss_mysql_log (LOG_ALERT, "Connection to server '%s' failed: %s",
diff --git a/net/libnss-mysql/files/patch-src_nss__mysql.h b/net/libnss-mysql/files/patch-src_nss__mysql.h
new file mode 100644
index 000000000000..866715e32797
--- /dev/null
+++ b/net/libnss-mysql/files/patch-src_nss__mysql.h
@@ -0,0 +1,13 @@
+--- src/nss_mysql.h.orig	2005-09-04 03:34:02 UTC
++++ src/nss_mysql.h
+@@ -72,6 +72,10 @@ typedef nss_status_t NSS_STATUS;
+ /* Default initializers */
+ #define DEF_TIMEOUT         3
+ 
++#if !defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 80001
++#define my_bool bool
++#endif
++
+ #ifdef DEBUG
+ void _nss_mysql_debug (char *fmt, ...);
+ #define DEBUG_FILE "/tmp/libnss-mysql-debug.log"