summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-10-28 10:01:50 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-10-28 10:01:50 +0200
commita8de8f261d1b7621b8e16396e87dfaac14891162 (patch)
tree9b8ec45858c2757305e0bdecf237fcb59251020c /plugin
parente183aec1d75ea7b424ebe237e6b1643961903f2d (diff)
parent42e1815ad850384fad292534665ff61b78dd96f6 (diff)
downloadmariadb-git-a8de8f261d1b7621b8e16396e87dfaac14891162.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'plugin')
-rw-r--r--plugin/auth_gssapi/CMakeLists.txt5
-rw-r--r--plugin/auth_pam/CMakeLists.txt34
-rw-r--r--plugin/auth_pam/auth_pam.c1
-rw-r--r--plugin/auth_pam/config.h.cmake5
-rw-r--r--plugin/auth_pam/mapper/pam_user_map.c30
5 files changed, 52 insertions, 23 deletions
diff --git a/plugin/auth_gssapi/CMakeLists.txt b/plugin/auth_gssapi/CMakeLists.txt
index bca4f5af3a1..4d3718dd471 100644
--- a/plugin/auth_gssapi/CMakeLists.txt
+++ b/plugin/auth_gssapi/CMakeLists.txt
@@ -18,6 +18,11 @@ ELSE()
SET(GSSAPI_SERVER gssapi_server.cc)
SET(GSSAPI_ERRMSG gssapi_errmsg.cc)
+ IF(APPLE)
+ SET_SOURCE_FILES_PROPERTIES(
+ ${GSSAPI_CLIENT} ${GSSAPI_SERVER} ${GSSAPI_ERRMSG}
+ PROPERTY COMPILE_FLAGS "-Wno-deprecated-declarations")
+ ENDIF()
SET(CMAKE_REQUIRED_INCLUDES ${GSSAPI_INCS})
SET(CMAKE_REQUIRED_LIBRARIES ${GSSAPI_LIBS})
INCLUDE(CheckCXXSymbolExists)
diff --git a/plugin/auth_pam/CMakeLists.txt b/plugin/auth_pam/CMakeLists.txt
index 5366246745e..ff7ba4a4f68 100644
--- a/plugin/auth_pam/CMakeLists.txt
+++ b/plugin/auth_pam/CMakeLists.txt
@@ -5,23 +5,31 @@ CHECK_INCLUDE_FILES (security/pam_ext.h HAVE_PAM_EXT_H)
CHECK_INCLUDE_FILES (security/pam_appl.h HAVE_PAM_APPL_H)
CHECK_FUNCTION_EXISTS (strndup HAVE_STRNDUP)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+
+# Check whether getgrouplist uses git_t for second and third arguments.
+SET(CMAKE_REQUIRED_FLAGS -Werror)
+CHECK_C_SOURCE_COMPILES(
+"
+#include <grp.h>
+#include <unistd.h>
+int main() {
+ char *arg_1;
+ gid_t arg_2, arg_3;
+ int arg_4;
+ (void)getgrouplist(arg_1,arg_2,&arg_3,&arg_4);
+ return 0;
+}
+"
+HAVE_POSIX_GETGROUPLIST
+)
+SET(CMAKE_REQUIRED_FLAGS)
+
SET(CMAKE_REQUIRED_LIBRARIES pam)
CHECK_FUNCTION_EXISTS(pam_syslog HAVE_PAM_SYSLOG)
SET(CMAKE_REQUIRED_LIBRARIES)
-IF(HAVE_PAM_SYSLOG)
- ADD_DEFINITIONS(-DHAVE_PAM_SYSLOG)
-ENDIF()
-
-IF(HAVE_PAM_EXT_H)
- ADD_DEFINITIONS(-DHAVE_PAM_EXT_H)
-ENDIF()
-
IF(HAVE_PAM_APPL_H)
- ADD_DEFINITIONS(-DHAVE_PAM_APPL_H)
- IF(HAVE_STRNDUP)
- ADD_DEFINITIONS(-DHAVE_STRNDUP)
- ENDIF(HAVE_STRNDUP)
FIND_LIBRARY(PAM_LIBRARY pam) # for srpm build-depends detection
MYSQL_ADD_PLUGIN(auth_pam auth_pam.c LINK_LIBRARIES pam MODULE_ONLY)
@@ -37,3 +45,5 @@ IF(HAVE_PAM_APPL_H)
ENDIF()
ENDIF(HAVE_PAM_APPL_H)
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/config_auth_pam.h)
diff --git a/plugin/auth_pam/auth_pam.c b/plugin/auth_pam/auth_pam.c
index fae73aea690..c80ec51b48d 100644
--- a/plugin/auth_pam/auth_pam.c
+++ b/plugin/auth_pam/auth_pam.c
@@ -16,6 +16,7 @@
#define _GNU_SOURCE 1 /* for strndup */
+#include <config_auth_pam.h>
#include <mysql/plugin_auth.h>
#include <stdio.h>
#include <string.h>
diff --git a/plugin/auth_pam/config.h.cmake b/plugin/auth_pam/config.h.cmake
new file mode 100644
index 00000000000..2a60e99d52c
--- /dev/null
+++ b/plugin/auth_pam/config.h.cmake
@@ -0,0 +1,5 @@
+#cmakedefine HAVE_POSIX_GETGROUPLIST 1
+#cmakedefine HAVE_PAM_SYSLOG 1
+#cmakedefine HAVE_PAM_EXT_H 1
+#cmakedefine HAVE_PAM_APPL_H 1
+#cmakedefine HAVE_STRNDUP 1
diff --git a/plugin/auth_pam/mapper/pam_user_map.c b/plugin/auth_pam/mapper/pam_user_map.c
index 9d7ed53f8b1..fa8d9ae08c1 100644
--- a/plugin/auth_pam/mapper/pam_user_map.c
+++ b/plugin/auth_pam/mapper/pam_user_map.c
@@ -31,6 +31,7 @@ These comments are written to the syslog as 'authpriv.debug'
and usually end up in /var/log/secure file.
*/
+#include <config_auth_pam.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
@@ -70,10 +71,16 @@ pam_syslog (const pam_handle_t *pamh, int priority,
#define GROUP_BUFFER_SIZE 100
static const char debug_keyword[]= "debug";
-static int populate_user_groups(const char *user, gid_t **groups)
+#ifdef HAVE_POSIX_GETGROUPLIST
+typedef gid_t my_gid_t;
+#else
+typedef int my_gid_t;
+#endif
+
+static int populate_user_groups(const char *user, my_gid_t **groups)
{
- gid_t user_group_id;
- gid_t *loc_groups= *groups;
+ my_gid_t user_group_id;
+ my_gid_t *loc_groups= *groups;
int ng;
{
@@ -88,22 +95,23 @@ static int populate_user_groups(const char *user, gid_t **groups)
{
/* The rare case when the user is present in more than */
/* GROUP_BUFFER_SIZE groups. */
- loc_groups= (gid_t *) malloc(ng * sizeof (gid_t));
+ loc_groups= (my_gid_t *) malloc(ng * sizeof (my_gid_t));
+
if (!loc_groups)
return 0;
(void) getgrouplist(user, user_group_id, loc_groups, &ng);
- *groups= loc_groups;
+ *groups= (my_gid_t*)loc_groups;
}
return ng;
}
-static int user_in_group(const gid_t *user_groups, int ng,const char *group)
+static int user_in_group(const my_gid_t *user_groups, int ng,const char *group)
{
- gid_t group_id;
- const gid_t *groups_end = user_groups + ng;
+ my_gid_t group_id;
+ const my_gid_t *groups_end = user_groups + ng;
{
struct group *g= getgrnam(group);
@@ -122,7 +130,7 @@ static int user_in_group(const gid_t *user_groups, int ng,const char *group)
}
-static void print_groups(pam_handle_t *pamh, const gid_t *user_groups, int ng)
+static void print_groups(pam_handle_t *pamh, const my_gid_t *user_groups, int ng)
{
char buf[256];
char *c_buf= buf, *buf_end= buf+sizeof(buf)-2;
@@ -158,8 +166,8 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags,
const char *username;
char buf[256];
FILE *f;
- gid_t group_buffer[GROUP_BUFFER_SIZE];
- gid_t *groups= group_buffer;
+ my_gid_t group_buffer[GROUP_BUFFER_SIZE];
+ my_gid_t *groups= group_buffer;
int n_groups= -1;
for (; argc > 0; argc--)