Re: Automatically maintaining permissions on specific directories
On (18/09/05 16:25), Olle Eriksson wrote:
> On Sunday 18 September 2005 02.37, Clive Menzies wrote:
> > On (18/09/05 01:39), Olle Eriksson wrote:
> > > Is there any way to enforce the permissions on a specific directory
> > > so that everything that is in it will always have the correct
> > > permissions?
> > >
> > > I know a simple cron job can do the job but I have fucked up more
> > > file and directory permissions than wanted on more than one occasion
> > > this way. And also, it would be nice to know that any files moved to
> > > a certain directory (like public_html) will get the correct
> > > permissions instantly without having to issue a chmod command or wait
> > > for the cron job to finish.
> > >
> > > I used to have a partition with the FAT32 filesystems, which allows
> > > you to set global values for user id, group id and permissions (with
> > > uid, gid, umask, dmask and fmask). Then, all files moved to this
> > > filesystem would get the specified permissions automatically. A while
> > > ago I switched to XFS because I needed to be able to have files
> > > larger than 2 Gb, and XFS doesn't have these features.
> >
> > When I asked this question, someone posted something like this:
> >
> > Prepare a directory hierarchy for group use, do the following as
> > root:
> > # chgrp -R $group $dir
> > # find $dir -type d -print0 | xargs -0 chmod 2770
> > (You can use mode 2775, depending on needs for further information see
> > 'man chmod' and google on Linux permissions)
> >
> > # sudo find $dir -type f -print0 | xargs -0 chmod 660
> > (likewise, you may also use mode 664...)
> >
> >
> > An alternative to the above is:
> > # sudo find $dir -type f -print0 | xargs -0 chmod g=u,o=-rwx
> > This will clear permissions for others and set group permissions to the
> > user permissions. This will preserve executable permissions. Give
> > yourself membership of the various groups to test permissions,
> > ownership, etc.
>
> Well all of these solutions require you to set the permissions either
> manually or via a cron script or something similar. I'm looking for
> something that will automatically do this so that the files will have the
> correct permissions as soon as they have been copied into the directory.
> Maybe pam can observe a directory and apply the permissions when it
> senses any changes to the directory's files or something. Is there
> nothing like this out there?
>From man cp:
--preserve[=ATTR_LIST]
preserve the specified attributes (default: mode,owner-
ship,timestamps), if possible additional attributes: links, all
--no-preserve=ATTR_LIST
don't preserve the specified attributes
Having set the ownership and permissions as above, as long as you
cp --no-preserve=ATTR_LIST
It should conform to the structure already established - I am no expert
and so I should test this 'theory' :)
Regards
Clive
--
www.clivemenzies.co.uk ...
...strategies for business
Reply to: