Originally Posted by catkin
That or something like it would work but I'm developing scripts that may be of more than personal use and do not want to require any modifications to the standard system.
Other possible workarounds are:
- a suid-root binary executable, simply to analyse /var/log/messages. Better to avoid suid-root binaries if possible.
- start the application as root and drop to another user:group after doing the necessary. Not so good; the application could not then be started by a non-root user.
Don't forget two other options:
1) Check the file permissions - if the user running the program can't read /var/log/messages then (i) disable that particular functionality and (ii) notify the user of how to get this functionality back (i.e. run as root/change the perms on messages). Of course, this is of no use if that functionality is essential to your program!
2) Just exit the program with an error message unless the person is root, or at least has read access to /var/log/messages. Some programs need
to be run as root/an admin, and there's just no way around it.