LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-14-2004, 10:25 AM   #1
KingofBLASH
Member
 
Registered: Sep 2003
Distribution: Just upgraded to Slackware 10.0
Posts: 91

Rep: Reputation: 15
Question Is this a bug? (BASH and Z shells)


Do the following as an underpriviledged user in the bash shell:

Code:
mkdir foo
cd foo
su 
cd ..
rm -fR ./foo
exit
pwd
Under the BASH shell and Z shell I get:
./foo (the directory)

Under tsch, and csh I get:
/usr/bin/ls: foo: No such file or directory

I assume this is a bug in the BASH and Z shells, and tsch and csh handle pwd correctly.

But, I know that you can open a file, delete the file, and have access to an anonymous file (because no inode refers to your inode, or something)

So have I found a bug, or just a peculiar feature of *nix? And is it worth bothering the maintainers of BASH and Z shell about?
 
Old 09-14-2004, 11:30 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
The pwd used in bash is a built-in, the pwd used with (t)csh is the 'real' pwd, there's no pwd built-in in (t)csh.

Try the above, but use /bin/pwd instead of pwd.

I do agree that it's strange the the two are not giving the same output. Cannot find a reason for that, but it must be done with something in mind.
 
Old 09-14-2004, 12:19 PM   #3
KingofBLASH
Member
 
Registered: Sep 2003
Distribution: Just upgraded to Slackware 10.0
Posts: 91

Original Poster
Rep: Reputation: 15
Do you think that I should report it? It seems to me like BASH (or any of the shells) should check when coming back from a su whether or not the directory still exists... I have been thinking about some possible ways to exploit it as a security vulnerability, but I am not smart enough. :-D But still, it seems like it should check....
 
Old 09-14-2004, 01:04 PM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
I don't think it's a bug, but implemented this way with something in mind (still trying to find out what). It is (kinda) known, this from man pwd:

DESCRIPTION
NOTE: your shell may have its own version of pwd which will supercede
the version described here. Please refer to your shell's documentation
for details about the options it supports.


It doesn't say that much, but you are warned that other pwd's (builtins or otherwise) might behave different.

Something that just came to mind:

When executing pwd you are asking for the present working directory, with that in mind:

You could argue that, since you are still in the foo dir, that it is the current working directory. That it is impossible to do (some) things because in reality it doesn't excist anymore could be considered as 'beside the point'.

Personally I can see the logic in that, but feel free to diragree
 
Old 09-14-2004, 06:14 PM   #5
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
I agree with Druuna, though it's only my opinion, and not necessarily the way bash was written.

As far as your user is concerned, you entered foo and never left it....so logically you're still there. You didn't go anywhere else, and you can't be nowhere, so you have to be in foo.
 
  


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
bash scripting problem (bug?) zz9pluralzalpha Linux - Software 2 04-12-2005 01:51 PM
editing /etc/shells to only allow bash omg-ffs Linux - Newbie 3 12-05-2004 03:20 PM
Bash and login shells Adrohak Linux - Software 3 11-18-2004 10:21 AM
wait in bash shells raypen Linux - Software 1 04-18-2003 02:19 PM
bash and other linux shells crealkiller175 Linux - General 9 03-02-2003 03:02 PM


All times are GMT -5. The time now is 03:57 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration