[r10376]: branches / 1.8 / modules / permissions / doc / permissions_admin.xml  Maximize  Restore  History

Download this file

1041 lines (1006 with data), 29.4 kB

   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
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
<!-- Module User's Guide -->
<chapter>
<title>&adminguide;</title>
<section>
<title>Overview</title>
<section id="sec-call-routing">
<title>Call Routing</title>
<para>
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
<filename moreinfo="none">hosts.allow</filename> and <filename
moreinfo="none">hosts.deny</filename> files used by tcpd.
</para>
<para>
When <function moreinfo="none">allow_routing</function> function is
called it tries to find a rule that matches selected fields of the
message.
</para>
<para>
&osips; 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.
</para>
<para>
The matching algorithm is as follows, first match wins:
</para>
<itemizedlist>
<listitem>
<para>
Create a set of pairs of form (From, R-URI of branch 1),
(From, R-URI of branch 2), etc.
</para>
</listitem>
<listitem>
<para>
Routing will be allowed when all pairs match an entry in the
allow file.
</para>
</listitem>
<listitem>
<para>
Otherwise routing will be denied when one of pairs matches an
entry in the deny file.
</para>
</listitem>
<listitem>
<para>
Otherwise, routing will be allowed.
</para>
</listitem>
</itemizedlist>
<para>
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.
</para>
<para>
From header field and Request-URIs are always compared with regular
expressions! For the syntax see the sample file:
<filename moreinfo="none">config/permissions.allow</filename>.
</para>
</section>
<section id="sec-registration-permissions">
<title>Registration Permissions</title>
<para>
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.
</para>
<para>
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 <filename
moreinfo="none">config/register.allow</filename> and <filename
moreinfo="none">config/register.deny</filename> contain an example
configuration.
</para>
<para>
Function for registration checking is called <function
moreinfo="none">allow_register</function> and the algorithm is very
similar to the algorithm described in
<xref linkend="sec-call-routing"/>. The only difference is in the way
how pairs are created.
</para>
<para>
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.
</para>
<para>
Thus, pairs used in matching will look like this: (To, Contact 1),
(To, Contact 2), (To, Contact 3), and so on..
</para>
<para>
The algorithm of matching is same as described in
<xref linkend="sec-call-routing"/>.
</para>
</section>
<section id="sec-uri-permissions">
<title>URI Permissions</title>
<para>
The module can be used to determine if request is
allowed to the destination specified by an URI stored in
a pvar. Permission rules are stored in
plaintext configuration files similar to
<filename moreinfo="none">hosts.allow</filename> and
<filename moreinfo="none">hosts.deny</filename> used by tcpd.
</para>
<para>
When <function moreinfo="none">allow_uri</function>
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:
</para>
<itemizedlist>
<listitem>
<para>
Create a pair &lt;From URI, URI stored in pvar&gt;.
</para>
</listitem>
<listitem>
<para>
Request will be allowed when the pair matches
an entry in the allow file.
</para>
</listitem>
<listitem>
<para>
Otherwise request will be denied when the pair
matches an entry in the deny file.
</para>
</listitem>
<listitem>
<para>
Otherwise, request will be allowed.
</para>
</listitem>
</itemizedlist>
<para>
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.
</para>
<para>
From URI and URI stored in pvar are always compared with regular
expressions! For the syntax see the sample file:
<filename moreinfo="none">config/permissions.allow</filename>.
</para>
</section>
<section id="sec-address-permissions">
<title>Address Permissions</title>
<para>
The module can be used to determine if an address (IP
address and port) matches any of the IP subnets
stored in cached &osips; database table.
Port 0 in cached database table matches any port. Group ID, IP
address, port and transport protocol values to be matched can be either taken from
the request (<function moreinfo="none">check_source_address</function>) or given as pvar
arguments or directly as strings(<function moreinfo="none">check_address</function>).
</para>
<para>
Addresses stored in cached database table can be grouped
together into one or more groups specified by a group
identifier (unsigned integer). Group identifier is given as
argument to <function moreinfo="none">check_address</function> and
<function moreinfo="none">check_source_address</function>.
</para>
<para>
Otherwise the request is rejected.
</para>
<para>
The address database table is specified by module parameters.
</para>
</section>
</section>
<section>
<title>Dependencies</title>
<section>
<title>&osips; Modules</title>
<para>
The following modules must be loaded before this module:
<itemizedlist>
<listitem>
<para>
<emphasis>No dependencies on other &osips; modules</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
</section>
<section>
<title>External Libraries or Applications</title>
<para>
The following libraries or applications must be installed before running
&osips; with this module loaded:
<itemizedlist>
<listitem>
<para>
<emphasis>None</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
</section>
</section>
<section>
<title>Exported Parameters</title>
<section>
<title><varname>default_allow_file</varname> (string)</title>
<para>
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.
</para>
<para>
<emphasis>
Default value is <quote>permissions.allow</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>default_allow_file</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "default_allow_file", "/etc/permissions.allow")
...
</programlisting>
</example>
</section>
<section>
<title><varname>default_deny_file</varname> (string)</title>
<para>
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.
</para>
<para>
<emphasis>
Default value is <quote>permissions.deny</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>default_deny_file</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "default_deny_file", "/etc/permissions.deny")
...
</programlisting>
</example>
</section>
<section>
<title><varname>check_all_branches</varname> (integer)</title>
<para>
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.
</para>
<warning>
<para>
Do not disable this parameter unless you really know what you
are doing.
</para>
</warning>
<para>
<emphasis>
Default value is 1.
</emphasis>
</para>
<example>
<title>Set <varname>check_all_branches</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "check_all_branches", 0)
...
</programlisting>
</example>
</section>
<section>
<title><varname>allow_suffix</varname> (string)</title>
<para>
Suffix to be appended to basename to create filename of the allow
file when version with one parameter of either
<function moreinfo="none">allow_routing</function> or
<function moreinfo="none">allow_register</function> is used.
</para>
<note>
<para>
Including leading dot.
</para>
</note>
<para>
<emphasis>
Default value is <quote>.allow</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>allow_suffix</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "allow_suffix", ".allow")
...
</programlisting>
</example>
</section>
<section>
<title><varname>deny_suffix</varname> (string)</title>
<para>
Suffix to be appended to basename to create filename of the deny file
when version with one parameter of either
<function moreinfo="none">allow_routing</function> or
<function moreinfo="none">allow_register</function> is used.
</para>
<note>
<para>
Including leading dot.
</para>
</note>
<para>
<emphasis>
Default value is <quote>.deny</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>deny_suffix</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "deny_suffix", ".deny")
...
</programlisting>
</example>
</section>
<section>
<title><varname>db_url</varname> (string)</title>
<para>
This is URL of the database to be used.
</para>
<para>
<emphasis>
Default value is <quote>NULL</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>db_url</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "db_url", "&exampledb;")
...
</programlisting>
</example>
</section>
<section>
<title><varname>address_table</varname> (string)</title>
<para>
Name of database table containing matching rules used by
<function moreinfo="none">allow_register</function> function.
</para>
<para>
<emphasis>
Default value is <quote>address</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>address_table</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "address_table", "pbx")
...
</programlisting>
</example>
</section>
<section>
<title><varname>grp_col</varname> (string)</title>
<para>
Name of address table column containing group
identifier of the address.
</para>
<para>
<emphasis>
Default value is <quote>grp</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>grp_col</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "grp_col", "group_id")
...
</programlisting>
</example>
</section>
<section>
<title><varname>ip_col</varname> (string)</title>
<para>
Name of address table column containing IP address
part of the address.
</para>
<para>
<emphasis>
Default value is <quote>ip</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>ip_col</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "ip_col", "ipess")
...
</programlisting>
</example>
</section>
<section>
<title><varname>mask_col</varname> (string)</title>
<para>
Name of address table column containing network mask of
the address. Possible values are 0-32.
</para>
<para>
<emphasis>
Default value is <quote>mask</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>mask_col</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "mask_col", "subnet_length")
...
</programlisting>
</example>
</section>
<section>
<title><varname>port_col</varname> (string)</title>
<para>
Name of address table column containing port
part of the address.
</para>
<para>
<emphasis>
Default value is <quote>port</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>port_col</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "port_col", "prt")
...
</programlisting>
</example>
</section>
<section>
<title><varname>proto_col</varname> (string)</title>
<para>
Name of address table column containing transport
protocol that is matched against transport protocol of
received request. Possible values that can be stored in
proto_col are <quote>any</quote>, <quote>udp</quote>,
<quote>tcp</quote>, <quote>tls</quote>,
<quote>sctp</quote>, and <quote>none</quote>. Value
<quote>any</quote> matches always and value
<quote>none</quote> never.
</para>
<para>
<emphasis>
Default value is <quote>proto</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>proto_col</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "proto_col", "transport")
...
</programlisting>
</example>
</section>
<section>
<title><varname>pattern_col</varname> (string)</title>
<para>
Name of address table column containing regular
expression that is matched against the arguments received by
<function moreinfo="none">check_address</function>
or <function moreinfo="none">check_source_address</function>.
</para>
<para>
<emphasis>
Default value is <quote>pattern</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>pattern_col</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "pattern_col", "regexp")
...
</programlisting>
</example>
</section>
<section>
<title><varname>info_col</varname> (string)</title>
<para>
Name of address table column containing a string
that is added as value to a pvar given as argument
to <function moreinfo="none">check_address</function>
or <function moreinfo="none">check_source_address</function> in
case the function succedes.
</para>
<para>
<emphasis>
Default value is <quote>context_info</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>info_col</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("permissions", "info_col", "info_col")
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Exported Functions</title>
<section>
<title>
<function moreinfo="none">allow_routing()</function>
</title>
<para>
Returns true if all pairs constructed as described in <xref
linkend="sec-call-routing"/> have appropriate permissions according to
the configuration files. This function uses default configuration
files specified in <varname>default_allow_file</varname> and
<varname>default_deny_file</varname>.
</para>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
</para>
<example>
<title><function>allow_routing</function> usage</title>
<programlisting format="linespecific">
...
if (allow_routing()) {
t_relay();
};
...
</programlisting>
</example>
</section>
<section>
<title>
<function moreinfo="none">allow_routing(basename)</function>
</title>
<para>
Returns true if all pairs constructed as described in <xref
linkend="sec-call-routing"/> have appropriate permissions according
to the configuration files given as parameters.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>basename</emphasis> - Basename from which allow
and deny filenames will be created by appending contents of
<varname>allow_suffix</varname> and <varname>deny_suffix</varname>
parameters.
</para>
<para>
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.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
</para>
<example>
<title><function>allow_routing(basename)</function> usage</title>
<programlisting format="linespecific">
...
if (allow_routing("basename")) {
t_relay();
};
...
</programlisting>
</example>
</section>
<section>
<title>
<function moreinfo="none">allow_routing(allow_file,deny_file)</function>
</title>
<para>
Returns true if all pairs constructed as described in
<xref linkend="sec-call-routing"/> have appropriate permissions
according to the configuration files given as parameters.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>allow_file</emphasis> - File containing allow rules.
</para>
<para>
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.
</para>
</listitem>
<listitem>
<para><emphasis>deny_file</emphasis> - File containing deny rules.
</para>
<para>
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.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
</para>
<example>
<title><function>allow_routing(allow_file, deny_file)</function> usage</title>
<programlisting format="linespecific">
...
if (allow_routing("rules.allow", "rules.deny")) {
t_relay();
};
...
</programlisting>
</example>
</section>
<section>
<title>
<function moreinfo="none">allow_register(basename)</function>
</title>
<para>
The function returns true if all pairs constructed as described in <xref
linkend="sec-registration-permissions"/> have appropriate permissions
according to the configuration files given as parameters.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>basename</emphasis> - Basename from which allow
and deny filenames will be created by appending contents of
<varname>allow_suffix</varname> and <varname>deny_suffix</varname>
parameters.
</para>
<para>
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.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
</para>
<example>
<title><function>allow_register(basename)</function> usage</title>
<programlisting format="linespecific">
...
if (method=="REGISTER") {
if (allow_register("register")) {
save("location");
exit;
} else {
sl_send_reply("403", "Forbidden");
};
};
...
</programlisting>
</example>
</section>
<section>
<title>
<function moreinfo="none">allow_register(allow_file, deny_file)</function>
</title>
<para>
The function returns true if all pairs constructed as described in
<xref linkend="sec-registration-permissions"/> have appropriate
permissions according to the configuration files given as parameters.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>allow_file</emphasis> - File containing allow rules.
</para>
<para>
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.
</para>
</listitem>
<listitem>
<para><emphasis>deny_file</emphasis> - File containing deny rules.
</para>
<para>
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.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
</para>
<example>
<title><function>allow_register(allow_file, deny_file)</function> usage</title>
<programlisting format="linespecific">
...
if (method=="REGISTER") {
if (allow_register("register.allow", "register.deny")) {
save("location");
exit;
} else {
sl_send_reply("403", "Forbidden");
};
};
...
</programlisting>
</example>
</section>
<section>
<title>
<function moreinfo="none">allow_uri(basename, pvar)</function>
</title>
<para>
Returns true if the pair constructed as described in <xref
linkend="sec-uri-permissions"/> have appropriate permissions
according to the configuration files specified by the parameter.
</para>
<para>Meaning of the parameter is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>basename</emphasis> - Basename from which allow
and deny filenames will be created by appending contents of
<varname>allow_suffix</varname> and <varname>deny_suffix</varname>
parameters.
</para>
<para>
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.
</para>
</listitem>
<listitem>
<para><emphasis>pvar</emphasis> - Any
pseudo-variable defined in OpenSIPS.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
</para>
<example>
<title><function>allow_uri(basename, pvar)</function> usage</title>
<programlisting format="linespecific">
...
if (allow_uri("basename", "$rt")) { // Check Refer-To URI
t_relay();
};
if (allow_uri("basename", "$avp(basename)") { // Check URI stored in $avp(basename)
t_relay();
};
...
</programlisting>
</example>
</section>
<section>
<title>
<function moreinfo="none">check_address(group_id, ip,
port, proto [, context_info [, pattern]])</function>
</title>
<para>
Returns 1 if group id, IP address, port and protocol given as
arguments match an IP subnet found in cached address table,
as described in <xref linkend="sec-address-permissions"/> .
The function takes 4 mandatory arguments and 2 optional ones.
</para>
<para>
This function can be useful to check if a request can be allowed
without authentication.
</para>
<para>Meaning of the parameter is as follows:</para>
<itemizedlist>
<listitem>
group_id
<para>
This argument represents the group id to be matched.
It can be an integer string or a string pvar.
If the group_id argument is "0", the query can match any group
in the cached address table.
</para>
</listitem>
<listitem>
ip
<para>
This argument represents the ip address to be matched.
It can be an given directly as string or as a string pvar.
This argument cannot be null/empty.
</para>
</listitem>
<listitem>
port
<para>
This argument represents the port to be matched.
It can be an given as an integer string or as a string pvar.
Cached address table entry containing port value 0
matches any port.
Also, a "0" value for the argument can match any port in the
address table.
</para>
</listitem>
<listitem>
proto
<para>
This argument represents the protocol used for transport;
it can be an given as string or as string pvar.
Transport protocol is either "ANY" or any
valid transport protocol value: "UDP, "TCP", "TLS", and "SCTP".
</para>
</listitem>
<listitem>
context_info
<para>
This argument represents the pvar in wich the context_info field
from the cached address table will be stored in case of match.
This argument is optional.
</para>
</listitem>
<listitem>
pattern
<para>
This argument is a string to be matched with the regular expression
pattern field from the cached address table.
This argument is optional.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
</para>
<example>
<title><function>check_address()
</function> usage</title>
<programlisting format="linespecific">
...
// Checks if the tuple IP address/port (given as strings) and source protocol
// (given as pvar), belongs to group 4, verifies if pattern string "texttest"
// matches the regular expression field in the database table and stores the
// context information in $avp(context)
if (check_address("4","192.168.2.135","5700","$proto","$avp(context)", "texttest")) {
t_relay();
xlog("$avp(context)\n");
}
...
// Checks if the tuple IP address/port/protocol of the source message is in group 4
if (check_address("4","$si","$sp","$proto")) {
t_relay();
}
...
// Checks if the tuple IP address/port/protocol stored in AVPs s:ip/s:port/s:proto
// is in group 4 and stores context information in $avp(context)
$avp(ip) = "192.168.2.135";
$avp(port) = 5061;
$avp(proto) = "any";
if (check_address("4","$avp(ip)","$avp(port)","$avp(proto)","$avp(context))) {
t_relay();
xlog("$avp(context)\n");
}
...
// Checks if the tuple IP address/port (given as strings) and source protocol
// (given as pvar) is in group 4, verifies if pattern string "texttest" matches
// the regular expression field in the database table, without storing any
// context information
if (check_address("4","$si","5700","$proto","", "texttest")) {
t_relay();
}
...
</programlisting>
</example>
</section>
<section>
<title>
<function moreinfo="none">check_source_address(group_id [, context_info [, pattern]])</function>
</title>
<para>
Equivalent to check_address(group_id, "$si", "$sp", "$proto", context_info, pattern).
</para>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
</para>
<example>
<title><function>check_source_address()</function> usage</title>
<programlisting format="linespecific">
...
// Check if source address/port/proto is in group 4 and stores
// context information in $avp(context)
if (check_source_address("4","$avp(context)")) {
xlog("$avp(context)\n");
}else {
sl_send_reply("403", "Forbidden");
}
...
</programlisting>
</example>
</section>
<section>
<title>
<function moreinfo="none">get_source_group(pvar)</function>
</title>
<para>
Checks if an entry with the source ip/port/protocol is
found in cached address or subnet table in any group.
If yes, returns that group in the pvar parameter.
If not returns -1. Port value 0 in cached address and
subnet table matches any port.
</para>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
</para>
<example>
<title><function>get_source_group()</function> usage</title>
<programlisting format="linespecific">
...
if ( get_source_group("$var(group)") ) {
# do something with $var(group)
xlog("group is $var(group)\n");
};
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Exported MI Functions</title>
<section>
<title>
<function moreinfo="none">address_reload</function>
</title>
<para>
Causes permissions module to re-read the contents of
the address database table into cache
memory. In cache memory the entries are
for performance reasons stored in two
different tables: address table and
subnet table depending on the value of
the mask field (32 or smaller).
</para>
<para>Parameters: <emphasis>none</emphasis></para>
</section>
<section>
<title>
<function moreinfo="none">address_dump</function>
</title>
<para>
Causes permissions module to dump contents of
the address table from cache memory.
</para>
<para>Parameters: <emphasis>none</emphasis></para>
</section>
<section>
<title>
<function moreinfo="none">subnet_dump</function>
</title>
<para>
Causes permissions module to dump
contents of cache memory subnet table.
</para>
<para>Parameters: <emphasis>none</emphasis></para>
</section>
<section>
<title>
<function moreinfo="none">allow_uri</function>
</title>
<para>
Tests if (URI, Contact) pair is allowed according to
allow/deny files. The files must already have been
loaded by OpenSIPS.
</para>
<para>Parameters: </para>
<itemizedlist>
<listitem><para>
<emphasis>basename</emphasis> -
Basename from
which allow and deny filenames will be created by
appending contents of allow_suffix and deny_suffix
parameters.
</para></listitem>
<listitem><para>
<emphasis>URI</emphasis> - URI to be tested
</para></listitem>
<listitem><para>
<emphasis>Contact</emphasis> - Contact
to be tested
</para></listitem>
</itemizedlist>
</section>
</section>
</chapter>

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks