genode/repos/gems/run/tresor_utils.run
Norman Feske 2c8beb462f file-system session: root dir via session label
This patch changes the way of how the client-selected sub directory is
communicated to the server. The former opaque session argument is now
passed as last label element, which allows for the flexible tweaking
of this argument by init's session-routing and label-rewriting
mechansims. In particular, it alleviates the need for creating chroot
component instances.

This change requires the following four adaptations at the
configuration level:

- Each file-system session request must now carry a path starting
  with / as last session arguments. Hence, <vfs> <fs> nodes that
  feature a 'label' attributes must extend the attribute value
  with " -> /". For <fs> nodes with no label attribute, "/" is
  used as last label argument by default.

- For matching session-routing rules at init's configuration,
  the matching of full labels should be replaced by 'label_prefix'
  matches, excluding the last (path) argument.

- Wherever a label of a file-system session is rewritten by using
  init's 'label' attribute of a <parent> or <child> target node,
  the new attribute 'identity' should be used instead. This replaces
  the identity part of the label while preserving the client's
  directory argument.

- Analogously to the matching of session-routing rules, server-side
  policy-selection rules that formerly matched a concrete 'label'
  must be changed to match a 'label_prefix' instead.

As a good practice, 'label_prefix' values should end with " ->" if
possible, which clearly delimits the identity part of the label
used by the matching.

Issue #5445
2025-02-24 16:39:20 +01:00

150 lines
4.3 KiB
Plaintext

assert_spec linux
append build_components {
core init timer lib/ld lib/vfs server/lx_block server/lx_fs server/vfs app/sequence
app/tresor_init_trust_anchor app/tresor_init app/tresor_check
lib/vfs_tresor_crypto_aes_cbc lib/vfs_tresor_trust_anchor lib/vfs_jitterentropy
lib/libc lib/libcrypto }
build $build_components
create_boot_directory
append config {
<config verbose="yes">
<parent-provides>
<service name="PD"/>
<service name="ROM"/>
<service name="LOG"/>
<service name="CPU"/>
</parent-provides>
<start name="timer" caps="100" ram="1M">
<provides><service name="Timer"/></provides>
<route>
<service name="PD"> <parent/> </service>
<service name="ROM"> <parent/> </service>
<service name="LOG"> <parent/> </service>
<service name="CPU"> <parent/> </service>
</route>
</start>
<start name="lx_fs" ld="no" caps="100" ram="2M">
<provides> <service name="File_system"/> </provides>
<config> <default-policy root="/" writeable="yes"/> </config>
<route>
<service name="PD"> <parent/> </service>
<service name="ROM"> <parent/> </service>
<service name="LOG"> <parent/> </service>
<service name="CPU"> <parent/> </service>
</route>
</start>
<start name="vfs" caps="120" ram="16M">
<provides><service name="File_system"/></provides>
<config>
<vfs>
<dir name="ta_storage"> <fs/> </dir>
<dir name="dev">
<jitterentropy/>
<tresor_trust_anchor name="tresor_trust_anchor" storage_dir="/ta_storage"/>
</dir>
</vfs>
<default-policy root="/dev/tresor_trust_anchor" writeable="yes"/>
</config>
<route>
<service name="File_system"> <child name="lx_fs"/> </service>
<service name="PD"> <parent/> </service>
<service name="ROM"> <parent/> </service>
<service name="LOG"> <parent/> </service>
<service name="CPU"> <parent/> </service>
</route>
</start>
<start name="sequence" caps="200" ram="128M">
<config>
<start name="tresor_init_trust_anchor" ram="4M">
<config passphrase="foobar" trust_anchor_dir="/trust_anchor">
<vfs> <dir name="trust_anchor"> <fs label="ta -> /"/> </dir> </vfs>
</config>
<route>
<service name="PD"> <parent/> </service>
<service name="ROM"> <parent/> </service>
<service name="LOG"> <parent/> </service>
<service name="CPU"> <parent/> </service>
</route>
</start>
<start name="tresor_init" ram="4M">
<config>
<block-io type="vfs" path="/tresor.img"/>
<crypto path="/crypto"/>
<trust-anchor path="/trust_anchor"/>
<vfs>
<fs buffer_size="1M"/>
<tresor_crypto_aes_cbc name="crypto"/>
<dir name="trust_anchor">
<fs label="ta -> /"/>
</dir>
</vfs>
<virtual-block-device max_lvl="2" degree="64" num_leaves="512" />
<free-tree max_lvl="2" degree="64" num_leaves="2048" />
</config>
<route>
<service name="PD"> <parent/> </service>
<service name="ROM"> <parent/> </service>
<service name="LOG"> <parent/> </service>
<service name="CPU"> <parent/> </service>
</route>
</start>
<start name="tresor_check" caps="100" ram="4M">
<config>
<block-io type="vfs" path="/tresor.img"/>
<crypto path="/crypto"/>
<trust-anchor path="/trust_anchor"/>
<vfs>
<fs buffer_size="1M"/>
<tresor_crypto_aes_cbc name="crypto"/>
<dir name="trust_anchor"> <fs label="ta -> /"/> </dir>
</vfs>
</config>
<route>
<service name="PD"> <parent/> </service>
<service name="ROM"> <parent/> </service>
<service name="LOG"> <parent/> </service>
<service name="CPU"> <parent/> </service>
</route>
</start>
</config>
<route>
<service name="File_system" label_suffix="ta -> /"> <child name="vfs"/> </service>
<service name="File_system"> <child name="lx_fs"/> </service>
<service name="PD"> <parent/> </service>
<service name="ROM"> <parent/> </service>
<service name="LOG"> <parent/> </service>
<service name="CPU"> <parent/> </service>
</route>
</start>
</config>
}
install_config $config
exec rm -rf bin/tresor.img
exec truncate -s 32M bin/tresor.img
append boot_modules [build_artifacts]
lappend boot_modules tresor.img
build_boot_image $boot_modules
run_genode_until {.*child "sequence" exited with exit value 0.*\n} 240