# # \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 { } # # 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 ld.lib.so 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"