1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
--- mod_auth_mysql.c.orig 2005-06-22 16:17:45 UTC
+++ mod_auth_mysql.c
@@ -98,6 +98,10 @@
#define _PORT STRING(PORT)
#endif
#else
+ /* MariaDB as of 10.2 does not declare MYSQL_PORT for the client */
+ #ifndef MYSQL_PORT
+ #define MYSQL_PORT 3306
+ #endif
#ifdef APACHE2
#define _PORT MYSQL_PORT /* Use the one from MySQL */
#else
@@ -108,6 +112,10 @@
#ifdef SOCKET /* UNIX socket */
#define _SOCKET STRING(SOCKET)
#else
+ /* MariaDB as of 10.2 does not declare MYSQL_UNIX_ADDR for the client */
+ #ifndef MYSQL_UNIX_ADDR
+ #define MYSQL_UNIX_ADDR STRING(/tmp/mysql.sock)
+ #endif
#define _SOCKET MYSQL_UNIX_ADDR
#endif
@@ -206,7 +214,7 @@
#define SNPRINTF apr_snprintf
#define PSTRDUP apr_pstrdup
#define PSTRNDUP apr_pstrndup
- #define STRCAT ap_pstrcat
+ #define STRCAT apr_pstrcat
#define POOL apr_pool_t
#include "http_request.h" /* for ap_hook_(check_user_id | auth_checker)*/
#include "ap_compat.h"
@@ -237,7 +245,7 @@
#define SNPRINTF ap_snprintf
#define PSTRDUP ap_pstrdup
#define PSTRNDUP ap_pstrndup
- #define STRCAT ap_pstrcat
+ #define STRCAT apr_pstrcat
#define POOL pool
#include <stdlib.h>
#include "ap_sha1.h"
@@ -589,87 +597,87 @@ static void * create_mysql_auth_dir_conf
static
command_rec mysql_auth_cmds[] = {
AP_INIT_TAKE1("AuthMySQLHost", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlhost),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlhost),
OR_AUTHCFG, "mysql server host name"),
AP_INIT_TAKE1("AuthMySQLPort", ap_set_int_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlport),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlport),
OR_AUTHCFG, "mysql server port number"),
AP_INIT_TAKE1("AuthMySQLSocket", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlsocket),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlsocket),
OR_AUTHCFG, "mysql server socket path"),
AP_INIT_TAKE1("AuthMySQLUser", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqluser),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqluser),
OR_AUTHCFG, "mysql server user name"),
AP_INIT_TAKE1("AuthMySQLPassword", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlpasswd),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlpasswd),
OR_AUTHCFG, "mysql server user password"),
AP_INIT_TAKE1("AuthMySQLDB", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlDB),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlDB),
OR_AUTHCFG, "mysql database name"),
AP_INIT_TAKE1("AuthMySQLUserTable", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlpwtable),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlpwtable),
OR_AUTHCFG, "mysql user table name"),
AP_INIT_TAKE1("AuthMySQLGroupTable", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlgrptable),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlgrptable),
OR_AUTHCFG, "mysql group table name"),
AP_INIT_TAKE1("AuthMySQLNameField", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlNameField),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlNameField),
OR_AUTHCFG, "mysql User ID field name within User table"),
AP_INIT_TAKE1("AuthMySQLGroupField", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlGroupField),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlGroupField),
OR_AUTHCFG, "mysql Group field name within table"),
AP_INIT_TAKE1("AuthMySQLGroupUserNameField", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlGroupUserNameField),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlGroupUserNameField),
OR_AUTHCFG, "mysql User ID field name within Group table"),
AP_INIT_TAKE1("AuthMySQLPasswordField", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlPasswordField),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlPasswordField),
OR_AUTHCFG, "mysql Password field name within table"),
AP_INIT_TAKE1("AuthMySQLPwEncryption", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlEncryptionField),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlEncryptionField),
OR_AUTHCFG, "mysql password encryption method"),
AP_INIT_TAKE1("AuthMySQLSaltField", ap_set_string_slot,
- (void*) APR_XtOffsetOf(mysql_auth_config_rec, mysqlSaltField),
+ (void*) APR_OFFSETOF(mysql_auth_config_rec, mysqlSaltField),
OR_AUTHCFG, "mysql salfe field name within table"),
/* AP_INIT_FLAG("AuthMySQLKeepAlive", ap_set_flag_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlKeepAlive),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlKeepAlive),
OR_AUTHCFG, "mysql connection kept open across requests if On"),
*/
AP_INIT_FLAG("AuthMySQLAuthoritative", ap_set_flag_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlAuthoritative),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlAuthoritative),
OR_AUTHCFG, "mysql lookup is authoritative if On"),
AP_INIT_FLAG("AuthMySQLNoPasswd", ap_set_flag_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlNoPasswd),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlNoPasswd),
OR_AUTHCFG, "If On, only check if user exists; ignore password"),
AP_INIT_FLAG("AuthMySQLEnable", ap_set_flag_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlEnable),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlEnable),
OR_AUTHCFG, "enable mysql authorization"),
AP_INIT_TAKE1("AuthMySQLUserCondition", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlUserCondition),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlUserCondition),
OR_AUTHCFG, "condition to add to user where-clause"),
AP_INIT_TAKE1("AuthMySQLGroupCondition", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlGroupCondition),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlGroupCondition),
OR_AUTHCFG, "condition to add to group where-clause"),
AP_INIT_TAKE1("AuthMySQLCharacterSet", ap_set_string_slot,
- (void *) APR_XtOffsetOf(mysql_auth_config_rec, mysqlCharacterSet),
+ (void *) APR_OFFSETOF(mysql_auth_config_rec, mysqlCharacterSet),
OR_AUTHCFG, "mysql character set to be used"),
{ NULL }
@@ -905,7 +913,16 @@ static char * format_remote_host(request
}
static char * format_remote_ip(request_rec * r, char ** parm) {
- return r->connection->remote_ip;
+/*
+ from ap_mmn.h
+ 20111130.0 (2.4.0-dev) c->remote_ip becomes c->peer_ip and r->client_ip,
+ c->remote_addr becomes c->peer_addr and r->client_addr
+*/
+#if AP_MODULE_MAGIC_AT_LEAST(20111130,0)
+ return r->connection->client_ip;
+#else
+ return r->connection->remote_ip;
+#endif
}
static char * format_filename(request_rec * r, char ** parm) {
@@ -1270,7 +1287,7 @@ static int mysql_check_auth(request_rec
int method = r->method_number;
#ifdef APACHE2
- const apr_array_header_t *reqs_arr = ap_requires(r);
+ const apr_array_header_t *reqs_arr = NULL;
#else
const array_header *reqs_arr = ap_requires(r);
#endif
|