8

install hfs /bin/true

in /etc/modprobe.d/hfs.conf supposedly disables hfs

Why? Seems backwards.

4
  • 1
    Did you read this somewhere? On the Internet? Please show where you found it. Jun 16, 2020 at 23:21
  • 1
    @michael-hampton cyberciti.biz/faq/linux-disable-mounting-of-uncommon-filesystem is the main one, but not the only one. Wikipedia suggests primitives are a way to disable also: en.wikipedia.org/wiki/Modprobe Jun 17, 2020 at 12:32
  • 1
    OK, that's pretty stupid. You should just blacklist a module you don't want. You shouldn't do things that confuse people when there is a clear and straightforward way of doing it. Jun 17, 2020 at 17:15
  • 4
    Please note that blacklisting is very weak. User space has to OPT IN to respect the blacklist by passing -b to modprobe. Without -b switch, modprobe will ignore the blacklist. Using install hfs /bin/true is actually the stronger way to do it. It's very counter intuitive. Aug 11, 2021 at 9:43

1 Answer 1

8

According to the modprobe.d(5) man page:

install modulename command...

This is the most powerful primitive: it tells modprobe to run your command instead of inserting the module in the kernel as normal.

So you are basically saying the kernel "Hey, if you ever want to insert the hfs module, just run /bin/true instead of the command you would have run. It will insert and configure the module, honest."

4
  • Thank you, sir. This beats the find command for least intuitive semantic design. Wouldn't /bin/false better tell the user, "Hey, you tried to use hfs, and that's just not what we do here. So we say false, did not complete, unsuccessful." Jun 17, 2020 at 13:03
  • 2
    It might be better to tell the user what is going on here, however, it is a poor choice to tell the kernel about it. Since /bin/false is always unsuccessful, modprobe would always think that loading the module has failed. It should be also noted that this approach is is kind of a hack: you could simply write blacklist hfs in the config, which would disable the module, and is straightforward.
    – Lacek
    Jun 17, 2020 at 13:14
  • 1
    That is the right way to do this. Thank you. I'll switch to the blacklist method, which should be blocklist very soon to not offend people of color. BLM Jun 17, 2020 at 17:38
  • 3
    Per Redhat, this only disables loading on boot. It doesn't prevent intentionally using insmod or modprobe to load a module, or from loading a module through a dependency. So you also have to add "install hfs /bin/false" to the config to disable these use cases. Ref: access.redhat.com/solutions/41278#rhel7only Jun 18, 2020 at 15:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .