For some component testing, in my C++ testapp on Ubuntu 14.04,
I'd like to rename /sbin/reboot temporarily to prevent my system under test (another big c++ app started inside testapp) from calling
system("/sbin/reboot")
and after the test I want to restore /sbin/reboot
to its full glory.
So on the cmd shell I call
sudo setcap cap_chown,cap_dac_override,cap_setfcap=+ep testapp
in order to enable my testapp to call system("chown user /sbin/reboot")
furthermore system("chgrp developer /sbin/reboot")
and system("mv /sbin/reboot /sbin/reboot.tmp")
But testapp stops with chown: changing ownership of ‘/sbin/reboot’: Operation not permitted
So, what has to be done to enable renaming this particular file from within an app not running sudo?