Commit 78cf869b authored by anonym's avatar anonym

Unload modules using modprobe -r (kmod) instead of rmmod.

Will-fix: #10430
parent e330cea6
......@@ -82,7 +82,5 @@ mod_rev_dep() {
# Unloads module $1, and all modules that (transatively) depends on
# $1 (i.e. its reverse dependencies).
unload_module_and_rev_deps() {
for mod in $(mod_rev_dep ${1}); do
/sbin/rmmod ${mod}
/sbin/modprobe -r $(mod_rev_dep ${1})
......@@ -57,8 +57,24 @@ end
Given /^MAC spoofing will fail, and the module cannot be unloaded$/ do
step "macchanger will fail by not spoofing and always returns true"
$vm.execute_successfully("mv /sbin/rmmod /sbin/rmmod.orig")
$vm.execute_successfully("ln -s /bin/false /sbin/rmmod")
# Note that the real /sbin/modprobe is a symlink to /bin/kmod, and
# for it to run in modprobe compatibility mode the name must be
# exactly "modprobe", so we just move it somewhere our of the path
# instead of renaming it ".real" or whatever we usuablly do when
# diverting executables for wrappers.
modprobe_divert = "/usr/local/lib/modprobe"
"dpkg-divert --add --rename --divert '#{modprobe_divert}' /sbin/modprobe"
fake_modprobe_wrapper = <<EOF
if echo "${@}" | grep -q -- -r; then
exit 1
exec '#{modprobe_divert}' "${@}"
$vm.file_append('/sbin/modprobe', fake_modprobe_wrapper)
$vm.execute_successfully("chmod a+rx /sbin/modprobe")
When /^see the "Network card disabled" notification$/ do
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment