[net.unix-wizards] unix quirks

argv@ucb-vax.ARPA (04/13/85)

    >>% mkdir foo
    >>% chmod 000 foo
    >>% cd foo
    >>foo: no such file or directory
    >>% WHAT?
    >>no match.
    
    >I assume you are surprised by by the fact that shutting off the
    >permissions to a directory you own makes it impossible for you
    >to change to it. That's not a quirk, that's a bona-fide feature.
    >What else could turning off your own permissions mean? Why have
    >them? I personally find this a real plus under UNIX in general,
    >it's *nice* to be able to protect me from me as usually my files
    >are in the gravest danger from *me*.
    
   
You don't seem to understand: it shouldn't say: "no such file or directory",
it should say: "Permission denied."  The example, was just that, an example.
This "bug" appears all the time whenever the permission is denied, it comes
up with the wrong error message! Try to cd into a path that you never had
any problems with and it says that it doesn't even EXIST. Then you panic and
call the system administrator and request a back up recovery and spend a
lot of time and effort (sometimes even money) to get a directory replaced
that never even went away. I just want the correct error message. Is this
clear now?


						Dan Heller (aka Frank)
------------------------------------------------------------------------------
		UCSC Computing Center Consultant
      (Looking for a UNIX/C hacking Job - nudge nudge wink wink)

UUCP:    ucbvax!ucscc!argv  {ihnp4,sun,cbosgd,decwrl}!qubix!ucscc!argv
ARPA:    argv%ucscc.uucp@ucb-vax.arpa
CSnet:   c.argv@ucsc.csnet

                   (say no more, say no more)
-------------------------------------------------------------------------------

mfe@leadsv.UUCP (Mark Ellson) (04/16/85)

In his article, ucscc!argv (Dan Heller) argues that the appropriate error
message when you try to change directory into a directory for which you don't
have permissions is "Permission denied" instead of "no such file or
directory".  In fact, while this may be clearer to the user, it falls in the
same general category as not using "Incorrect password" or "Incorrect
username" for failed logins.  You never want to tell a potential intruder or
unauthorized user any information which can be used to infer the existence
or nonexistence of a protected object.

A possible exception to this rule might be if the software is smart
enough to check the ownership of the directory, and then generate the
appropriate error message based upon whether or not you are the owner of
that directory.

					Mark Ellson
					{amdcad!cae780, sun!sunncal}!leadsv!mfe

tmb@talcott.UUCP (Thomas M. Breuel) (04/19/85)

> have permissions is "Permission denied" instead of "no such file or
> directory".  In fact, while this may be clearer to the user, it falls in the
> same general category as not using "Incorrect password" or "Incorrect
> username" for failed logins.  You never want to tell a potential intruder or
> unauthorized user any information which can be used to infer the existence
> or nonexistence of a protected object.

That's hardly an argument. A simple 'ls -l' will reveal the whole truth
to the 'intruder'. I suspect that someone was lazy when writing the code
and inferred from an error return code from 'chdir' that the target does
not exist.

							Thomas.

jimb@amdcad.UUCP (Jim Budler) (04/21/85)

In article <9938@brl-tgr.ARPA> argv@ucb-vax.ARPA writes:
>
>    >>% mkdir foo
>    >>% chmod 000 foo
>    >>% cd foo
>    >>foo: no such file or directory
>You don't seem to understand: it shouldn't say: "no such file or directory",
>it should say: "Permission denied."  The example, was just that, an example.
>This "bug" appears all the time whenever the permission is denied, it comes
>up with the wrong error message! Try to cd into a path that you never had
>any problems with and it says that it doesn't even EXIST. Then you panic and
>call the system administrator and request a back up recovery and spend a
>lot of time and effort (sometimes even money) to get a directory replaced
>that never even went away. I just want the correct error message. Is this
>clear now?

If you don't have read permission then the directory isn't there to you.
The fact that you can see it in a listing is because you have read
permission in the parent directory.
-- 
 Jim Budler
 Advanced Micro Devices, Inc.
 (408) 749-5806
 UUCPnet: {ucbvax,decwrl,ihnp4,allegra,intelca}!amdcad!jimb
 Compuserve:	72415,1200

mike@whuxl.UUCP (BALDWIN) (04/21/85)

>    >>% mkdir foo
>    >>% chmod 000 foo
>    >>% cd foo
>    >>foo: no such file or directory
>You don't seem to understand: it shouldn't say: "no such file or directory",
>it should say: "Permission denied."  The example, was just that, an example.

