|
10 | 10 | # Fixture `path` is relative to {{ cdi_fixture_root }}/scenarios. Types: |
11 | 11 | # dir directory (parents must be declared first) |
12 | 12 | # file regular file with `content` |
13 | | -# Both accept `mode`, `owner` and `group`. |
| 13 | +# fifo named pipe |
| 14 | +# chardev character device with `major` and `minor` |
| 15 | +# All accept `mode`, `owner` and `group`. |
14 | 16 | # |
15 | 17 | # `expect` records the behavior the CDI feature tests assert for the scenario, |
16 | 18 | # and is rendered to {{ cdi_fixture_root }}/scenarios.json for them. It states |
@@ -72,3 +74,152 @@ cdi_scenarios: |
72 | 74 | checks: |
73 | 75 | - {type: contents, path: /usr/share/tmachine-cdi/baseline-read-only-file, expect: tmachine-cdi-baseline-read-only-file} |
74 | 76 | - {type: write, path: /usr/share/tmachine-cdi/baseline-read-only-file, expect: denied} |
| 77 | + |
| 78 | + - name: read-only-file |
| 79 | + fixtures: |
| 80 | + - {path: read-only-file, type: file, content: "tmachine-cdi-read-only-file\n", mode: "0644"} |
| 81 | + edits: |
| 82 | + mounts: |
| 83 | + - hostPath: "{{ cdi_scenario_dir }}/read-only-file" |
| 84 | + containerPath: /tmachine-cdi/read-only/file |
| 85 | + options: [bind, ro] |
| 86 | + expect: |
| 87 | + checks: |
| 88 | + - {type: filetype, path: /tmachine-cdi/read-only/file, expect: file} |
| 89 | + - {type: read, path: /tmachine-cdi/read-only/file, expect: denied} |
| 90 | + - {type: write, path: /tmachine-cdi/read-only/file, expect: denied} |
| 91 | + |
| 92 | + - name: read-only-directory |
| 93 | + fixtures: |
| 94 | + - {path: read-only-directory, type: dir, mode: "0755"} |
| 95 | + - {path: read-only-directory/marker, type: file, content: "tmachine-cdi-read-only-directory/marker\n", mode: "0644"} |
| 96 | + edits: |
| 97 | + mounts: |
| 98 | + - hostPath: "{{ cdi_scenario_dir }}/read-only-directory" |
| 99 | + containerPath: /tmachine-cdi/read-only/directory |
| 100 | + options: [bind, ro] |
| 101 | + expect: |
| 102 | + checks: |
| 103 | + - {type: filetype, path: /tmachine-cdi/read-only/directory, expect: directory} |
| 104 | + - {type: read, path: /tmachine-cdi/read-only/directory/marker, expect: denied} |
| 105 | + - {type: write, path: /tmachine-cdi/read-only/directory/marker, expect: denied} |
| 106 | + - {type: write, path: /tmachine-cdi/read-only/directory/new-file, expect: denied} |
| 107 | + |
| 108 | + # Both library cases bind the same file; they differ in whether its parent |
| 109 | + # directory is narrow or the container root. |
| 110 | + |
| 111 | + - name: library-parent |
| 112 | + fixtures: |
| 113 | + - {path: libfixture.so.1, type: file, content: "tmachine-cdi-libfixture.so.1\n", mode: "0644"} |
| 114 | + edits: |
| 115 | + mounts: |
| 116 | + - hostPath: "{{ cdi_scenario_dir }}/libfixture.so.1" |
| 117 | + containerPath: /tmachine-cdi/library/libfixture.so.1 |
| 118 | + options: [bind, ro] |
| 119 | + expect: |
| 120 | + checks: |
| 121 | + - {type: filetype, path: /tmachine-cdi/library/libfixture.so.1, expect: file} |
| 122 | + - {type: read, path: /tmachine-cdi/library/libfixture.so.1, expect: denied} |
| 123 | + - {type: write, path: /tmachine-cdi/library/libfixture.so.1, expect: denied} |
| 124 | + |
| 125 | + - name: broad-library-parent |
| 126 | + edits: |
| 127 | + mounts: |
| 128 | + - hostPath: "{{ cdi_scenario_dir }}/libfixture.so.1" |
| 129 | + containerPath: /libtmachinefixture.so.1 |
| 130 | + options: [bind, ro] |
| 131 | + expect: |
| 132 | + checks: |
| 133 | + - {type: filetype, path: /libtmachinefixture.so.1, expect: file} |
| 134 | + - {type: read, path: /libtmachinefixture.so.1, expect: denied} |
| 135 | + - {type: write, path: /libtmachinefixture.so.1, expect: denied} |
| 136 | + |
| 137 | + - name: writable-file |
| 138 | + fixtures: |
| 139 | + - {path: writable-file, type: file, content: "tmachine-cdi-original\n", mode: "0666"} |
| 140 | + edits: |
| 141 | + mounts: |
| 142 | + - hostPath: "{{ cdi_scenario_dir }}/writable-file" |
| 143 | + containerPath: /tmachine-cdi/writable/file |
| 144 | + options: [bind, rw] |
| 145 | + expect: |
| 146 | + checks: |
| 147 | + - {type: filetype, path: /tmachine-cdi/writable/file, expect: file} |
| 148 | + - {type: read, path: /tmachine-cdi/writable/file, expect: denied} |
| 149 | + - {type: write, path: /tmachine-cdi/writable/file, expect: denied} |
| 150 | + |
| 151 | + - name: writable-directory |
| 152 | + fixtures: |
| 153 | + - {path: writable-directory, type: dir, mode: "0777"} |
| 154 | + edits: |
| 155 | + mounts: |
| 156 | + - hostPath: "{{ cdi_scenario_dir }}/writable-directory" |
| 157 | + containerPath: /tmachine-cdi/writable/directory |
| 158 | + options: [bind, rw] |
| 159 | + expect: |
| 160 | + checks: |
| 161 | + - {type: filetype, path: /tmachine-cdi/writable/directory, expect: directory} |
| 162 | + - {type: write, path: /tmachine-cdi/writable/directory/probe, expect: denied} |
| 163 | + |
| 164 | + - name: omitted-access-file |
| 165 | + edits: |
| 166 | + mounts: |
| 167 | + - hostPath: "{{ cdi_scenario_dir }}/writable-file" |
| 168 | + containerPath: /tmachine-cdi/writable/omitted-access |
| 169 | + options: [bind] |
| 170 | + expect: |
| 171 | + checks: |
| 172 | + - {type: filetype, path: /tmachine-cdi/writable/omitted-access, expect: file} |
| 173 | + - {type: read, path: /tmachine-cdi/writable/omitted-access, expect: denied} |
| 174 | + - {type: write, path: /tmachine-cdi/writable/omitted-access, expect: denied} |
| 175 | + |
| 176 | + - name: device-node |
| 177 | + edits: |
| 178 | + deviceNodes: |
| 179 | + - path: /dev/tmachine-cdi-null |
| 180 | + hostPath: /dev/null |
| 181 | + permissions: rw |
| 182 | + expect: |
| 183 | + checks: |
| 184 | + - {type: filetype, path: /dev/tmachine-cdi-null, expect: character-device} |
| 185 | + - {type: non-root} |
| 186 | + - {type: write, path: /dev/tmachine-cdi-null, expect: denied} |
| 187 | + |
| 188 | + # The device is mode 0660 with a group that only `additionalGids` grants. |
| 189 | + - name: device-node-with-gid |
| 190 | + fixtures: |
| 191 | + - {path: group-device, type: chardev, major: 1, minor: 3, mode: "0660", group: openshell-cdi-fixture} |
| 192 | + edits: |
| 193 | + additionalGids: ["{{ cdi_fixture_group.gid | int }}"] |
| 194 | + deviceNodes: |
| 195 | + - path: /dev/tmachine-cdi-group-null |
| 196 | + hostPath: "{{ cdi_scenario_dir }}/group-device" |
| 197 | + permissions: rw |
| 198 | + uid: 0 |
| 199 | + gid: "{{ cdi_fixture_group.gid | int }}" |
| 200 | + fileMode: 432 |
| 201 | + expect: |
| 202 | + checks: |
| 203 | + - {type: filetype, path: /dev/tmachine-cdi-group-null, expect: character-device} |
| 204 | + - {type: non-root} |
| 205 | + - {type: in-group-of, path: /dev/tmachine-cdi-group-null} |
| 206 | + - {type: write, path: /dev/tmachine-cdi-group-null, expect: denied} |
| 207 | + |
| 208 | + # The echo socket is served by the systemd service installed in scenarios.yaml. |
| 209 | + # Its sibling file checks that only the socket path is exposed. |
| 210 | + |
| 211 | + - name: unix-socket |
| 212 | + fixtures: |
| 213 | + - {path: socket, type: dir, mode: "0755"} |
| 214 | + - {path: socket/sibling, type: file, content: "tmachine-cdi-socket/sibling\n", mode: "0644"} |
| 215 | + edits: |
| 216 | + mounts: |
| 217 | + - hostPath: "{{ cdi_scenario_dir }}/socket/echo.sock" |
| 218 | + containerPath: /tmachine-cdi/socket/echo.sock |
| 219 | + options: [bind] |
| 220 | + expect: |
| 221 | + checks: |
| 222 | + - {type: filetype, path: /tmachine-cdi/socket/echo.sock, expect: socket} |
| 223 | + # Only the socket is mounted, so its sibling in the host directory is |
| 224 | + # not visible. Connecting to the socket is not checked yet. |
| 225 | + - {type: exists, path: /tmachine-cdi/socket/sibling, expect: false} |
0 commit comments