develooper Front page | perl.perl5.porters | Postings from June 2008

Re: [PATCH] File::Copy & permission bits.

Thread Previous | Thread Next
Aaron Crane
June 13, 2008 03:55
Re: [PATCH] File::Copy & permission bits.
Message ID:
Aristotle Pagaltzis writes:
> On Win32, files can inherit permissions from the directory they’re
> in, which is why not carrying the permissions along from the old
> file is OK and even desirable. No such thing exists in Unix.

Depending on what one means by “inherit”, that’s not quite true.
Consider setgid directories:

  $ mkdir foo
  $ chgrp admin foo
  $ ls -ld foo
  drwxrwxr-x 2 aaron admin 4096 2008-06-13 11:52 foo
  $ touch foo/normal-file
  $ mkdir foo/normal-dir
  $ chmod g+s foo
  $ ls -ld foo
  drwxrwsr-x 3 aaron admin 4096 2008-06-13 11:52 foo
  $ touch foo/setgid-file
  $ mkdir foo/setgid-dir
  $ ls -l foo
  total 8K
  drwxrwxr-x 2 aaron aaron 4096 2008-06-13 11:52 normal-dir
  -rw-rw-r-- 1 aaron aaron    0 2008-06-13 11:52 normal-file
  drwxrwsr-x 2 aaron admin 4096 2008-06-13 11:52 setgid-dir
  -rw-rw-r-- 1 aaron admin    0 2008-06-13 11:52 setgid-file

Files created inside a setgid directory acquire the group ownership
of the directory; directories created inside a setgid directory
additionally acquire the setgid bit.

That transcript was done on Linux; as I understand it, BSD-derived
systems, including Mac OS X, treat all directories as setgid.

My caveat about the meaning of “inherit” is that this only applies at
the instant when an inode is created with its initial name a child of
a directory with setgid semantics.  I’m not sufficiently familiar with
Win32 to know whether the permission inheritance you mention applies
to, for example, files moved into a directory after their creation.

Aaron Crane **

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About