Added [in-progress] Developer Guides
[AGL/documentation.git] / docs / 2_Architecture_Guides / 2.2_Security_Blueprint / 5_Platform / 1.2.5.2_SystemD.md
1 ---
2 title: SystemD
3 ---
4
5 # SystemD
6
7 `afm-system-daemon` is used to:
8
9 - Manage users and user sessions.
10 - Setup applications and services (_CGroups_, _namespaces_, autostart, permissions).
11 - Use of `libsystemd` for its programs (event management, **D-Bus** interface).
12
13 <!-- section-config -->
14
15 Domain             | Object         | Recommendations
16 ------------------ | -------------- | ------------------------------------
17 Platform-SystemD-1 | Security model | Use Namespaces for containerization.
18 Platform-SystemD-2 | Security model | Use CGroups to organise processes.
19
20 <!-- end-section-config -->
21
22 See [systemd integration and user management](http://iot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf) for more information.
23
24 ## Benefits
25
26 - Removal of one privileged process: **afm-user-daemon**
27 - Access and use of high level features:
28
29   - Socket activation.
30   - Management of users and integration of **PAM**.
31   - Dependency resolution to services.
32   - `Cgroups` and resource control.
33   - `Namespaces` containerization.
34   - Autostart of required API.
35   - Permissions and security settings.
36   - Network management.
37
38 <!-- pagebreak -->
39
40 ## CGroups
41
42 Control Groups offer a lot of features, with the most useful ones you can
43 control: Memory usage, how much CPU time is allocated, how much device I/O is
44 allowed or which devices can be accessed. **SystemD** uses _CGroups_ to organise
45 processes (each service is a _CGroups_, and all processes started by that
46 service use that _CGroups_). By default, **SystemD** automatically creates a
47 hierarchy of slice, scope and service units to provide a unified structure for
48 the _CGroups_ tree. With the `systemctl` command, you can further modify this
49 structure by creating custom slices. Currently, in AGL, there are 2 slices
50 (**user.slice** and **system.slice**).
51
52 ## Namespaces
53
54 ### User side
55
56 There are several ways of authenticating users (Key Radio Frequency, Phone,
57 Gesture, ...). Each authentication provides dynamic allocation of **uids** to
58 authenticated users. **Uids** is used to ensure privacy of users and **SMACK**
59 for applications privacy.
60
61 First, the user initiates authentication with **PAM** activation. **PAM**
62 Standard offers highly configurable authentication with modular design like
63 face recognition, Voice identification or with a password. Then users should
64 access identity services with services and applications.