Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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.
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?
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.
$ touch test∕file$ file test∕file
$ echo Test >test∕file$ ls -l$ ls -l
drwxr-xr-x 60 Peter Peter 4096 2008-08-19 08:28 Books
drwxr-xr-x 2 Peter Peter 4096 2008-08-18 03:31 Desktop
drwxr-xr-x 2 Peter Peter 4096 2008-08-19 08:28 Documents
drwxr-xr-x 9 Peter Peter 4096 2008-08-20 15:00 Downloads
drwxrwxr-x 5 Peter Peter 4096 2008-08-19 15:10 iMacros
-rw-rw-r-- 1 Peter Peter 11927 2008-08-22 06:10 maxout.gnuplot_pipes
drwxr-xr-x 6 Peter Peter 4096 2008-08-19 08:29 Pictures
drwxrwxr-x 3 Peter Peter 4096 2008-08-20 11:41 Scripts
-rw-rw-r-- 1 Peter Peter 5 2008-08-24 09:30 test∕file
drwxr-xr-x 2 Peter Peter 20480 2008-08-19 08:29 Wallpapers
$ file test∕file
test∕file: ASCII text
$ ls test
ls: cannot access test: No such file or directory
My secret? That's not a /, it's a unicode character that displays as a /.
Last edited by PTrenholme; 08-24-2008 at 11:36 AM.
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.
<snip>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?
If that's all you wanted to do, look at the chmod command. You can set the s flag on an executable so that executable will run with the permissions of the user setting the flag. So you, as root, could write the interpreter and let your users run it.
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.
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.