9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] chdir to mode 000 directory
@ 2004-06-03  6:01 YAMANASHI Takeshi
  2004-06-03  6:19 ` lucio
  0 siblings, 1 reply; 6+ messages in thread
From: YAMANASHI Takeshi @ 2004-06-03  6:01 UTC (permalink / raw)
  To: 9fans

> > % ls -ld dir
> > d---------- M 9 nashi nashi 0 Jun  3 10:51 dir
> > % cd dir
> > %  __chdir succeeds!__
 :
> The semantics of directory permissions are different: you can walk to
> a directory without permission,

Thank you.  My confusion is cleared now.  So when I want to
check if a process can chdir to a directory, the following
fragment is good enough?

	if(access("/usr/hoge/adir", AREAD) < 0){
		// error, can't chdir to adir
			:
	}


I thought the following should work at first, hence my question.
	if(chdir("/usr/hoge/adir") < 0){
		// error, can't chdir to adir
			:
	}
-- 




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] chdir to mode 000 directory
  2004-06-03  6:01 [9fans] chdir to mode 000 directory YAMANASHI Takeshi
@ 2004-06-03  6:19 ` lucio
  2004-06-06  7:10   ` YAMANASHI Takeshi
  0 siblings, 1 reply; 6+ messages in thread
From: lucio @ 2004-06-03  6:19 UTC (permalink / raw)
  To: 9fans

> Thank you.  My confusion is cleared now.  So when I want to
> check if a process can chdir to a directory, the following
> fragment is good enough?

I'm not sure.  When out of one's comfort zone, only testing can reveal
the truth.  The man pages, if read carefully, do reveal what happens,
but you should let the developers give their opinion.

If you're in a hurry, I should think stat(2) will supply the
information you need.

++L



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] chdir to mode 000 directory
  2004-06-03  6:19 ` lucio
@ 2004-06-06  7:10   ` YAMANASHI Takeshi
  2004-06-06  7:33     ` Rob Pike
  0 siblings, 1 reply; 6+ messages in thread
From: YAMANASHI Takeshi @ 2004-06-06  7:10 UTC (permalink / raw)
  To: 9fans

> If you're in a hurry, I should think stat(2) will supply the
> information you need.

I wasn't in a hurry and I read through stat(2), intro(5), stat(5)
(thank you for the suggestiong, lucio).

I misunderstood the search permission of a directory
as specifying whether if one can walk to the directory
itself and I learned it's not.  It specifies if one can
issue walk in the directory.

Having understood this semantic, there ocurred a question
to me.  This is yet another departure from UNIX semantics
isn't it?  Why is this so?

I always be curious of this kind of things.  I am eager
to learn what lies behind the decisions of Plan 9 architects.
Could someone slip what is or was in his mind? :)
-- 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] chdir to mode 000 directory
  2004-06-06  7:10   ` YAMANASHI Takeshi
@ 2004-06-06  7:33     ` Rob Pike
  0 siblings, 0 replies; 6+ messages in thread
From: Rob Pike @ 2004-06-06  7:33 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> Having understood this semantic, there ocurred a question
> to me.  This is yet another departure from UNIX semantics
> isn't it?  Why is this so?

plan 9 was not designed by going down a list of unix features
and choosing which ones to change.  it was started from
scratch, so many details are different just because they ended
up different, given the overall design.  the permission model
was designed from scratch, for instance.

-rob


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] chdir to mode 000 directory
  2004-06-03  1:58 YAMANASHI Takeshi
@ 2004-06-03  5:49 ` lucio
  0 siblings, 0 replies; 6+ messages in thread
From: lucio @ 2004-06-03  5:49 UTC (permalink / raw)
  To: 9fans

> Clearly, I'm missing something..., but how do I interpret
> this behaviour?
> 
> % mkdir dir
> % chmod 000 dir
> % ls -ld dir
> d---------- M 9 nashi nashi 0 Jun  3 10:51 dir
> % cd dir
> %  __chdir succeeds!__
> % pwd
> pwd: permission denied
> -- 

The semantics of directory permissions are different: you can walk to
a directory without permission, but you can't walk to its elements.
It may seem odd, but I presume it is more consistent.  Perhaps a
result of using 9P?

++L



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [9fans] chdir to mode 000 directory
@ 2004-06-03  1:58 YAMANASHI Takeshi
  2004-06-03  5:49 ` lucio
  0 siblings, 1 reply; 6+ messages in thread
From: YAMANASHI Takeshi @ 2004-06-03  1:58 UTC (permalink / raw)
  To: 9fans

Clearly, I'm missing something..., but how do I interpret
this behaviour?

% mkdir dir
% chmod 000 dir
% ls -ld dir
d---------- M 9 nashi nashi 0 Jun  3 10:51 dir
% cd dir
%  __chdir succeeds!__
% pwd
pwd: permission denied
-- 




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-06-06  7:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-03  6:01 [9fans] chdir to mode 000 directory YAMANASHI Takeshi
2004-06-03  6:19 ` lucio
2004-06-06  7:10   ` YAMANASHI Takeshi
2004-06-06  7:33     ` Rob Pike
  -- strict thread matches above, loose matches on Subject: below --
2004-06-03  1:58 YAMANASHI Takeshi
2004-06-03  5:49 ` lucio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).