-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.patch
335 lines (315 loc) · 12.6 KB
/
doc.patch
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
diff -rupN gateway-1.4.3/config.log gateway-1.4.3-docpatch/config.log
--- gateway-1.4.3/config.log 2010-12-16 16:10:39.556817202 +0300
+++ gateway-1.4.3-docpatch/config.log 2010-12-17 08:03:03.511830000 +0300
@@ -1210,6 +1210,7 @@ on davey-crockett
config.status:824: creating gwlib/gw_uuid_types.h
config.status:824: creating Makefile
config.status:824: creating gw-config.h
+config.status:1040: gw-config.h is unchanged
## ---------------- ##
## Cache variables. ##
diff -rupN gateway-1.4.3/config.status gateway-1.4.3-docpatch/config.status
--- gateway-1.4.3/config.status 2010-12-16 16:10:39.372822229 +0300
+++ gateway-1.4.3-docpatch/config.status 2010-12-17 08:03:03.363830000 +0300
@@ -358,7 +358,7 @@ Copyright (C) 2008 Free Software Foundat
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
-ac_pwd='/home/david/Projects/Kannel/gateway-1.4.3'
+ac_pwd='/home/david/Projects/Kannel/gateway-1.4.3-patch'
srcdir='.'
INSTALL='/usr/bin/install -c'
test -n "$AWK" || AWK=awk
diff -rupN gateway-1.4.3/doc/userguide/userguide.xml gateway-1.4.3-docpatch/doc/userguide/userguide.xml
--- gateway-1.4.3/doc/userguide/userguide.xml 2008-12-10 20:55:07.000000000 +0300
+++ gateway-1.4.3-docpatch/doc/userguide/userguide.xml 2010-12-17 09:52:54.147327462 +0300
@@ -5308,6 +5308,13 @@ ssl-certkey-file
/cgi-bin/sendsms</literal>.
</entry></row>
+ <row><entry><literal>refresh-list-url (o)</literal></entry>
+ <entry>url</entry>
+ <entry valign="bottom">
+ URL locating the refreshlist service. Defaults to <literal>
+ /cgi-bin/refreshlist</literal>.
+ </entry></row>
+
<row><entry><literal>sendota-url (o)</literal></entry>
<entry>url</entry>
<entry valign="bottom">
@@ -5695,7 +5702,7 @@ get-url = "http://%S"
<row><entry><literal>name</literal></entry>
<entry>string</entry>
<entry valign="bottom">
- Optional name to identify the service in logs. If unset,
+ Optional name to identify the service in logs (and for refreshing whitelists and blacklists of services). If unset,
<literal>keyword</literal> is used.
</entry></row>
@@ -7620,8 +7627,95 @@ the Kannel configuration, or 'Authorizat
</sect2>
+<sect2>
+<title>Using the HTTP interface to Refresh sms-service whitelists and blacklists</title>
+
+ <para>After you have configured Kannel to allow the refreshlist
+ service, you can refresh service whitelists and blacklists via HTTP,
+ e.g., using a WWW browser. The URL looks something like this:
+
+<programlisting>
+http://smsbox.host.name:13013/cgi-bin/refreshlist?
+username=foo&password=bar&name=myservice
+</programlisting>
+
+ Thus, technically,
+ you make an HTTP GET request. This means that all the information
+ is stuffed into the URL. If you want to use this often via a
+ browser, you probably want to make an HTML form for this.</para>
+
+ <para>
+ Kannel will answer to sendsms request with following codes and
+ body texts:</para>
+
+ <table frame="none">
+ <title>SMS Refresh list reply codes</title>
+ <tgroup cols="3"><thead><row>
+ <entry>Status</entry>
+ <entry>Body</entry>
+ <entry>Meaning</entry>
+ </row></thead>
+ <tbody>
+ <row><entry><literal>200</literal></entry>
+ <entry><literal>0: Successful refresh</literal></entry>
+ <entry valign="bottom">
+ The service name was valid and a successful refresh of the
+ corresponding white list or black list occurred.
+ </entry></row>
+ <row><entry><literal>4xx</literal></entry>
+ <entry>(varies)</entry>
+ <entry valign="bottom">
+ The service name was not provided, or the user authentication failed.
+ </entry></row>
+ <row><entry><literal>503</literal></entry>
+ <entry><literal>Temporal failure, try again later.</literal></entry>
+ <entry valign="bottom">
+ There was temporal failure in retrieving the white list or black list
+ from the configured url for the sms-service. Could indicate the application serving the list
+ is down or had its own internal failure.
+ </entry></row>
+
+ </tbody>
+ </tgroup>
+ </table>
+
+
+ <table frame="none">
+ <title>Refresh List (refreshlist) CGI Variables</title>
+ <tgroup cols="3">
+ <tbody>
+ <row><entry><literal>username</literal> (or <literal>user</literal>)</entry>
+ <entry><literal>string</literal></entry>
+ <entry valign="bottom">
+ Username or account name. Must be <literal>username</literal> of the one
+ 'sendsms-user' group in the Kannel configuration,
+ or results in 'Authorization failed' reply.
+ </entry></row>
+
+ <row><entry><literal>password</literal> (or <literal>pass</literal>)</entry>
+ <entry><literal>string</literal></entry>
+ <entry valign="bottom">
+ Password associated with given <literal>username</literal>. Must match
+ corresponding field in the 'sendsms-user' group of
+the Kannel configuration, or 'Authorization failed' is returned.
+ </entry></row>
+
+ <row><entry><literal>name</literal></entry>
+ <entry><literal>string</literal></entry>
+ <entry valign="bottom">
+ The name of the service for which lists should be refreshed, as specified in the
+ <literal>sms-service</literal> block by the configuration option <literal>name</literal>.
+ </entry></row>
+
+ </tbody>
+ </tgroup>
+ </table>
+
+</sect2>
</sect1>
+
+
</chapter>
diff -rupN gateway-1.4.3/gw/smsbox.c gateway-1.4.3-docpatch/gw/smsbox.c
--- gateway-1.4.3/gw/smsbox.c 2009-01-12 19:46:57.000000000 +0300
+++ gateway-1.4.3-docpatch/gw/smsbox.c 2010-12-17 08:25:09.135326000 +0300
@@ -106,6 +106,7 @@ static Octstr *sendsms_interface = NULL;
static Octstr *smsbox_id = NULL;
static Octstr *sendsms_url = NULL;
static Octstr *sendota_url = NULL;
+static Octstr *refreshlist_url = NULL;
static Octstr *xmlrpc_url = NULL;
static Octstr *bb_host;
static Octstr *accepted_chars = NULL;
@@ -2465,6 +2466,38 @@ static URLTranslation *authorise_user(Li
#endif
}
+static Octstr *smsbox_refresh_service(List *args, Octstr *client_ip, int *status,
+ HTTPClient *client)
+{
+ URLTranslation *t;
+ Octstr *name;
+
+ /* check the username and password */
+ t = authorise_user(args, client_ip);
+ if (t == NULL) {
+ *status = HTTP_FORBIDDEN;
+ return octstr_create("Authorization failed for sendsms");
+ }
+
+ name = http_cgi_variable(args, "name");
+ if (name == NULL) {
+ error(0, "%s got insufficient headers (<name> is NULL)",
+ octstr_get_cstr(sendsms_url));
+ *status = HTTP_BAD_REQUEST;
+ return octstr_create("Missing service name, rejected");
+ }
+
+ if (urltrans_refresh_service_lists(translations, name) == -1) {
+ error(0, "An error occurred while trying to refresh list for %s",
+ octstr_get_cstr(name));
+ *status = HTTP_INTERNAL_SERVER_ERROR;
+ return octstr_create("Refreshing service list failed");
+ }
+ else {
+ *status = HTTP_OK;
+ return octstr_create("Lists for service successfully refreshed");
+ }
+}
/*
* Create and send an SMS message from an HTTP request.
@@ -3202,6 +3235,20 @@ static void sendsms_thread(void *arg)
else
answer = smsbox_sendsms_post(hdrs, body, ip, &status, client);
}
+ /* refresh service-level white and black lists */
+ else if (octstr_compare(url, refreshlist_url) == 0)
+ {
+ /*
+ * decide if this is a GET or POST request,
+ * currently only GET requests are supported
+ */
+ if (body == NULL)
+ answer = smsbox_refresh_service(args, ip, &status, client);
+ else {
+ answer = octstr_create("Only GET request for refresh list are supported.");
+ status = HTTP_BAD_REQUEST;
+ }
+ }
/* XML-RPC */
else if (octstr_compare(url, xmlrpc_url) == 0)
{
@@ -3447,6 +3494,8 @@ static Cfg *init_smsbox(Cfg *cfg)
xmlrpc_url = octstr_imm("/cgi-bin/xmlrpc");
if ((sendota_url = cfg_get(grp, octstr_imm("sendota-url"))) == NULL)
sendota_url = octstr_imm("/cgi-bin/sendota");
+ if ((refreshlist_url = cfg_get(grp, octstr_imm("refresh-list-url"))) == NULL)
+ refreshlist_url = octstr_imm("/cgi-bin/refreshlist");
global_sender = cfg_get(grp, octstr_imm("global-sender"));
accepted_chars = cfg_get(grp, octstr_imm("sendsms-chars"));
@@ -3638,6 +3687,7 @@ int main(int argc, char **argv)
octstr_destroy(smsbox_id);
octstr_destroy(sendsms_url);
octstr_destroy(sendota_url);
+ octstr_destroy(refreshlist_url);
octstr_destroy(xmlrpc_url);
octstr_destroy(reply_emptymessage);
octstr_destroy(reply_requestfailed);
diff -rupN gateway-1.4.3/gw/urltrans.c gateway-1.4.3-docpatch/gw/urltrans.c
--- gateway-1.4.3/gw/urltrans.c 2009-01-12 19:46:56.000000000 +0300
+++ gateway-1.4.3-docpatch/gw/urltrans.c 2010-12-17 08:24:55.299826000 +0300
@@ -73,7 +73,7 @@
#include "gw/sms.h"
-/***********************************************************************
+/***************************************nu********************************
* Definitions of data structures. These are not visible to the external
* world -- they may be accessed only via the functions declared in
* urltrans.h.
@@ -114,6 +114,9 @@ struct URLTranslation {
Octstr *denied_prefix; /* ...denied prefixes */
Octstr *allowed_recv_prefix; /* Prefixes (of receiver) allowed in this translation, or... */
Octstr *denied_recv_prefix; /* ...denied prefixes */
+ Octstr *white_list_url; /* url to retreive the white list from */
+ /* stored so that it can be refreshed on-demand */
+ Octstr *black_list_url; /* url to retreive the black list from */
Numhash *white_list; /* To numbers allowed, or ... */
Numhash *black_list; /* ...denied numbers */
@@ -247,6 +250,27 @@ int urltrans_add_cfg(URLTranslationList
return 0;
}
+int urltrans_refresh_service_lists(URLTranslationList *trans, Octstr *name) {
+ List *list;
+ URLTranslation *ot;
+ int retval = -1;
+
+ list = dict_get(trans->names, name);
+ while (list && (ot = gwlist_extract_first(list)) != NULL) {
+ if (ot->type != TRANSTYPE_SENDSMS) {
+ if (ot->white_list_url != NULL) {
+ ot->white_list = numhash_create(octstr_get_cstr(ot->white_list_url));
+ retval = 0;
+ }
+ if (ot->black_list_url != NULL) {
+ ot->black_list = numhash_create(octstr_get_cstr(ot->black_list_url));
+ retval = 0;
+ }
+ }
+ }
+ return retval;
+}
+
URLTranslation *urltrans_find(URLTranslationList *trans, Msg *msg)
{
@@ -1102,6 +1126,7 @@ static URLTranslation *create_onetrans(C
os = cfg_get(grp, octstr_imm("white-list"));
if (os != NULL) {
+ ot->white_list_url = octstr_duplicate(os);
ot->white_list = numhash_create(octstr_get_cstr(os));
octstr_destroy(os);
}
@@ -1114,6 +1139,7 @@ static URLTranslation *create_onetrans(C
os = cfg_get(grp, octstr_imm("black-list"));
if (os != NULL) {
+ ot->black_list_url = octstr_duplicate(os);
ot->black_list = numhash_create(octstr_get_cstr(os));
octstr_destroy(os);
}
@@ -1187,6 +1213,8 @@ static void destroy_onetrans(void *p)
octstr_destroy(ot->denied_prefix);
octstr_destroy(ot->allowed_recv_prefix);
octstr_destroy(ot->denied_recv_prefix);
+ octstr_destroy(ot->white_list_url);
+ octstr_destroy(ot->black_list_url);
numhash_destroy(ot->white_list);
numhash_destroy(ot->black_list);
if (ot->keyword_regex != NULL) gw_regex_destroy(ot->keyword_regex);
diff -rupN gateway-1.4.3/gw/urltrans.h gateway-1.4.3-docpatch/gw/urltrans.h
--- gateway-1.4.3/gw/urltrans.h 2009-01-12 19:46:56.000000000 +0300
+++ gateway-1.4.3-docpatch/gw/urltrans.h 2010-12-16 16:47:15.796820000 +0300
@@ -172,6 +172,12 @@ int urltrans_add_cfg(URLTranslationList
*/
URLTranslation *urltrans_find(URLTranslationList *trans, Msg *msg);
+/* Refresh the white list and black lists for a particular sms service,
+ * if specified in the config file by urls.
+ * returns 0 if everything goes according to plan, -1 otherwise
+ */
+int urltrans_refresh_service_lists(URLTranslationList *trans, Octstr *name);
+
/*
* Find the translation that corresponds to a given name
*
diff -rupN gateway-1.4.3/gwlib/cfg.def gateway-1.4.3-docpatch/gwlib/cfg.def
--- gateway-1.4.3/gwlib/cfg.def 2009-01-12 19:46:55.000000000 +0300
+++ gateway-1.4.3-docpatch/gwlib/cfg.def 2010-12-17 07:24:31.951828000 +0300
@@ -256,6 +256,7 @@ SINGLE_GROUP(smsbox,
OCTSTR(sendsms-interface)
OCTSTR(sendsms-url)
OCTSTR(sendota-url)
+ OCTSTR(refresh-list-url)
OCTSTR(xmlrpc-url)
OCTSTR(sendsms-chars)
OCTSTR(global-sender)