tests: allow overriding `mount` for mounting sysfs in the mount NS
On my NixOS, `mount` is a SUID wrapper which fails in a user NS with our
UID mapping, like this:
Assertion `!(st.st_mode & S_ISUID) || (st.st_uid == geteuid())` in NixOS's wrapper.c failed.
That's because in the created NS, the `/run/wrappers/bin/mount` appears
to be owned by `nobody:nogroup`. Fortunately, there's also the
`/run/current-system/sw/bin/mount` which does not involve any fancy
wrappers. So just let me pass
`-DMOUNT_EXECUTABLE=/run/current-system/sw/bin/mount` in my local build
script.
Bug: https://github.com/NixOS/nixpkgs/issues/42117#issuecomment-974194691
Change-Id: If5c601981c69bc179e5e413cc6692a56db65529d
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f7ce978..0de69ec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -446,6 +446,7 @@
velia_test(NAME sysrepo_system-ietfinterfaces LIBRARIES velia-system FIXTURE fixture_sysrepo-czechlight-network)
find_program(UNSHARE_EXECUTABLE unshare REQUIRED)
+ find_program(MOUNT_EXECUTABLE mount REQUIRED)
pkg_get_variable(SR_GROUP sysrepo SR_GROUP)
if (SR_GROUP)
set(UNSHARE_MAP_GROUP_ARG "--map-group=${SR_GROUP}")
@@ -453,7 +454,7 @@
set(UNSHARE_MAP_GROUP_ARG "")
endif()
velia_test(NAME sysrepo_system-ietfinterfaces-sudo LIBRARIES velia-system FIXTURE fixture_sysrepo-czechlight-network
- COMMAND ${UNSHARE_EXECUTABLE} --net --mount --map-root-user ${UNSHARE_MAP_GROUP_ARG} sh -c "set -ex $<SEMICOLON> mount -t sysfs none /sys $<SEMICOLON> ./test-sysrepo_system-ietfinterfaces-sudo")
+ COMMAND ${UNSHARE_EXECUTABLE} --net --mount --map-root-user ${UNSHARE_MAP_GROUP_ARG} sh -c "set -ex $<SEMICOLON> ${MOUNT_EXECUTABLE} -t sysfs none /sys $<SEMICOLON> ./test-sysrepo_system-ietfinterfaces-sudo")
set(fixture_sysrepo-ietf-hardware YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/iana-hardware@2018-03-13.yang YANG ${CMAKE_CURRENT_SOURCE_DIR}/yang/ietf-hardware@2018-03-13.yang FEATURE hardware-sensor)
velia_test(NAME hardware_ietf-hardware LIBRARIES velia-ietf-hardware velia-ietf-hardware-sysrepo FsTestUtils FIXTURE fixture_sysrepo-ietf-hardware)