Sorry, folks, but the REAL answer to this is the cdpath variable.  If it can't
chdir somewhere, csh will go down $cdpath, and the error message you end up
getting is that of the LAST component in cdpath:

	% mkdir rc
	% chmod 0 rc
	% set cdpath = (. /etc)
	% cd rc
	rc: Not a directory
	% set cdpath = (/etc .)
	% cd rc
	rc: Permission denied

If cdpath is unset, you will always get the "right" error message.

							Michael Baldwin
							AT&T Bell Labs
							harpo!whuxl!mike

dce@hammer.UUCP (David Elliott) (04/22/85)

In article <9938@brl-tgr.ARPA> argv@ucb-vax.ARPA writes:
>
>    >>% mkdir foo
>    >>% chmod 000 foo
>    >>% cd foo
>    >>foo: no such file or directory
>You don't seem to understand: it shouldn't say: "no such file or directory",
>it should say: "Permission denied."  The example, was just that, an example.
>This "bug" appears all the time whenever the permission is denied, it comes
>up with the wrong error message! Try to cd into a path that you never had
>any problems with and it says that it doesn't even EXIST. Then you panic and
>call the system administrator and request a back up recovery and spend a
>lot of time and effort (sometimes even money) to get a directory replaced
>that never even went away. I just want the correct error message. Is this
>clear now?

The problem is the fact that the csh cd command is running through the
cdpath vector, attempting to do a chdir() each time. When the error message
is finally printed, it is done using the last value of errno (in this case,
ENOENT). Thus, you get "no such file or directory".

Possible fixes:

	1. Change the cd code to print an error message for each attempt
	   that does not result in errno being ENOENT.

	2. Change the cd code to save errno if it isn't ENOENT, and use
	   this saved value (default ENOENT) to print the message.


			David Elliott
			tektronix!tekecs!dce

dave@lsuc.UUCP (David Sherman) (04/22/85)

In article <413@leadsv.UUCP> mfe@leadsv.UUCP (Mark Ellson) writes:
||In his article, ucscc!argv (Dan Heller) argues that the appropriate error
||message when you try to change directory into a directory for which you don't
||have permissions is "Permission denied" instead of "no such file or
||directory".  In fact, while this may be clearer to the user, it falls in the
||same general category as not using "Incorrect password" or "Incorrect
||username" for failed logins.  You never want to tell a potential intruder or
||unauthorized user any information which can be used to infer the existence
||or nonexistence of a protected object.
||
||A possible exception to this rule might be if the software is smart
||enough to check the ownership of the directory, and then generate the
||appropriate error message based upon whether or not you are the owner of
||that directory.

Not really. The test of who's allowed to know the directory
exists is really "who has read permission on the parent directory".
In most UNIX applications, a protected directory that someone
is trying to cd to can be found to exist, even if its execute bit
is off. The error message really should be "Permission denied".

Dave Sherman
The Law Society of Upper Canada
Toronto
-- 
{utzoo pesnta nrcaero utcs hcr}!lsuc!dave
{allegra decvax ihnp4 linus}!utcsri!lsuc!dave

lcc.rich-wiz@UCLA-LOCUS.ARPA (Richard Mathews) (04/23/85)

> Date: Fri, 12 Apr 85 08:25:12 pst
> From: Dan Heller <ucscc!argv@UCB-VAX.ARPA>
>
>     >>% mkdir foo
>     >>% chmod 000 foo
>     >>% cd foo
>     >>foo: no such file or directory
>     >>% WHAT?
>     >>no match.
>
> You don't seem to understand: it shouldn't say: "no such file or directory",
> it should say: "Permission denied."

Sorry, to rehash an old subject, but I'm a few weeks behind in my mail.
Looking through my backlog, however, I do not see the correct description
of the problem; so here goes.

I tried this on both our Locus Distributed System and on Caltech's 4.2 system.
If $cdpath is not defined, I get "Permission denied."  If I do have a cdpath,
I get "no such file or directory."  The problem is that Csh has tried to
do the "cd" relative to each directory in the cdpath and has failed each time.
It then reports the LAST error it encountered.

It seems to me that the best way to report errors in this case would be to
report the FIRST error which is not "no such file."  The "no such file"
message should appear only if EVERY call to chdir() resulted in ENOENT.

Richard M. Mathews
Locus Computing Corporation			       lcc!richard@ucla-cs
					{ucivax,trwrb}!lcc!richard
	 {ihnp4,randvax,sdcrdcf,ucbvax,trwspp}!ucla-cs!lcc!richard