Discussion Locked

Inherit permissions

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have an application which creates rotating log files in a directory. Because this application can only run as root, the log files are created with root permissions. Is there any way I can force newly created files to automatically inhherit the permissions of their parent directory or other specified permissions? (i.e. I don't want to change the file permissions using chown/chgrp/chmod)

OS is Redhat 9 and just in case it's relevant, the application is Tethereal.

6 replies

by lyon_bleu

There is no option in Ethereal nor Tethereal to alter the
permissions of the output file specified by -w. The best I could
suggest would be a shell function or script that includes a test
for when the app is finished writing to the file and then changes
the permissions according to a preset array--perhaps using the
-o option--or by getting the permissions of the parent directory
with the file's path and setting that to a variable.

Coming at it from a different POV, if you are looking to minimize
the risks of logging in as root to read the logs, you can, under
KDE, run a shell as root regardless of which account you are
logged in from.

If you are looking to share the logs, perhaps writing them to a /
Public/Drop_Box/ or something similar might work.

HTH,

paul

by spidererrol

I suggest setting the owner and group of the directory to be one that your user belongs to ("chown myuser: /path/to/dir"), then setting the set-gid bit on the directory ("chmod g+s /path/to/dir") which will make all files created in that directory gain the same group as the directory. You will probably need to run these commands as root, but they should be one-shot to set up the directory.
Then as root before running tethereal set your umask to be 007 ("umask 007") so that the permisions on the files will be set to accessable by group.
You should then be able to access those files and delete them as needed. Unfortunatly you will not be able to alter permisions or change ownership of the files. For that you would need to chown as root.
This is the closest to inheritance you can get with standard unix permisions. I belive ACLs may offer better options but I haven't had the chance to play with them much.

This discussion is closed to new replies.