Kernel Hacks & Weird Filenames
gordon at sneaky.UUCP
gordon at sneaky.UUCP
Sun May 15 15:11:00 AEST 1988
To all the proponents of hacking the kernel and/or the shell to protect the
user from wierd file names:
Please do the world a favor and limit your "file-name sanity protection"
to creation of files. Do not prohibit opening files with strange characters
in their names. And especially, do not prohibit deleting them. And
yes, I mean permit this kind of access regardless of what the
user says his terminal is capable of. (By the way, what kind of terminal
does cron use?)
Yes, I know this messes up the obvious place to put the check in namei().
If doing it right is too complicated, maybe checking it at all is too
complicated?
Most of the problem is caused by the fact that the characters in the filename
are treated specially. Don't mess things up worse by making all "funny"
characters as bad as embedded nulls or '/' characters in a directory entry.
Right now, there are several types of special characters that cause
problems because they are special, the worst ones first:
'\0' and '/': If you get these embedded in a filename, you have to go
in through the disk device. How did these ever get into
a file name? Ever have disk errors? Overheated memory?
Buggy programs that access disk devices? Administrators
that run disk-patch programs and goof? Boot up after a crash
with a scrambled free list and forget to/decide not to fsck?
characters with the high bit on: on those systems where the shell strips
high bit from filenames, use "rm -ri ." (not "rm -ri *"), to avoid
letting the shell get its hands on the name. On other systems,
these characters are merely unreadable and/or untypable.
unprintable characters you can't read: 'od' the directory (easiest on SysV
systems), or use ls | cat -v to figure out what the name is.
Also, if the characters are just invisible (as opposed to 'clear
screen' or something), "rm -ri ." or rm -i with shell metacharacters
filling in for the unprintable ones can work.
untypable characters: use "rm -ri .", or rm -i with shell metacharacters
to match the offending filename.
shell metacharacters: use backslashes to quote the metacharacters and
backslashes. (This may vary with what shell you are using. Also,
using single quotes may be easier.)
'-': if it's the first character, prefix ./ to the filename.
By the way, I know there are lots of programs around like "rmfile" that
may make the job easier. "rm" is pretty standard on UN*X/Xen*x systems
and "rmfile", etc. aren't.
Gordon Burditt
...!ihnp4!sys1!sneaky!gordon
P.S. How long before /bin/shell is an illegal filename for English-speaking
users only, because of the embedded cussword?
More information about the Comp.unix.wizards
mailing list