[Gllug] Recursively setting file permissions
Tethys
tet at createservices.com
Sun May 2 22:27:40 UTC 2004
Dylan writes:
>will set all files as executable which is not on since none of them are!
>So what do I need to do to get the correct permissions? In other words
>- how can I get chmod to discriminate between files and directories?
You can't. However, you can call chmod selectively, using find to
discriminate between the two:
find /top/level/directory -type d -exec chmod 770 {} \;
find /top/level/directory -type f -exec chmod 660 {} \;
>Also, is it possible to have new files and directories to automatically
>have the correct permissions? (I know about umask, but want to retain
>the default for home directories, just have the rwxrwx--- for this
>shared data area.
No, not as far as I'm aware. I guess it may be theoretically possible
to have a per-directory umask using filesystem attributes under Linux,
but AFAIK no one has implemented it yet, and it would be inherrently
non-portable. But even then, umask can only remove permissions, not
add them. The only way to explicitly set permissions on a file at
creation time is with the mode argument to open(2). You could, I
suppose, write a shim library to intercept calls to open(2) and
give them the desired mode depending on the directory (albeit with
a performance hit).
Tet
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list