LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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.

Notices


Reply
  Search this Thread
Old 08-24-2008, 10:02 AM   #1
Oxagast
Member
 
Registered: Aug 2003
Location: Mocksville, NC, USA
Distribution: Gentoo, Slackware.
Posts: 410

Rep: Reputation: 30
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
 
Old 08-24-2008, 10:05 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
No, it is not possible.
 
Old 08-24-2008, 10:12 AM   #3
Oxagast
Member
 
Registered: Aug 2003
Location: Mocksville, NC, USA
Distribution: Gentoo, Slackware.
Posts: 410

Original Poster
Rep: Reputation: 30
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?
 
Old 08-24-2008, 10:36 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
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.
 
Old 08-24-2008, 11:24 AM   #5
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
There's more than one way to skin a cat:
Code:
$ touch test∕file

$ file test∕file
test∕file: empty

$ echo Test >test∕file

$ ls -l$ ls -l
total 64
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. Reason: Typo
 
Old 08-24-2008, 11:40 AM   #6
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
unicode is cheating.
 
Old 08-24-2008, 02:21 PM   #7
Oxagast
Member
 
Registered: Aug 2003
Location: Mocksville, NC, USA
Distribution: Gentoo, Slackware.
Posts: 410

Original Poster
Rep: Reputation: 30
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:
$ ls -al blah.sh
-rwsr-xr-x 1 root root 16 2008-08-24 11:08 blah.sh
$ cat blah.sh
#!/bin/bash
$ id
uid=1000(oxagast) gid=100(users)
$ cat "#!/bin/bash"
/bin/bash -p
$ ./"#!/bin/bash"
$ id
uid=1000(oxagast) gid=100(users) euid=0(root)
or something to that effect.

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?

Last edited by Oxagast; 08-24-2008 at 02:33 PM.
 
Old 08-24-2008, 05:08 PM   #8
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
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.
 
Old 08-26-2008, 08:20 AM   #9
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Quote:
Originally Posted by Oxagast View Post
<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.
 
Old 07-21-2009, 06:34 PM   #10
Nethac DIU
LQ Newbie
 
Registered: Jul 2009
Posts: 1

Rep: Reputation: 0
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.
 
Old 07-21-2009, 09:04 PM   #11
GaijinPunch
Member
 
Registered: Aug 2003
Location: Tokyo, Japan
Distribution: Gentoo
Posts: 130

Rep: Reputation: 22
Quote:
and what might happen if you did.
You would be, at minimum, laughed at by your peers.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
question mark and forward slash osc~ Slackware 2 08-16-2007 12:32 PM
Script to convert DOS backslash to UNIX forward slash pro_chandan Linux - Software 1 10-24-2006 10:09 AM
forward slash being treated as escape character in shell? debiant Linux - General 1 07-19-2006 04:57 PM
Basic difference between / (slash) and /root (slash root) ? tofee Linux - Newbie 2 03-24-2006 04:04 AM
Forward slashes in filenames. Convert from 2f to Colon chrisk5527 Linux - General 3 03-26-2004 03:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration