The entry rights
The source src/modules/demonstrations/rights built with the setting DRAWING_THROUGH_MODULE=true. The text after this paragraph is the comment of that source.
A demonstration of rights on handles: a process holds only the handles that it was given, and only with the rights that it was given.
The root service gives this process two handles, each with a part of its rights: the machine with Inspect, the boot image with Read. The process asks the kernel for nine operations. The window shows each answer of the kernel: the kernel refuses each operation that needs another right.
What it is for. It shows that a right is part of a handle, and that the kernel checks it on each operation: holding the machine is not holding all of it. A handle that the process creates itself has each right, so the process is not crippled for its own work.
The nine operations, with the answer that the kernel must give:
- read the report of the machine (Inspect): allowed;
- create a handle to the ports of the keyboard:
No_Right; - stop the machine:
No_Right; - map the boot image to read it: allowed;
- map it to write in it, or to execute it:
No_Right; - give the boot image to the compositor:
No_Right, because the handle has no right Give; - create memory and write in it: allowed;
- start a thread and read its state: allowed.
Start: start("rights") in the console, or the bar of the desktop.
Grants, as the root service gives them:
- Inspect: the machine, with the right Inspect only.
- Image: the boot image, with the right Read only.
What a reader sees: the two handles, then one row for each operation with the answer of the kernel; an unexpected answer is in another color. The log has "rights: ok, 4 allowed, 5 refused", or "rights: wrong answer: ..." for each unexpected answer.
rights module with an entry
- Hash
a054f74c46773d0fc6869cee67ba959ef54ec7a295c50508857bfeb0f319a425- Size
149327 bytes- Exports
0- Imports
1- Imported by
0- License
- MIT
A demonstration of rights on handles: a process holds only the handles that it was given, and only with the rights that it was given
| Fact | Value |
|---|---|
| Kind | Modules with an entry |
| Source | src/modules/demonstrations/rights |
| Boot image | yes: in the boot image, 149327 bytes in this build |
| Build settings |
|
| Imports | |
| Imported by | none |
Neighbours
What it imports, at its left, and what imports it, at its right: the part of the module graph that touches it.
Exports
| Export | What it does |
|---|---|
entry() | The entry of rights: it asks the kernel for the nine operations once, writes the result, then shows the table until the principal closes the window |
entry
entry()
The entry of rights: it asks the kernel for the nine operations once, writes the result, then shows the table until the principal closes the window.
With no window it stops with Failed. Each operation is noted with the status that the kernel gave and the status that it must give.
- Form
- The entry of the module: one parameter, an address, fixed by the contract.
src/modules/demonstrations/rights/main.odin:116
Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).
What the root service gives it
| What | Value | As the root service says |
|---|---|---|
| Grants | It shows what the kernel refuses. | |
| Other terms of its start grant set | none | |
| Budget that it asks for |
| The working memory: the rest of the pages that the root service gave it by its name, once the tool counts its module, its threads and its window: 1554 pages. And the glyph memory of the copy of the text rendering of the drawing module, which draws its text: 354 pages (display.TEXT_MEMORY_PAGES). 1554 + 354 = 1908. |
The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).
