Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
638075e5
Commit
638075e5
authored
Sep 06, 2014
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-6577 auth_socket.so does not build in kFreeBSD
if it has to be a mess of ifdefs, then mess of ifdefs it is
parent
695781a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
14 deletions
+65
-14
plugin/auth_socket/CMakeLists.txt
plugin/auth_socket/CMakeLists.txt
+42
-11
plugin/auth_socket/auth_socket.c
plugin/auth_socket/auth_socket.c
+23
-3
No files found.
plugin/auth_socket/CMakeLists.txt
View file @
638075e5
...
...
@@ -22,18 +22,49 @@ int main() {
getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, 0);
}"
HAVE_PEERCRED
)
IF
(
NOT HAVE_PEERCRED
)
# Hi, OpenBSD!
CHECK_CXX_SOURCE_COMPILES
(
"#include <sys/types.h>
#include <sys/socket.h>
int main() {
struct sockpeercred cred;
getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, 0);
}"
HAVE_SOCKPEERCRED
)
ADD_DEFINITIONS
(
-Ducred=sockpeercred
)
IF
(
HAVE_PEERCRED
)
ADD_DEFINITIONS
(
-DHAVE_PEERCRED
)
SET
(
ok 1
)
ELSE
()
# Hi, OpenBSD!
CHECK_CXX_SOURCE_COMPILES
(
"#include <sys/types.h>
#include <sys/socket.h>
int main() {
struct sockpeercred cred;
getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, 0);
}"
HAVE_SOCKPEERCRED
)
IF
(
HAVE_SOCKPEERCRED
)
ADD_DEFINITIONS
(
-DHAVE_SOCKPEERCRED
)
SET
(
ok 1
)
ELSE
()
# FreeBSD, is that you?
CHECK_CXX_SOURCE_COMPILES
(
"#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/ucred.h>
int main() {
struct xucred cred;
getsockopt(0, 0, LOCAL_PEERCRED, &cred, 0);
}"
HAVE_XUCRED
)
IF
(
HAVE_XUCRED
)
ADD_DEFINITIONS
(
-DHAVE_XUCRED
)
SET
(
ok 1
)
ELSE
()
# Who else? Anyone?
# C'mon, show your creativity, be different! ifdef's are fun, aren't they?
ENDIF
()
ENDIF
()
ENDIF
()
IF
(
HAVE_PEERCRED OR HAVE_SOCKPEERCRED
)
IF
(
ok
)
MYSQL_ADD_PLUGIN
(
auth_socket auth_socket.c MODULE_ONLY
)
ENDIF
()
plugin/auth_socket/auth_socket.c
View file @
638075e5
...
...
@@ -27,9 +27,29 @@
#define _GNU_SOURCE 1
/* for struct ucred */
#include <mysql/plugin_auth.h>
#include <sys/socket.h>
#include <pwd.h>
#include <string.h>
#include <pwd.h>
#include <sys/socket.h>
#include <sys/types.h>
#ifdef HAVE_PEERCRED
#define level SOL_SOCKET
#elif defined HAVE_SOCKPEERCRED
#define level SOL_SOCKET
#define ucred socketpeercred
#elif defined HAVE_XUCRED
#include <sys/un.h>
#include <sys/ucred.h>
#define level 0
#define SO_PEERCRED LOCAL_PEERCRED
#define uid cr_uid
#define ucred xucred
#else
#error impossible
#endif
/**
perform the unix socket based authentication
...
...
@@ -63,7 +83,7 @@ static int socket_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info)
return
CR_ERROR
;
/* get the UID of the client process */
if
(
getsockopt
(
vio_info
.
socket
,
SOL_SOCKET
,
SO_PEERCRED
,
&
cred
,
&
cred_len
))
if
(
getsockopt
(
vio_info
.
socket
,
level
,
SO_PEERCRED
,
&
cred
,
&
cred_len
))
return
CR_ERROR
;
if
(
cred_len
!=
sizeof
(
cred
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment