| 1 |
= Modules |
| 2 |
|
| 3 |
.Syntax |
| 4 |
[source,unlang] |
| 5 |
---- |
| 6 |
<module> |
| 7 |
---- |
| 8 |
|
| 9 |
The `<module>` statement is a reference to the named module. Common |
| 10 |
module names include `pap`, `chap`, `files`, `eap`, and `sql`. The |
| 11 |
`modules { ... }` subsection of `radiusd.conf` contains all of the |
| 12 |
valid modules. |
| 13 |
|
| 14 |
When processing reaches a named module, the pre-compiled module is |
| 15 |
called. The module may succeed or fail and will return a status code |
| 16 |
to the `unlang` interpreter detailing success or failure. |
| 17 |
|
| 18 |
.Example |
| 19 |
[source,unlang] |
| 20 |
---- |
| 21 |
chap |
| 22 |
sql |
| 23 |
---- |
| 24 |
|
| 25 |
== Module Return Codes |
| 26 |
|
| 27 |
When a module is called, it returns one of the following codes to |
| 28 |
the interpreter; the meaning of each code is detailed to the right of |
| 29 |
the source, below: |
| 30 |
|
| 31 |
.Module Return Codes |
| 32 |
|
| 33 |
The below table describes the purpose of the rcodes that may be returned |
| 34 |
by a module call. In this case the 'operation' referenced in the table is |
| 35 |
the current module call. |
| 36 |
|
| 37 |
include::partial$rcode_table.adoc[] |
| 38 |
|
| 39 |
These return codes can be used in a subsequent |
| 40 |
xref:condition/index.adoc[conditional expression] thus allowing policies to |
| 41 |
perform different actions based on the behaviour of the modules. |
| 42 |
|
| 43 |
.Example |
| 44 |
[source,unlang] |
| 45 |
---- |
| 46 |
sql |
| 47 |
if (notfound) { |
| 48 |
update reply { |
| 49 |
Reply-Message = "We don't know who you are" |
| 50 |
} |
| 51 |
reject |
| 52 |
} |
| 53 |
---- |
| 54 |
|
| 55 |
== Module Return Code priority overrides |
| 56 |
|
| 57 |
In the case of modules, rcodes can be modified on a per-call basis. |
| 58 |
|
| 59 |
Module priority overrides are specified in a block inline with the module call. |
| 60 |
The format of an override is `<rcode> = (0+|<rcode>|return)` - That is, |
| 61 |
a number greater than or equal to 0, the priority of another rcode, or the special |
| 62 |
priority `return` which causes the current section to immediately exit. |
| 63 |
|
| 64 |
[source, unlang] |
| 65 |
---- |
| 66 |
ldap { <1> |
| 67 |
fail = 1 <2> |
| 68 |
ok = handled <3> |
| 69 |
reject = return <4> |
| 70 |
} |
| 71 |
---- |
| 72 |
|
| 73 |
<1> Call to the `ldap` module. |
| 74 |
<2> Sets the priority of the `fail` rcode to be `1`. If the priority |
| 75 |
of the rcode for the request is `0`, then the request request rcode |
| 76 |
will be set to `fail` if the module returns `fail`. |
| 77 |
<3> Sets the priority of the `ok` rcode to be whatever the default is for |
| 78 |
`handled` in this section. As the default for `handled` is usually |
| 79 |
`return`. If `ok` is returned, the current section will immediately |
| 80 |
exit. |
| 81 |
<4> Sets the priority of `reject` to be `return`. If the module returns |
| 82 |
`reject`, the current section will immediately exit. |
| 83 |
|
| 84 |
|
| 85 |
// Copyright (C) 2020 Network RADIUS SAS. Licenced under CC-by-NC 4.0. |
| 86 |
// Development of this documentation was sponsored by Network RADIUS SAS. |