4

I've noticed that when I mount a FAT filesystem on Linux, all of the files have their executable permissions set. Why is this? There's almost no chance that you can or want to directly execute any program found on a FAT file system, and having the executable bit implicitly set for all files seems annoying to me.

I understand that FAT (and other filesystems as well) have no mode bits, and so the 777 mode I'm seeing on files is just simulated by the filesystem driver under Unix. My question is why 777 instead of 666?

closed as primarily opinion-based by Thomas Dickey, Julie Pelletier, Stephen Harris, Anthon, Archemar Sep 6 '16 at 9:24

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Possible duplicate of can't change file permission – Thomas Dickey Sep 6 '16 at 0:57
  • No, I know that FAT has no mode bits, and that's why I can't change them. What I'm asking is why is Unix simulating mode 777 for files instead of 666? I'll try to make my question more clear. – Edward Falk Sep 6 '16 at 0:59
  • 2
    It's to allow executing them if you wanted to. Why would you decide to prevent anyone from running Unix programs on a FAT FS? It may not be ideal but it can surely work. – Julie Pelletier Sep 6 '16 at 1:03
  • 2
    Wow, downvoted to -3. Hint: Grab a Peer Pressure badge... – countermode Sep 6 '16 at 7:59
  • 1
    Meh, it's all just ones and zeros anyway. I see they've tagged this for closure as an "opinion" item. That wasn't my intent; I was wondering if there was an actual technical reason for it. As for peer pressure, I don't give into it, but then, I'm part of a social groups that frowns on that. (Actually, since I couldn't find an answer to my question via Google et al, I still think it was a fair question.) – Edward Falk Sep 6 '16 at 15:58
9

FAT may not be a POSIX-style filesystem, that doesn't mean that you shouldn't be allowed to store executables on it and run them directly from it. Because FAT doesn't store POSIX permissions, the only way this can happen (easily) is if the default mode used for files allows their execution...

In the past, when (V)FAT was still used as the main filesystem for other operating systems (DOS and Windows), and hard drives were smaller, it wasn't unusual to store Unix/Linux binaries on a FAT filesystem. (There's even a FAT variant which stores POSIX attributes in special files, so you could run Linux on a FAT filesystem.) Nowadays you can still end up doing so on USB keys for exemple.

If you're worried about the security implications, there are a number of options you can use. noexec and nodev are probably already set for removable filesystems on your distribution; dmask and fmask allow you to specifically determine the modes used. showexec will only set the executable bits on files with .bat, .com or .exe extensions. (Note that a file's permissions and the ability to execute it are separate...)

  • OK, so bottom line: it is because someone just might want to execute a program from a FAT file system. – Edward Falk Sep 17 '16 at 21:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.