1
Author: Sergei Golubchik <serg@mariadb.org>
2
Descriptiong: Experimental patch from https://mariadb.atlassian.net/browse/MDEV-6577
4
=== modified file 'plugin/auth_socket/CMakeLists.txt'
5
--- a/plugin/auth_socket/CMakeLists.txt 2013-03-08 18:09:15 +0000
6
+++ b/plugin/auth_socket/CMakeLists.txt 2014-08-13 14:44:30 +0000
7
@@ -22,18 +22,48 @@ int main() {
8
getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, 0);
11
-IF (NOT HAVE_PEERCRED)
13
- CHECK_CXX_SOURCE_COMPILES(
14
- "#include <sys/types.h>
15
- #include <sys/socket.h>
17
- struct sockpeercred cred;
18
- getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, 0);
19
- }" HAVE_SOCKPEERCRED)
20
- ADD_DEFINITIONS(-Ducred=sockpeercred)
22
+ ADD_DEFINITIONS(-DHAVE_PEERCRED)
27
+CHECK_CXX_SOURCE_COMPILES(
28
+"#include <sys/types.h>
29
+#include <sys/socket.h>
31
+ struct sockpeercred cred;
32
+ getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, 0);
33
+ }" HAVE_SOCKPEERCRED)
35
+IF (HAVE_SOCKPEERCRED)
36
+ ADD_DEFINITIONS(-DHAVE_SOCKPEERCRED)
40
+# FreeBSD, is that you?
41
+CHECK_CXX_SOURCE_COMPILES(
42
+"#include <sys/types.h>
43
+#include <sys/socket.h>
45
+#include <sys/ucred.h>
48
+ getsockopt(0, 0, LOCAL_PEERCRED, &cred, 0);
52
+ ADD_DEFINITIONS(-DHAVE_XUCRED)
56
+# What else? C'mon, show your creativity, be different!
62
-IF(HAVE_PEERCRED OR HAVE_SOCKPEERCRED)
64
MYSQL_ADD_PLUGIN(auth_socket auth_socket.c MODULE_ONLY)
68
=== modified file 'plugin/auth_socket/auth_socket.c'
69
--- a/plugin/auth_socket/auth_socket.c 2012-02-15 17:08:08 +0000
70
+++ b/plugin/auth_socket/auth_socket.c 2014-08-13 14:46:42 +0000
72
#define _GNU_SOURCE 1 /* for struct ucred */
74
#include <mysql/plugin_auth.h>
75
-#include <sys/socket.h>
79
+#include <sys/socket.h>
80
+#include <sys/types.h>
83
+#define level SOL_SOCKET
85
+#elif defined HAVE_SOCKPEERCRED
86
+#define level SOL_SOCKET
87
+#define ucred socketpeercred
89
+#elif defined HAVE_XUCRED
91
+#include <sys/ucred.h>
93
+#define SO_PEERCRED LOCAL_PEERCRED
102
perform the unix socket based authentication
103
@@ -63,7 +83,7 @@ static int socket_auth(MYSQL_PLUGIN_VIO
106
/* get the UID of the client process */
107
- if (getsockopt(vio_info.socket, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len))
108
+ if (getsockopt(vio_info.socket, level, SO_PEERCRED, &cred, &cred_len))
111
if (cred_len != sizeof(cred))