~ubuntu-branches/ubuntu/utopic/mariadb-5.5/utopic-security

« back to all changes in this revision

Viewing changes to debian/patches/21_kfreebsd-peercred.diff

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2014-08-27 21:12:36 UTC
  • mfrom: (2.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20140827211236-se41hwfe4xy0hpef
* d/control: Removed Provides: libmysqlclient-dev (Closes: #759309)
* d/control: Removed Provides: libmysqld-dev with same motivation
* Re-introduced tha HPPA build patch as the upstream fix wasn't complete
* Fixed all kFreeBSD build and test suite issues
* Added Italian translation (Closes: #759813)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Author: Sergei Golubchik <serg@mariadb.org>
 
2
Descriptiong: Experimental patch from https://mariadb.atlassian.net/browse/MDEV-6577
 
3
 
 
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);
 
9
 }" HAVE_PEERCRED)
 
10
  
 
11
-IF (NOT HAVE_PEERCRED)
 
12
-  # Hi, OpenBSD!
 
13
-  CHECK_CXX_SOURCE_COMPILES(
 
14
-  "#include <sys/types.h>
 
15
-  #include <sys/socket.h>
 
16
-  int main() {
 
17
-    struct sockpeercred cred;
 
18
-    getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, 0);
 
19
-    }" HAVE_SOCKPEERCRED)
 
20
-  ADD_DEFINITIONS(-Ducred=sockpeercred)
 
21
+IF (HAVE_PEERCRED)
 
22
+  ADD_DEFINITIONS(-DHAVE_PEERCRED)
 
23
+  SET(ok 1)
 
24
+ELSE()
 
25
+
 
26
+# Hi, OpenBSD!
 
27
+CHECK_CXX_SOURCE_COMPILES(
 
28
+"#include <sys/types.h>
 
29
+#include <sys/socket.h>
 
30
+int main() {
 
31
+  struct sockpeercred cred;
 
32
+  getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, 0);
 
33
+  }" HAVE_SOCKPEERCRED)
 
34
+
 
35
+IF (HAVE_SOCKPEERCRED)
 
36
+  ADD_DEFINITIONS(-DHAVE_SOCKPEERCRED)
 
37
+  SET(ok 1)
 
38
+ELSE()
 
39
+
 
40
+# FreeBSD, is that you?
 
41
+CHECK_CXX_SOURCE_COMPILES(
 
42
+"#include <sys/types.h>
 
43
+#include <sys/socket.h>
 
44
+#include <sys/un.h>
 
45
+#include <sys/ucred.h>
 
46
+int main() {
 
47
+  struct xucred cred;
 
48
+  getsockopt(0, 0, LOCAL_PEERCRED, &cred, 0);
 
49
+  }" HAVE_XUCRED)
 
50
+
 
51
+IF (HAVE_XUCRED)
 
52
+  ADD_DEFINITIONS(-DHAVE_XUCRED)
 
53
+  SET(ok 1)
 
54
+ELSE()
 
55
+
 
56
+# What else? C'mon, show your creativity, be different!
 
57
+
 
58
+ENDIF()
 
59
+ENDIF()
 
60
 ENDIF()
 
61
 
 
62
-IF(HAVE_PEERCRED OR HAVE_SOCKPEERCRED)
 
63
+IF(ok)
 
64
   MYSQL_ADD_PLUGIN(auth_socket auth_socket.c MODULE_ONLY)
 
65
 ENDIF()
 
66
+
 
67
 
 
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
 
71
@@ -27,9 +27,29 @@
 
72
 #define _GNU_SOURCE 1 /* for struct ucred */
 
73
 
 
74
 #include <mysql/plugin_auth.h>
 
75
-#include <sys/socket.h>
 
76
-#include <pwd.h>
 
77
 #include <string.h>
 
78
+#include <pwd.h>
 
79
+#include <sys/socket.h>
 
80
+#include <sys/types.h>
 
81
+
 
82
+#ifdef HAVE_PEERCRED
 
83
+#define level SOL_SOCKET
 
84
+
 
85
+#elif defined HAVE_SOCKPEERCRED
 
86
+#define level SOL_SOCKET
 
87
+#define ucred socketpeercred
 
88
+
 
89
+#elif defined HAVE_XUCRED
 
90
+#include <sys/un.h>
 
91
+#include <sys/ucred.h>
 
92
+#define level 0
 
93
+#define SO_PEERCRED LOCAL_PEERCRED
 
94
+#define uid cr_uid
 
95
+#define ucred xucred
 
96
+
 
97
+#else
 
98
+#error impossible
 
99
+#endif
 
100
 
 
101
 /**
 
102
   perform the unix socket based authentication
 
103
@@ -63,7 +83,7 @@ static int socket_auth(MYSQL_PLUGIN_VIO
 
104
     return CR_ERROR;
 
105
 
 
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))
 
109
     return CR_ERROR;
 
110
 
 
111
   if (cred_len != sizeof(cred))
 
112