Monday, June 11, 2012

Policy for keeping filenames sane

Have you ever created a file with the name "-rf"?

Or used KDE where a "/" was interpreted as some character that looks like a slash, but is not one? and totally borks your computer?


I would like to create a system-wide policy that does not allow insane filenames to be created.

This potentially means banning look-alike characters.

The complexities in this system would be when including filenames with characters from languages other than English.

We could have a dual file-name system...

And Or we could use the hash of a non-compliant filename.


Basically I want the filesystem to be able to  give an error if a file name starting with a dash, or has a space then a dash, or contains certain reserved words separated by spaces.  If it has a non us-english keyboard character in it..

This could add substantial overhead to some writing operations...  and it could add danger for programs that do not try again if write was unsuccessful.

This program could also save the file regardless, but name it in a compliant fashion.... but it is better to just error out.


3 comments:

Kenneth Parker said...

I go even farther than you, Aaron: No spaces in filenames. (Yes, I know Windows "encourages" spaces, but there are even more reasons I don't like Windows, such as Administrator permissions for untrusted applications).

Thank you and best regards,

Ken Parker (from Linux meetup)

aaron_pet said...

Some links:

http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html

https://blueprints.launchpad.net/apparmor/+spec/filenamepolicykit

aaron_pet said...

@Ken,
Dave Wheeler points out that it is possible to set shell scripts to not include spaces as breaks between files.

I agree with him that spaces are far too common to get rid of :(
He has some good tips to handle them.