File: README

package info (click to toggle)
openser 1.1.0-9etch1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 9,828 kB
  • ctags: 11,809
  • sloc: ansic: 120,528; sh: 5,249; yacc: 1,716; makefile: 1,261; php: 656; perl: 205; sql: 190
file content (679 lines) | stat: -rw-r--r-- 21,576 bytes parent folder | download
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679

permissions Module

Miklos Tirpak

Edited by

Miklos Tirpak

Bogdan-Andrei Iancu

   Copyright  2003 Miklos Tirpak
     _________________________________________________________

   Table of Contents
   1. User's Guide

        1.1. Overview

              1.1.1. Call Routing
              1.1.2. Registration Permissions
              1.1.3. Referral Permissions
              1.1.4. Trusted Requests

        1.2. Dependencies

              1.2.1. OpenSER Modules
              1.2.2. External Libraries or Applications

        1.3. Exported Parameters

              1.3.1. default_allow_file (string)
              1.3.2. default_deny_file (string)
              1.3.3. check_all_branches (integer)
              1.3.4. allow_suffix (string)
              1.3.5. deny_suffix (string)
              1.3.6. db_url (string)
              1.3.7. db_mode (integer)
              1.3.8. trusted_table (string)
              1.3.9. source_col (string)
              1.3.10. proto_col (string)
              1.3.11. from_col (string)
              1.3.12. tag_col (string)
              1.3.13. peer_tag_avp (string)

        1.4. Exported Functions

              1.4.1. allow_routing()
              1.4.2. allow_routing(basename)
              1.4.3. allow_routing(allow_file,deny_file)
              1.4.4. allow_register(basename)
              1.4.5. allow_register(allow_file, deny_file)
              1.4.6. allow_refer_to(basename)
              1.4.7. allow_refer_to(allow_file, deny_file)
              1.4.8. allow_trusted()

        1.5. FIFO Commands

              1.5.1. trusted_reload
              1.5.2. trusted_dump

   2. Developer's Guide
   3. Frequently Asked Questions

   List of Examples
   1-1. Set default_allow_file parameter
   1-2. Set default_deny_file parameter
   1-3. Set check_all_branches parameter
   1-4. Set allow_suffix parameter
   1-5. Set deny_suffix parameter
   1-6. Set db_url parameter
   1-7. Set db_mode parameter
   1-8. Set trusted_table parameter
   1-9. Set source_col parameter
   1-10. Set proto_col parameter
   1-11. Set from_col parameter
   1-12. Set tag_col parameter
   1-13. Set peer_tag_avp parameter
   1-14. allow_routing usage
   1-15. allow_routing(basename) usage
   1-16. allow_routing(allow_file, deny_file) usage
   1-17. allow_register(basename) usage
   1-18. allow_register(allow_file, deny_file) usage
   1-19. allow_refer_to(basename) usage
   1-20. allow_refer_to(allow_file, deny_file) usage
   1-21. allow_trusted() usage
     _________________________________________________________

Chapter 1. User's Guide

1.1. Overview

1.1.1. Call Routing

   The module can be used to determine if a call has appropriate
   permission to be established. Permission rules are stored in
   plaintext configuration files similar to hosts.allow and
   hosts.deny files used by tcpd.

   When allow_routing function is called it tries to find a rule
   that matches selected fields of the message.

   OpenSER is a forking proxy and therefore a single message can
   be sent to different destinations simultaneously. When
   checking permissions all the destinations must be checked and
   if one of them fails, the forwarding will fail.

   The matching algorithm is as follows, first match wins:

     * Create a set of pairs of form (From, R-URI of branch 1),
       (From, R-URI of branch 2), etc.
     * Routing will be allowed when all pairs match an entry in
       the allow file.
     * Otherwise routing will be denied when one of pairs matches
       an entry in the deny file.
     * Otherwise, routing will be allowed.

   A non-existing permission control file is treated as if it
   were an empty file. Thus, permission control can be turned off
   by providing no permission control files.

   From header field and Request-URIs are always compared with
   regular expressions! For the syntax see the sample file:
   config/permissions.allow.
     _________________________________________________________

1.1.2. Registration Permissions

   In addition to call routing it is also possible to check
   REGISTER messages and decide--based on the configuration
   files--whether the message should be allowed and the
   registration accepted or not.

   Main purpose of the function is to prevent registration of
   "prohibited" IP addresses. One example, when a malicious user
   registers a contact containing IP address of a PSTN gateway,
   he might be able to bypass authorization checks performed by
   the SIP proxy. That is undesirable and therefore attempts to
   register IP address of a PSTN gateway should be rejected.
   Files config/register.allow and config/register.deny contain
   an example configuration.

   Function for registration checking is called allow_register
   and the algorithm is very similar to the algorithm described
   in Section 1.1.1. The only difference is in the way how pairs
   are created.

   Instead of From header field the function uses To header field
   because To header field in REGISTER messages contains the URI
   of the person being registered. Instead of the Request-URI of
   branches the function uses Contact header field.

   Thus, pairs used in matching will look like this: (To, Contact
   1), (To, Contact 2), (To, Contact 3), and so on..

   The algorithm of matching is same as described in Section
   1.1.1.
     _________________________________________________________

1.1.3. Referral Permissions

   The module can be used to determine if referral is allowed to
   the destination specified by Refer-To header of REFER request.
   Permission rules are stored in plaintext configuration files
   similar to hosts.allow and hosts.deny used by tcpd.

   When allow_refer_to function is called, it tries to find a
   rule that matches selected fields of the message. The matching
   algorithm is as follows, first match wins:

     * Create a pair <From URI, Refer-To URI>.
     * Referral will be allowed when the pair matches an entry in
       the allow file.
     * Otherwise referral will be denied when the pair matches an
       entry in the deny file.
     * Otherwise, referral will be allowed.

   A non-existing permission control file is treated as if it
   were an empty file. Thus, permission control can be turned off
   by providing no permission control files.

   From URI and Refer-To URI are always compared with regular
   expressions! For the syntax see the sample file:
   config/permissions.allow.
     _________________________________________________________

1.1.4. Trusted Requests

   The module can be used to determine if an incoming request can
   be trusted without authentication.

   When allow_trusted function is called, it tries to find a rule
   that matches the request. Rules contain the following fields:
   <source address, transport protocol, regular expression>.

   A requests is accepted if there exists a rule, where

     * source address is equal to source address of request,
     * transport protocol is either "any" or equal to transport
       protocol of request, and
     * regular expression is either empty (NULL in database) or
       matches From URI of request.

   Otherwise the request is rejected.

   Rules are stored in a database table specified by module
   parameters. There also exists a module parameter that
   determines if rules are cached into memory for faster matching
   or if database is consulted for each invocation of
   allow_trusted function call.
     _________________________________________________________

1.2. Dependencies

1.2.1. OpenSER Modules

   The following modules must be loaded before this module:

     * No dependencies on other OpenSER modules.
     _________________________________________________________

1.2.2. External Libraries or Applications

   The following libraries or applications must be installed
   before running OpenSER with this module loaded:

     * None.
     _________________________________________________________

1.3. Exported Parameters

1.3.1. default_allow_file (string)

   Default allow file used by functions without parameters. If
   you don't specify full pathname then the directory in which is
   the main config file is located will be used.

   Default value is "permissions.allow". 

   Example 1-1. Set default_allow_file parameter
...
modparam("permissions", "default_allow_file", "/etc/permissions.allow")
...
     _________________________________________________________

1.3.2. default_deny_file (string)

   Default file containing deny rules. The file is used by
   functions without parameters. If you don't specify full
   pathname then the directory in which the main config file is
   located will be used.

   Default value is "permissions.deny". 

   Example 1-2. Set default_deny_file parameter
...
modparam("permissions", "default_deny_file", "/etc/permissions.deny")
...
     _________________________________________________________

1.3.3. check_all_branches (integer)

   If set then allow_routing functions will check Request-URI of
   all branches (default). If disabled then only Request-URI of
   the first branch will be checked.

   Warning

   Do not disable this parameter unless you really know what you
   are doing.

   Default value is 1. 

   Example 1-3. Set check_all_branches parameter
...
modparam("permissions", "check_all_branches", 0)
...
     _________________________________________________________

1.3.4. allow_suffix (string)

   Suffix to be appended to basename to create filename of the
   allow file when version with one parameter of either
   allow_routing or allow_register is used.

   Note

   Including leading dot.

   Default value is ".allow". 

   Example 1-4. Set allow_suffix parameter
...
modparam("permissions", "allow_suffix", ".allow")
...
     _________________________________________________________

1.3.5. deny_suffix (string)

   Suffix to be appended to basename to create filename of the
   deny file when version with one parameter of either
   allow_routing or allow_register is used.

   Note

   Including leading dot.

   Default value is ".deny". 

   Example 1-5. Set deny_suffix parameter
...
modparam("permissions", "deny_suffix", ".deny")
...
     _________________________________________________________

1.3.6. db_url (string)

   This is URL of the database to be used to store rules used by
   allow_trusted function.

   Default value is "NULL". 

   Example 1-6. Set db_url parameter
...
modparam("permissions", "db_url", "mysql://openser:pass@db_host/openser
")
...
     _________________________________________________________

1.3.7. db_mode (integer)

   Database mode. 0 means non-caching, 1 means caching.

   Default value is 0 (non-caching). 

   Example 1-7. Set db_mode parameter
...
modparam("permissions", "db_mode", 1)
...
     _________________________________________________________

1.3.8. trusted_table (string)

   Name of database table containing matching rules used by
   allow_register function.

   Default value is "trusted". 

   Example 1-8. Set trusted_table parameter
...
modparam("permissions", "trusted_table", "pbx")
...
     _________________________________________________________

1.3.9. source_col (string)

   Name of trusted table column containing source IP address that
   is matched against source IP address of received request.

   Default value is "src_ip". 

   Example 1-9. Set source_col parameter
...
modparam("permissions", "source_col", "source_ip_address")
...
     _________________________________________________________

1.3.10. proto_col (string)

   Name of trusted table column containing transport protocol
   that is matched against transport protocol of received
   request. Possible values that can be stored in proto_col are
   "any", "udp", "tcp", "tls", "sctp", and "none". Value "any"
   matches always and value "none" never.

   Default value is "proto". 

   Example 1-10. Set proto_col parameter
...
modparam("permissions", "proto_col", "transport")
...
     _________________________________________________________

1.3.11. from_col (string)

   Name of trusted table column containing regular expression
   that is matched against From URI.

   Default value is "from_pattern". 

   Example 1-11. Set from_col parameter
...
modparam("permissions", "from_col", "regexp")
...
     _________________________________________________________

1.3.12. tag_col (string)

   Name of trusted table column containing a string that is added
   as value to peer_tag AVP if peer_tag AVP has been defined and
   if the peer matches.

   Default value is "tag". 

   Example 1-12. Set tag_col parameter
...
modparam("permissions", "tag_col", "peer_tag")
...
     _________________________________________________________

1.3.13. peer_tag_avp (string)

   AVP spec of peer tag AVP. If defined, the AVP will be set as
   side effect of allow_trusted() call to not NULL tag column
   value of the matching peer.

   Default value is "undefined". 

   Example 1-13. Set peer_tag_avp parameter
...
modparam("permissions", "peer_tag_avp", "i:707")
...
     _________________________________________________________

1.4. Exported Functions

1.4.1. allow_routing()

   Returns true if all pairs constructed as described in Section
   1.1.1 have appropriate permissions according to the
   configuration files. This function uses default configuration
   files specified in default_allow_file and default_deny_file.

   This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.

   Example 1-14. allow_routing usage
...
if (allow_routing()) {
        t_relay();
};
...
     _________________________________________________________

1.4.2. allow_routing(basename)

   Returns true if all pairs constructed as described in Section
   1.1.1 have appropriate permissions according to the
   configuration files given as parameters.

   Meaning of the parameters is as follows:

     * basename - Basename from which allow and deny filenames
       will be created by appending contents of allow_suffix and
       deny_suffix parameters.
       If the parameter doesn't contain full pathname then the
       function expects the file to be located in the same
       directory as the main configuration file of the server.

   This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.

   Example 1-15. allow_routing(basename) usage
...
if (allow_routing("basename")) {
        t_relay();
};
...
     _________________________________________________________

1.4.3. allow_routing(allow_file,deny_file)

   Returns true if all pairs constructed as described in Section
   1.1.1 have appropriate permissions according to the
   configuration files given as parameters.

   Meaning of the parameters is as follows:

     * allow_file - File containing allow rules.
       If the parameter doesn't contain full pathname then the
       function expects the file to be located in the same
       directory as the main configuration file of the server.
     * deny_file - File containing deny rules.
       If the parameter doesn't contain full pathname then the
       function expects the file to be located in the same
       directory as the main configuration file of the server.

   This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.

   Example 1-16. allow_routing(allow_file, deny_file) usage
...
if (allow_routing("rules.allow", "rules.deny")) {
        t_relay();
};
...
     _________________________________________________________

1.4.4. allow_register(basename)

   The function returns true if all pairs constructed as
   described in Section 1.1.2 have appropriate permissions
   according to the configuration files given as parameters.

   Meaning of the parameters is as follows:

     * basename - Basename from which allow and deny filenames
       will be created by appending contents of allow_suffix and
       deny_suffix parameters.
       If the parameter doesn't contain full pathname then the
       function expects the file to be located in the same
       directory as the main configuration file of the server.

   This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.

   Example 1-17. allow_register(basename) usage
...
if (method=="REGISTER") {
        if (allow_register("register")) {
                save("location");
                break;
        } else {
                sl_send_reply("403", "Forbidden");
        };
};
...
     _________________________________________________________

1.4.5. allow_register(allow_file, deny_file)

   The function returns true if all pairs constructed as
   described in Section 1.1.2 have appropriate permissions
   according to the configuration files given as parameters.

   Meaning of the parameters is as follows:

     * allow_file - File containing allow rules.
       If the parameter doesn't contain full pathname then the
       function expects the file to be located in the same
       directory as the main configuration file of the server.
     * deny_file - File containing deny rules.
       If the parameter doesn't contain full pathname then the
       function expects the file to be located in the same
       directory as the main configuration file of the server.

   This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.

   Example 1-18. allow_register(allow_file, deny_file) usage
...
if (method=="REGISTER") {
        if (allow_register("register.allow", "register.deny")) {
                save("location");
                break;
        } else {
                sl_send_reply("403", "Forbidden");
        };
};
...
     _________________________________________________________

1.4.6. allow_refer_to(basename)

   Returns true if the pair constructed as described in Section
   1.1.3 have appropriate permissions according to the
   configuration files specified by the parameter.

   Meaning of the parameter is as follows:

     * basename - Basename from which allow and deny filenames
       will be created by appending contents of allow_suffix and
       deny_suffix parameters.
       If the parameter doesn't contain full pathname then the
       function expects the file to be located in the same
       directory as the main configuration file of the server.

   This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.

   Example 1-19. allow_refer_to(basename) usage
...
if (allow_refer_to("basename")) {
        t_relay();
};
...
     _________________________________________________________

1.4.7. allow_refer_to(allow_file, deny_file)

   Returns true if the pair constructed as described in Section
   1.1.3 have appropriate permissions according to the
   configuration files specified by parameters.

   Meaning of the parameters is as follows:

     * allow_file - File containing allow rules.
       If the parameter doesn't contain full pathname then the
       function expects the file to be located in the same
       directory as the main configuration file of the server.
     * deny_file - File containing deny rules.
       If the parameter doesn't contain full pathname then the
       function expects the file to be located in the same
       directory as the main configuration file of the server.

   This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.

   Example 1-20. allow_refer_to(allow_file, deny_file) usage
...
if (allow_refer_to("rules.allow", "rules.deny")) {
        t_relay();
};
...
     _________________________________________________________

1.4.8. allow_trusted()

   Checks based on request's source address, transport protocol,
   and From URI if request can be trusted without authentication.
   Returns 1 if a match is found as described in Section 1.1.4
   and -1 otherwise. If a match is found and peer_tag_avp has
   been defined, adds a non-NULL tag column value of the matching
   peer to AVP peer_tag_avp.

   This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.

   Example 1-21. allow_trusted() usage
...
if (allow_trusted()) {
        t_relay();
};
...
     _________________________________________________________

1.5. FIFO Commands

1.5.1. trusted_reload

   Causes permissions module to re-read the contents of trusted
   table into cache memory.
     _________________________________________________________

1.5.2. trusted_dump

   Causes permissions module to dump contents of trusted table
   from cache memory.
     _________________________________________________________

Chapter 2. Developer's Guide

   The module does not provide any API to use in other OpenSER
   modules.
     _________________________________________________________

Chapter 3. Frequently Asked Questions

   3.1. Where can I find more about OpenSER?
   3.2. Where can I post a question about this module?
   3.3. How can I report a bug?

   3.1. Where can I find more about OpenSER?

   Take a look at http://openser.org/.

   3.2. Where can I post a question about this module?

   First at all check if your question was already answered on
   one of our mailing lists:

     * User Mailing List -
       http://openser.org/cgi-bin/mailman/listinfo/users
     * Developer Mailing List -
       http://openser.org/cgi-bin/mailman/listinfo/devel

   E-mails regarding any stable OpenSER release should be sent to
   <users@openser.org> and e-mails regarding development versions
   should be sent to <devel@openser.org>.

   If you want to keep the mail private, send it to
   <team@openser.org>.

   3.3. How can I report a bug?

   Please follow the guidelines provided at:
   http://sourceforge.net/tracker/?group_id=139143.