I was looking for a easy way to setup group file permission depending on
the group ownership. Thanks to hflogel_at_mailhub.wpl.com
Jay
>
> Let's say I have user a, b and c, and group x and y. Both user a and b has
> default group of x, c has default group of y. And b also belong to group y.
> And I also have the following directories:
> drwxr-xr-x 1 a x 1024 May 1 20:22 first
> drwxr-xr-x 1 b x 1024 May 1 20:10 second
> drwxrwsr-x 1 c y 1024 May 1 20:10 third
>
> Now I want user b to write to third directory with a default file
> permission of 770. I can easily accomplish this with umask. However, I do
> NOT want to change the umask because I want user b to have a default file
> permission of 755 when writing to second directory. Is there a way
> to accomplish this? Basiclly do selectly umask depending on the parent
> directory permission.
>
Jay,
A variant to the solution you desire can be accomplished with the
"newgrp" and "id" commands.
You can add the following to the user's .profile for Bourne shell,
or .kshrc for Korn shell:
case `id -gn` in
"x") umask 755;;
"y") umask 770; cd third;;
esac
When the user "b" wants to work in the "third" directory, use the command
"newgrp y", which will change the file permission mask to the desired
value. To revert to the default group give the "newgrp" command without
an argument, this will also revert the file permission mask. There is one
caveat. User "b" can write to both directory "second" and "third" regardless
of his current group id setting; just belonging to group "y" gives "b" the
correct permissions to put and modify files there, and "b" is the owner of
directory "second" which also gives "b" sufficient rights there. So, user
"b" must always be aware of the current group id setting and the current
working directory.
Hope this helps.
Hal
hflogel_at_mailhub.wpl.com
Received on Mon May 13 1996 - 18:12:05 NZST