I would say so, yes:pamplifier wrote:One question, I just realized that I need root privileges to access the logs in /var/log/. I didn't notice because I'm almost always running as root on my test machine. Could the seg fault be due to the fact that the nagios user is trying to access the logfiles when it doesn't have permission to?
Code: Select all
nagios@localhost: /tmp
$ ls -l check_thing somelog
-rwxr-xr-x 1 root root 11725 Jul 24 11:38 check_thing
-rwx------ 1 root root 64 Jul 24 11:45 somelog
nagios@localhost: /tmp
$ ./check_thing -F somelog -w 5 -e 10
Segmentation fault
nagios@localhost: /tmp
$
Code: Select all
FILE* logfile = fopen(logpath, "r");
if (logfile == NULL) {
printf("CHECK YOUR PERMS!\n");
return 1;
}
fseek(logfile, loffset, SEEK_SET);
fseek(thingfile, moffset, SEEK_SET);
That's probably the "right way" to do this. I would need to look over the code for the plugins that do this though to find out for sure how they work.pamplifier wrote:Right now I'm looking up ways to ameliorate this, including how Nagios' does it with its pre-existing plugins in /plugins-root. I'm thinking of adding a new rule to /etc/sudoers, is that the best solution for this?