Forward slash (/) in filenames.
Hi,
I was wondering if it was at all possible to have a forward slash in a filename under linux or any other unix/unixbased operating system. For obvious reasons it would be illadvised, considering the way directories are separated in linux/unix, but I was just wondering if there was any way to force it, and what might happen if you did. Thanks, Marshall |
No, it is not possible.
|
What would happen if you tried to download a file named as such from a operating system with a filesystem that supported such a name? Would the linux/unix system automatically rename it or crash or try to put it in a directory or what?
|
Lets say the file name is "test/file".
If an application tried to open such a file to write it using the system call open, it would be interpretted as an attempt to open the file "file" in the directory "test". If the directory "test" exists and is writable, then I guess "file" would be created inside "test". If "test" does not exist or it is not possible to create a file within it (e.g. because of the permissions on the directory), the open system call will fail, and the application (if it is written properly) should notify the user of the failure. In some cases I would imagine applications would spot a problem, e.g. in some file selectors where the path and the file name are separate, I would guess some file selectors would simple concatenate the two with a '/' between then - in this case the behavior described above would occur. Some might spot that the file name contains a '/' and complain. That's down to the application and/or GUI framework which is big used. |
There's more than one way to skin a cat:
Code:
$ touch test∕file |
unicode is cheating. :p
|
I suppose the unicode trick wouldn't work because it's not a litteral forward slash. I was actually trying to find a way to say do:
Quote:
Or for example, what stops me from writing a "interpreter" such as perl, bash, awk, whatever owned by my user (because they are not set suid by default anyway) that interprets any suid/sgid script (or even binary) as a command that runs "bash -p" or whatever in suid? |
Slash is an illegal character for a file name, period. It is *the* path component separator in all *nix systems. This is hard coded into the kernel, and utilities, which adhere to this restriction. Ultimately, all pathnames are passed to system calls, where the kernel does path component splitting using forward slashes as the separator.
|
Quote:
Of course your users can't do that since you have to be the user setting the flag. (Without that restriction the permission model would be meaningless.) So, bottom line, was your question about the *NIX security model? There are books on that subject, and, of course, the NSA-instigated "SELinux" project which can raise the security level of Linux to "military-grade" security if you use it. |
I wondered the same...
at Dolphin when I make a folder with a slash as part of a filename it automatically converts it to a fraction slash (Unicode 0x2044).*Any other attempt of forcing a folder with a solidus as part of its name (renaming a folder, having a folder with the three different kinds of slashes as name) will throw some error. |
Quote:
|
All times are GMT -5. The time now is 04:34 PM. |