views:

52

answers:

2

I am writing a python script that needs to make a log entry whenever it's invoked. The log created by the script must not be changeable by the user (except root) who invoked the script. I tried the syslog module and while this does exactly what I want in terms of file permissions, I need to be able to put the resulting log file in an arbitrary location. How would I go about doing this?

A: 

Run your script with setuid root.

compie
Having a script setuid root just to make a log entry is definitely NOT a good idea.
mgv
I believe this got me started in the right direction. As I understand in, creating a C wrapper binary for the script and then setuid root on it is more secure, right?
Travis
never. ever. setuid scripts.
hop
+1  A: 

I see you are on linux,

Depending on which filesystem you are using, you may be able to use the chattr command. You can make files that are append only by setting the a attribute

gnibbler