mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-30 10:38:55 +00:00
ca971bbfd8
This patch changes the top-level directory layout as a preparatory step for improving the tools for managing 3rd-party source codes. The rationale is described in the issue referenced below. Issue #1082
104 lines
2.5 KiB
Plaintext
104 lines
2.5 KiB
Plaintext
#
|
|
# \brief Test for assigning custom UIDs and GIDs to Genode processes
|
|
# \author Norman Feske
|
|
# \date 2012-11-21
|
|
#
|
|
|
|
build "core init test/printf"
|
|
|
|
assert_spec linux
|
|
|
|
create_boot_directory
|
|
|
|
install_config {
|
|
<config>
|
|
<parent-provides>
|
|
<service name="LOG"/>
|
|
<service name="RAM"/>
|
|
<service name="CAP"/>
|
|
<service name="PD"/>
|
|
<service name="RM"/>
|
|
<service name="CPU"/>
|
|
<service name="ROM"/>
|
|
<service name="SIGNAL"/>
|
|
</parent-provides>
|
|
<default-route>
|
|
<any-service><parent/></any-service>
|
|
</default-route>
|
|
|
|
<start name="init_55_66" uid="55" gid="66">
|
|
<binary name="init" />
|
|
<resource name="RAM" quantum="1M"/>
|
|
<config/>
|
|
</start>
|
|
|
|
<!-- we expect the GID of init_77 to equal the UID -->
|
|
<start name="init_77" uid="77">
|
|
<binary name="init" />
|
|
<resource name="RAM" quantum="1M"/>
|
|
<config>
|
|
<parent-provides>
|
|
<service name="LOG"/>
|
|
<service name="CAP"/>
|
|
<service name="ROM"/>
|
|
<service name="SIGNAL"/>
|
|
</parent-provides>
|
|
<default-route>
|
|
<any-service><parent/></any-service>
|
|
</default-route>
|
|
|
|
<!-- we expect the GID and UID of init_sub_77 to inherit
|
|
its UID and GIDs from its parent policy. -->
|
|
<start name="init_sub_77">
|
|
<binary name="init" />
|
|
<resource name="RAM" quantum="1M"/>
|
|
<config/>
|
|
</start>
|
|
</config>
|
|
</start>
|
|
</config>
|
|
}
|
|
|
|
#
|
|
# Copy boot modules into run directory
|
|
#
|
|
# We cannot use the predefined 'build_boot_image' function here because
|
|
# this would create mere symlinks. However, we need to enable the setuid
|
|
# and setgid capabilities for core, which won't work if core were a symlink.
|
|
#
|
|
foreach binary { core init } {
|
|
exec cp -H bin/$binary [run_dir] }
|
|
|
|
#
|
|
# Allow core to set arbitrary UIDs and GIDs
|
|
#
|
|
exec sudo setcap cap_setuid,cap_setgid=ep [run_dir]/core
|
|
|
|
#
|
|
# Execute Genode until the point where init_sub_77 is up
|
|
#
|
|
run_genode_until {\[init -> init_77 -> init_sub_77\].*No children to start.*\n} 10
|
|
|
|
#
|
|
# Obtain the list of Genode user processes starting with the name 'init'
|
|
#
|
|
set ps_output [exec ps -eo uid,gid,cmd | grep Genode | grep init]
|
|
|
|
puts "Genode user processes:\n$ps_output"
|
|
|
|
#
|
|
# Validate output of ps
|
|
#
|
|
# We are only interested in the lines for the init instances with the
|
|
# customized UIDs and GIDs.
|
|
#
|
|
if {![regexp {55\s*66 \[Genode\] init_55_66} $ps_output]
|
|
|| ![regexp {77\s*77 \[Genode\] init_77} $ps_output]
|
|
|| ![regexp {77\s*77 \[Genode\] init_77 -> init_sub_77} $ps_output]} {
|
|
puts stderr "Unexpected output of ps"
|
|
exit 1
|
|
}
|
|
|
|
puts "Test succeeded"
|
|
|