summaryrefslogtreecommitdiff
path: root/net-im/jabberd/files/jabberd-2.1.11-r2.patch
Unidiff
Diffstat (limited to 'net-im/jabberd/files/jabberd-2.1.11-r2.patch') (more/less context) (ignore whitespace changes)
-rw-r--r--net-im/jabberd/files/jabberd-2.1.11-r2.patch299
1 files changed, 299 insertions, 0 deletions
diff --git a/net-im/jabberd/files/jabberd-2.1.11-r2.patch b/net-im/jabberd/files/jabberd-2.1.11-r2.patch
new file mode 100644
index 0000000..dbf441a
--- a/dev/null
+++ b/net-im/jabberd/files/jabberd-2.1.11-r2.patch
@@ -0,0 +1,299 @@
1diff --git a/c2s/main.c b/c2s/main.c
2index a86e571..0bf89e6 100644
3--- a/c2s/main.c
4+++ b/c2s/main.c
5@@ -698,6 +698,7 @@ JABBER_MAIN("jabberd2c2s", "Jabber 2 C2S", "Jabber Open Source Server: Client to
6 if(sess->ip != NULL) free(sess->ip);
7 if(sess->result != NULL) nad_free(sess->result);
8 if(sess->jid != NULL) jid_free(sess->jid);
9+ if(sess->rate != NULL) rate_free(sess->rate);
10
11 free(sess);
12 }
13diff --git a/configure.ac b/configure.ac
14index 099aec9..29dca26 100644
15--- a/configure.ac
16+++ b/configure.ac
17@@ -494,37 +494,48 @@ AM_CONDITIONAL(STORAGE_MYSQL, [test "x-$have_mysql" = "x-yes"])
18
19 # PostgreSQL
20 AC_ARG_ENABLE([pgsql],
21- AC_HELP_STRING([--enable-pgsql], [enable PostgreSQL auth/reg/storage support (no)]),
22- [enable_pgsql=$enableval have_pgsql=no],
23+ AC_HELP_STRING([--enable-pgsql],
24 +[enable PostgreSQL auth/reg/storage support, you can provide path to
25 +pg_config executable (no)]),
26+ [enable_pgsql="$enableval" have_pgsql=no],
27 [enable_pgsql=no have_pgsql=no])
28-if test "x-$enable_pgsql" = "x-yes" ; then
29- for i in /usr /usr/local /usr/local/pgsql ; do
30- for j in include include/pgsql include/postgres include/postgresql "" ; do
31- if test -r "$i/$j/libpq-fe.h" ; then
32- PGSQL_INCLUDE=$i/$j
33- fi
34- done
35- for lib in lib lib64 ; do
36- for j in $lib $lib/pgsql $lib/postgres $lib/postgresql "" ; do
37- if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a" ; then
38- PGSQL_LIBDIR=$i/$j
39- fi
40- done
41- done
42- done
43- AC_CHECK_LIB([pq], [PQsetdbLogin], [
44- have_pgsql=yes
45- if test "x-$PGSQL_INCLUDE" != "x-"; then
46- PGSQL_CFLAGS="-I $PGSQL_INCLUDE"
47- fi
48- if test "x-$PGSQL_LIBDIR" != "x-"; then
49- PGSQL_LIBS="-L$PGSQL_LIBDIR -lpq"
50- fi
51- AC_DEFINE(STORAGE_POSTGRES, 1, [Define to 1 if you want to use PostgreSQL for storage.])
52- ])
53- if test "x-$have_pgsql" != "x-yes" ; then
54- AC_MSG_ERROR([PostgreSQL support requested, but headers/libraries not found.])
55- fi
56+if test "x-$enable_pgsql" != "x-no" ; then
57 +if test -x "$enable_pgsql" ; then
58 + PGSQL_INCLUDE="$($enable_pgsql --includedir)"
59 + PGSQL_LIBDIR="$($enable_pgsql --libdir)"
60 + PGSQL_CFLAGS="-I$PGSQL_INCLUDE"
61 + PGSQL_LIBS="-L$PGSQL_LIBDIR -lpq"
62 + have_pgsql=yes
63 + AC_DEFINE([STORAGE_POSTGRES],[1],[Define to 1 if you want to use PostgreSQL for storage.])
64 + else# leave legacy detection intact for now
65 + for i in /usr /usr/local /usr/local/pgsql ; do
66 + for j in include include/pgsql include/postgres include/postgresql "" ; do
67 + if test -r "$i/$j/libpq-fe.h" ; then
68 + PGSQL_INCLUDE=$i/$j
69 + fi
70 + done
71 + for lib in lib lib64 ; do
72 + for j in $lib $lib/pgsql $lib/postgres $lib/postgresql "" ; do
73 + if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a" ; then
74 + PGSQL_LIBDIR=$i/$j
75 + fi
76 + done
77 + done
78 + done
79 + AC_CHECK_LIB([pq], [PQsetdbLogin], [
80 + have_pgsql=yes
81 + if test "x-$PGSQL_INCLUDE" != "x-"; then
82 + PGSQL_CFLAGS="-I $PGSQL_INCLUDE"
83 + fi
84 + if test "x-$PGSQL_LIBDIR" != "x-"; then
85 + PGSQL_LIBS="-L$PGSQL_LIBDIR -lpq"
86 + fi
87 + AC_DEFINE(STORAGE_POSTGRES, 1, [Define to 1 if you want to use PostgreSQL for storage.])
88 + ])
89 + if test "x-$have_pgsql" != "x-yes" ; then
90 + AC_MSG_ERROR([PostgreSQL support requested, but headers/libraries not found.])
91 + fi
92 +fi
93 fi
94 AC_SUBST(PGSQL_CFLAGS)
95 AC_SUBST(PGSQL_LIBS)
96diff --git a/etc/c2s.xml.dist.in b/etc/c2s.xml.dist.in
97index 873a133..0589ada 100644
98--- a/etc/c2s.xml.dist.in
99+++ b/etc/c2s.xml.dist.in
100@@ -325,6 +325,11 @@
101
102 <!-- PostgreSQL module configuration -->
103 <pgsql>
104+ <!-- PostgreSQL connection info -->
105+ <conninfo>dbname=jabberd2 user=jabberd2 password=secret</conninfo>
106+
107+ <!-- The rest of connection settings are used only in absence of 'conninfo' -->
108+
109 <!-- Database server host and port -->
110 <host>localhost</host>
111 <port>5432</port>
112diff --git a/mio/mio_impl.h b/mio/mio_impl.h
113index 6f72a5c..cabdc67 100644
114--- a/mio/mio_impl.h
115+++ b/mio/mio_impl.h
116@@ -226,8 +226,12 @@ static void _mio_run(mio_t m, int timeout)
117 {
118 mio_fd_t fd = MIO_ITERATOR_FD(m,iter);
119
120- /* skip dead slots */
121- if(FD(m,fd)->type == type_CLOSED) continue;
122+ /* deferred closing fd */
123+ if(FD(m,fd)->type == type_CLOSED)
124+ {
125+ MIO_FREE_FD(m, fd);
126+ continue;
127+ }
128
129 /* new conns on a listen socket */
130 if(FD(m,fd)->type == type_LISTEN && MIO_CAN_READ(m,iter))
131@@ -259,12 +263,6 @@ static void _mio_run(mio_t m, int timeout)
132 if(ACT(m, fd, action_WRITE, NULL) == 0)
133 MIO_UNSET_WRITE(m, FD(m,fd));
134 }
135-
136- /* deferred closing fd */
137- if(FD(m,fd)->type == type_CLOSED)
138- {
139- MIO_FREE_FD(m, fd);
140- }
141 }
142 }
143
144diff --git a/sm/main.c b/sm/main.c
145index 2f1439d..9f27829 100644
146--- a/sm/main.c
147+++ b/sm/main.c
148@@ -392,6 +392,7 @@ JABBER_MAIN("jabberd2sm", "Jabber 2 Session Manager", "Jabber Open Source Server
149 xhash_free(sm->acls);
150 xhash_free(sm->features);
151 xhash_free(sm->xmlns);
152+ xhash_free(sm->xmlns_refcount);
153 xhash_free(sm->users);
154
155 sx_free(sm->router);
156diff --git a/sm/mod_privacy.c b/sm/mod_privacy.c
157index 06f9e6e..5abf065 100644
158--- a/sm/mod_privacy.c
159+++ b/sm/mod_privacy.c
160@@ -205,7 +205,7 @@ static int _privacy_user_load(mod_instance_t mi, user_t user) {
161 continue;
162 }
163
164- pool_cleanup(zlist->p, free, zitem->jid);
165+ pool_cleanup(zlist->p, jid_free, zitem->jid);
166
167 log_debug(ZONE, "jid item with value '%s'", jid_full(zitem->jid));
168
169@@ -696,7 +696,7 @@ static mod_ret_t _privacy_in_sess(mod_instance_t mi, sess_t sess, pkt_t pkt) {
170 return -stanza_err_BAD_REQUEST;
171 }
172
173- pool_cleanup(p, free, zitem->jid);
174+ pool_cleanup(p, jid_free, zitem->jid);
175
176 log_debug(ZONE, "jid item with value '%s'", jid_full(zitem->jid));
177
178diff --git a/storage/authreg_pgsql.c b/storage/authreg_pgsql.c
179index 1f15e83..5f1583d 100644
180--- a/storage/authreg_pgsql.c
181+++ b/storage/authreg_pgsql.c
182@@ -302,9 +302,13 @@ int _ar_pgsql_check_sql( authreg_t ar, char * sql, char * types ) {
183 return 1;
184 }
185
186+#ifdef HAVE_SSL
187+extern int sx_openssl_initialized;
188+#endif
189+
190 /** start me up */
191 int ar_init(authreg_t ar) {
192- char *host, *port, *dbname, *user, *pass;
193+ char *host, *port, *dbname, *user, *pass, *conninfo;
194 char *create, *select, *setpassword, *delete;
195 char *table, *username, *realm;
196 char *template;
197@@ -391,15 +395,26 @@ int ar_init(authreg_t ar) {
198 free(setpassword);
199 free(delete);
200
201- host = config_get_one(ar->c2s->config, "authreg.pgsql.host", 0);
202- port = config_get_one(ar->c2s->config, "authreg.pgsql.port", 0);
203- dbname = config_get_one(ar->c2s->config, "authreg.pgsql.dbname", 0);
204- user = config_get_one(ar->c2s->config, "authreg.pgsql.user", 0);
205- pass = config_get_one(ar->c2s->config, "authreg.pgsql.pass", 0);
206-
207- log_debug( ZONE, "pgsql connecting as '%s' to database '%s' on %s:%s", user, dbname, host, port );
208+#ifdef HAVE_SSL
209+ if(sx_openssl_initialized)
210 +PQinitSSL(0);
211+#endif
212+ conninfo = config_get_one(ar->c2s->config,"authreg.pgsql.conninfo",0);
213+ if(conninfo) {
214 +/* don't log connection info for it can contain password */
215 +log_debug( ZONE, "pgsql connecting to the databse");
216 +conn = PQconnectdb(conninfo);
217+ }else{
218 +/* compatibility settings */
219 +host = config_get_one(ar->c2s->config, "authreg.pgsql.host", 0);
220 +port = config_get_one(ar->c2s->config, "authreg.pgsql.port", 0);
221 +dbname = config_get_one(ar->c2s->config, "authreg.pgsql.dbname", 0);
222 +user = config_get_one(ar->c2s->config, "authreg.pgsql.user", 0);
223 +pass = config_get_one(ar->c2s->config, "authreg.pgsql.pass", 0);
224 +log_debug( ZONE, "pgsql connecting as '%s' to database '%s' on %s:%s", user, dbname, host, port );
225 +conn = PQsetdbLogin(host, port, NULL, NULL, dbname, user, pass);
226+ }
227
228- conn = PQsetdbLogin(host, port, NULL, NULL, dbname, user, pass);
229 if(conn == NULL) {
230 log_write(ar->c2s->log, LOG_ERR, "pgsql: unable to allocate database connection state");
231 return 1;
232diff --git a/sx/sasl_gsasl.c b/sx/sasl_gsasl.c
233index 69eeec2..0036c0f 100644
234--- a/sx/sasl_gsasl.c
235+++ b/sx/sasl_gsasl.c
236@@ -338,6 +338,7 @@ static void _sx_sasl_client_process(sx_t s, sx_plugin_t p, Gsasl_session *sd, ch
237 if(ret != GSASL_OK && ret != GSASL_NEEDS_MORE) {
238 _sx_debug(ZONE, "gsasl_step failed, no sasl for this conn; (%d): %s", ret, gsasl_strerror(ret));
239 _sx_nad_write(s, _sx_sasl_failure(s, _sasl_err_MALFORMED_REQUEST), 0);
240+ if(buf != NULL) free(buf);
241 return;
242 }
243 }
244@@ -350,6 +351,7 @@ static void _sx_sasl_client_process(sx_t s, sx_plugin_t p, Gsasl_session *sd, ch
245 if(ret != GSASL_OK && ret != GSASL_NEEDS_MORE) {
246 _sx_debug(ZONE, "gsasl_step failed, no sasl for this conn; (%d): %s", ret, gsasl_strerror(ret));
247 _sx_nad_write(s, _sx_sasl_failure(s, _sasl_err_MALFORMED_REQUEST), 0);
248+ if(buf != NULL) free(buf);
249 return;
250 }
251
252diff --git a/sx/ssl.c b/sx/ssl.c
253index 62c4258..9359f4d 100644
254--- a/sx/ssl.c
255+++ b/sx/ssl.c
256@@ -628,6 +628,8 @@ static void _sx_ssl_unload(sx_plugin_t p) {
257 SSL_CTX_free((SSL_CTX *) p->private);
258 }
259
260+int sx_openssl_initialized = 0;
261+
262 /** args: pemfile */
263 int sx_ssl_init(sx_env_t env, sx_plugin_t p, va_list args) {
264 char *pemfile, *cachain;
265@@ -653,6 +655,8 @@ int sx_ssl_init(sx_env_t env, sx_plugin_t p, va_list args) {
266 SSL_library_init();
267 SSL_load_error_strings();
268
269+ sx_openssl_initialized = 1;
270+
271 /* create the context */
272 ctx = SSL_CTX_new(SSLv23_method());
273 if(ctx == NULL) {
274diff --git a/util/jid.c b/util/jid.c
275index 695b15f..f4b0021 100644
276--- a/util/jid.c
277+++ b/util/jid.c
278@@ -332,7 +332,7 @@ static jid_t jid_reset_components_internal(jid_t jid, const unsigned char *node,
279 else {
280 /* allocate new data buffer */
281 jid->jid_data_len = node_l+domain_l+resource_l+3;
282- jid->jid_data = malloc(jid->jid_data_len);
283+ jid->jid_data = realloc(jid->jid_data, jid->jid_data_len);
284 }
285
286 /* copy to buffer */
287diff --git a/util/nad.c b/util/nad.c
288index 2ac8670..eec3c17 100644
289--- a/util/nad.c
290+++ b/util/nad.c
291@@ -61,7 +61,7 @@ static void _nad_ptr_check(const char *func, nad_t nad) {
292 #define _nad_ptr_check(func,nad)
293 #endif
294
295-#define BLOCKSIZE 1024
296+#define BLOCKSIZE 128
297
298 /** internal: do and return the math and ensure it gets realloc'd */
299 static int _nad_realloc(void **oblocks, int len)