Jason
On Wed, Mar 16, 2016 at 12:09 PM Jason Brockdorf via Xymon <xymon at xymon.com> wrote:
I'm getting an error message: Cannot create output directory
here's what I've done so far to try to fix it:
- going to the /var/cache/xymon/ directory and creating a rep directory
You haven't set what your XYMONREPDIR is set to. On my system it's /usr/lib/xymon/server/www/rep/. On yours, it's probably ~xymon/server/www/rep/.
- giving rwxrwxrwx permissions to that directory
That's a common solution to a permissions problem, but is not recommended. I'm hoping you are planning on removing the permissions once you get the problem sorted. When making world-writeable directories, it's best to set the sticky bit to avoid some potential security risks. Do this with "chmod +t /path/to/dir". The permissions should look the same as /tmp:
$ ls -ld /tmp drwxrwxrwt 30 root root 344064 2016-03-16 14:33 /tmp
But when you think about it, there are only two possible users. One is the xymon user and the other is the apache user.
On my system, there's a www group, to which the apache user belongs. My "rep" directory is writeable by both the xymon user and the apache group, so that it looks like this:
$ ls -ld ~xymon/server/www/rep drwxrwxr-x 3 xymon www 4096 2016-02-23 14:17 /usr/lib/xymon/server/www/rep
The XYMONREPDIR environment variable is used in creating the directory
where the report will go, but I don't know:
- How to check which process is running the file that's encountering the problem (httpd or some xymon process)
It's the web server, so "apache" or "wwwrun" or whatever your web server is running as.
- How to check for the presence or value of this variable in the environment that process is using
The relevant variables are set by CGI shell scripts. These scripts import variables from cgioptions.cfg, which in turn pulls in variables from xymonserver.cfg, and in particular, XYMONREPDIR.
You can probably simulate the environment that the CGI process runs as, fairly accurately, by doing:
$ sudo -u www ~xymon/server/bin/xymoncmd --env=echo ~xymon/server/etc/cgioptions.cfg --env=echo ~xymon/server/etc/xymonserver.cfg
$ echo $XYMONREPDIR
/usr/lib/xymon/server/www/rep
Thus, it would seem that I am unable to reproduce the problem with "stock"
xymon, and I'm apparently not bright enough to fix it with terabithia srpms either. At this point, I feel like I've put in enough effort to warrant asking for help. Anyone, please help?
I'm not aware of a fault with the Terabithia (S)RPMs. At this stage I'm not sure you've proven that it's a problem with the package and not a problem with a config file or directory permission. I don't think you mentioned the OS you're using, and so it's possible that the Terabithia packages are not quite in alignment with your OS.
I had a look through your patch, and I can't see any reason why it would not work.
What I would do is create a copy of the report.sh script, eg report-test.sh and update it to run "strace" against the binary, so it looks like this:
exec strace -f /usr/lib/xymon/server/bin/report.cgi $CGI_REP_OPTS $XYMONGENREPOPTS 2>/tmp/report.stderr
Then run a report in your browser by adjusting the URL, and check the output file /tmp/report.stderr. This will not only show you where it's trying to create a report file, but the ownership of the file will tell you what user needs to own the rep directory.
Cheers Jeremy